sauce actions converts it to a SauceScript program that swaps WETH for USDC on Uniswap V3, approves the USDC received, and supplies it to Aave V3 for the Pot.
The cook reverts if the pool is missing, the swap delivers less than the document’s 2,000 USDC minimum, or the approval or supply fails. Set the minimum for your input amount and market conditions before sending.
Target chains: Base. The document names no chain and no address, so it compiles for any chain that registers WETH, USDC, UniswapV3.Factory and AaveV3.Pool; it was compiled and simulated on Base.
Prerequisites
Install the Sauce CLI to compile and simulate. To send the transaction, configure a wallet with WETH for the program and native coin for gas and the Kitchen fee.Document
actions-swap-supply.json
sauce actions actions-swap-supply.json --chain base prints the program it lowers to. An excerpt, with the inlined approval elided:
How it works
- The
argumentaction becomesmain’s parametera_wethIn, so one compiled document takes any amount through--args.amountOutMincannot be an argument: it is a string fixed in the document, so 2,000 USDC is the minimum for everywethIn. Set it again from a quote when you change the amount. - The pool is given by key (
factory+fee). The program reads it fromUniswapV3.Factory.getPoolwhile it runs and reverts withactions[1]: no pool under that keyif there is none. The swap is a call to@sauce/router’suniswapV3, the same function a SauceScript program imports. saveOutputAs: "usdc"names the swap’s output, and both the approval and the supply spend exactly that amount throughamountRef. The approval is lowered to an inline checked approve that resets a non-zero allowance first.- The document cannot do what the SauceScript version does: quote two pools and choose one at run time. The actions format has no quote, comparison or condition action; each swap names its pool when the document is written.
Run the example
1
Lower
main’s parameters and the bytecode (898 bytes on Base).2
Compile
3
Simulate
--assume-balance WETH:1 gives the Pot 1 WETH for this simulation only, and --args gives the argument actions in the order the document declares them. If your Pot is not deployed yet, the simulation deploys it first.4
Send
--fund WETH:1 pulls 1 WETH from your wallet into the Pot in the same cook. To sign elsewhere, build the unsigned transactions instead:Simulation result
Simulated on a local fork of Base at block 52965104 with the current contracts. Nothing was signed or sent.0xd0b5…F224) took 1 WETH and paid 2,380.895733 USDC, above the 2,000 USDC minimum, and the Pot supplied all of it to Aave. With onBehalfOf: "pot", the Pot holds the 2,380.895732 aBasUSDC; a later cook on the same Pot can withdraw it. main returns nothing, so the cook returns 0x.
Next steps
- Quote two pools, swap on the better one, supply to Aave: the same flow in SauceScript, choosing the pool at run time.
- Low-level calls: raw calldata and a program’s own ABI, for what neither the actions format nor the registry covers.
sauce actions,sauce simulate, Protocols reference.
