A canonical ERC-20 written in 11 lines of TypeScript. Same selectors, same gas, same audit surface as Solidity.
1// ERC-20 transfer as SauceScript. Balances live in storage,2// keyed by keccak256(account, slot). The compiler emits Sauce3// bytecode the same engine executes on chain.4function balanceSlot(account) {5 return crypto.keccak256(abi.encode(account, 1));6}78function main(to, amount) {9 const from = msg.sender;10 const fromSlot = balanceSlot(from);11 const fromBalance = storage.read(fromSlot);12 if (fromBalance < amount) throw "insufficient balance";1314 storage.write(fromSlot, fromBalance - amount);15 const toSlot = balanceSlot(to);16 storage.write(toSlot, storage.read(toSlot) + amount);1718 emit("Transfer(address,address,uint256)", { from, to, amount }, "from", "to");19 return 1;20}Sauce accepts TypeScript with EVM-native types and emits the same bytecode you would get from hand-written Solidity. The example here is the ERC-20 spec in 11 lines. Same selectors, same gas, same audit surface.
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.
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.