main parameters supplied at run time. The program imports its contract ABIs as JSON artifacts placed beside the source.
Prerequisites
- Complete Sauce setup, including access, a Pot and the current Kitchen fee.
- Use Base mainnet (chain ID
8453) and two Uniswap V3 pools for the same token pair. - The caller must hold the input tokens and approve the Pot to spend
amountIn. - Save these four ABI files beside the program: IERC20, IV3SwapRouter, IUniswapV3Pool, and IQuoterV2.
- Supply a minimum acceptable output in the output token’s smallest unit. Review the compiler compatibility limitation before execution.
Program
best-pool-swap.sauce.ts
What to notice
- The two quotes and the swap happen in the same transaction, so the decision is made against the state the swap executes in.
- Under a Pot delegatecall,
ctx.self()is the Pot, so the input tokens are pulled to the Pot and the router is approved from there. - The struct arguments use positional keys (
atog). The SauceScript reference explains the naming rules for struct fields.
Run it
Compile with@eco-incorp/sauce-compiler (target: "evm") with the four ABI JSON files next to the source, append the seven main arguments as 32-byte words, and execute through your Pot with the Kitchen fee. See Getting started with Sauce.
