Skip to main content
This program keeps a target USDC reserve in the Pot. It supplies excess USDC to Aave V3 or withdraws from the Pot’s Aave position to cover a shortfall. It skips movements smaller than minMove. The program checks the supplied token address, verifies the balance after a supply and checks the amount withdrawn. An unhandled failure from Aave reverts the cook. Target chains: Base and Ethereum. Both registries include USDC and AaveV3.Pool; the recorded simulation uses a Base fork.

Prerequisites

Install the Sauce CLI to compile and simulate. To send the transaction, configure a wallet with USDC for the program and native coin for gas and the Kitchen fee.

Program

pot is the Pot the program runs on, available without declaring it (Names).
supply-idle.sauce.ts

How it works

  • The registry’s AaveV3.Pool declares no lookup of a reserve’s aToken (sauce globals --chain base --protocol AaveV3 lists the methods it declares). The program therefore takes the aUSDC address as the aToken parameter and reads the Pot’s supplied USDC as Token(aToken).balanceOf(pot).
  • supply names pot as onBehalfOf, so the aUSDC is minted to the Pot. A later run of the same program withdraws from that balance; aUSDC credited to a wallet could not be withdrawn by a cook.
  • withdraw’s result is discarded, and a discarded result is neither decoded nor checked. withdrawn is therefore the change in the Pot’s USDC, and the program requires it to be at least the amount asked.

Run the example

1

Compile

2

Simulate

--assume-balance USDC:1000 gives the Pot 1,000 USDC for this simulation only, 500 above a reserve of 500 USDC, so the program takes the supply branch. <aToken> is Aave’s aUSDC on the chain: on Base, the aBasUSDC address in the program’s header.
3

Send

--fund USDC:1000 pulls 1,000 USDC from your wallet into the Pot in the same cook. sauce tx prints the unsigned transactions instead, for your own signer: the Pot’s deployment if it has no code yet, the transfer of the USDC into the Pot, then the cook.

Simulation result

Simulated on a local fork of Base at block 52965104 with the current contracts. The command is the one above, with aBasUSDC as aToken. Nothing was signed or sent.
The Pot held 1,000 USDC against a 500 USDC reserve, so the program supplied the 500 USDC excess and kept 500 liquid. Aave minted 499.999999 aBasUSDC to the Pot, which deposited reports. The cook used 303,066 gas. The withdrawal branch was not simulated: it needs aUSDC in the Pot, and sauce simulate refuses --assume-balance for aBasUSDC because the token computes its balance rather than storing it.

Next steps