Every template is a complete, runnable Sauce script with its own live playground. Read the source, run it against Base, and adapt it to your use case.
const outA = quoter.quoteExactInputSingle({...});const outB = quoter.quoteExactInputSingle({...});// Branch at inclusion on live quotesconst pool = outA > outB ? poolA : poolB;return router.exactInputSingle({...});Quote every venue inside the transaction and route through the winner. Decision is made at inclusion against the live pool state.
const legs = split(amount, pools);const out = await Promise.all( legs.map(l => swap(in, out, l.amt, l.pool)));require(sum(out) >= minOut, "min not met");return sum(out);Atomically split an order across N pools, execute in parallel, and recombine against a floor. Bigger sizes, smaller per-leg impact.
@contractexport class ERC20 { balanceOf = new Map<address, uint256>(); transfer(to: address, amt: uint256) { this.balanceOf.sub(msg.sender, amt);Same ERC-20 spec in 11 lines of TypeScript vs 28 lines of Solidity. Identical selectors, identical gas, identical audit surface.
token.transferFrom(caller, THIS_ADDRESS(), amountIn);// adaptive swap across discovered pools…const swapDelta = postBal[0] - preBal[0];outToken.approve(aavePool, swapDelta);IAavePool.at(aavePool).supply(tokenOut, swapDelta, beneficiary, 0);PLACEHOLDER — Swap USDC into WETH across the best Base pools and supply the WETH to Aave V3 for a beneficiary, in one atomic Sauce program.