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.Pooldeclares no lookup of a reserve’s aToken (sauce globals --chain base --protocol AaveV3lists the methods it declares). The program therefore takes the aUSDC address as theaTokenparameter and reads the Pot’s supplied USDC asToken(aToken).balanceOf(pot). supplynamespotasonBehalfOf, 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.withdrawnis 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 asaToken. Nothing was signed or sent.
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
- Repay by health factor: repays the Pot’s Aave V3 USDC debt when its health factor is below a target.
- Borrow with a health-factor floor: supplies WETH, borrows USDC and requires a minimum health factor in one cook.
sauce simulate, Names, Protocols reference.
