When to use it
- An aggregator: its router fills a swap across many venues along a route its off-chain API quotes. Use it for a route the program does not want to choose itself.
Pitfalls for a program
- The calldata is quoted for one sender, amount and moment: quote it for the Pot (the swap’s sender) and send it soon.
- Approve the router for exactly
amountIn, and clear the allowance after. - The calldata’s own minimum is not yours: check the output as a balance delta against your
minOut.
In a Sauce program
Forward a 1inch quote for the Pot, checked by the WETH received:What it offers
- unoswap: Single-source optimized swap via AggregationRouter
- swap: Multi-source aggregated swap with custom routing
Notes
- Same contract address across all 7 chains
- V6 router is the latest version
- unoswap is gas-efficient for single-pool swaps; swap handles complex multi-hop routes
dexin unoswap packs the pool address with its protocol and swap-direction flags in the high bits- Fusion mode enables gasless swaps via order matching (off-chain, not in ABI)
- Approve srcToken to aggregationRouterV6 before swapping
Its names in a program
On Ethereum,Oneinch is a namespace: its contracts need no import.
Deployments
ABI
AggregationRouterV6ABI
import AggregationRouterV6ABI from "./protocols/oneinch/AggregationRouterV6ABI.json"; Speaks for: aggregationRouterV6.
swap(address executor, (address srcToken, address dstToken, address srcReceiver, address dstReceiver, uint256 amount, uint256 minReturnAmount, uint256 flags) desc, bytes data) payable returns (uint256 returnAmount, uint256 spentAmount)unoswap(uint256 token, uint256 amount, uint256 minReturn, uint256 dex) returns (uint256 returnAmount)
Next steps
- Protocols: the other protocols, by what they do.
- Protocols and tokens: calling a contract by its namespace, or through its ABI.
- Glossary: the words these pages use, in plain terms.
