Router
Interacting with the Router (code examples)
Getting the pool for a pair
IRouter router = IRouter(routerAddress);
address pool = router.poolFor(tokenA, tokenB, address(0));
// address(0) for factory means use router.defaultFactory()Quoting a single-hop swap
IRouter.Route[] memory routes = new IRouter.Route[](1);
routes[0] = IRouter.Route({
from: usdc, // token in
to: usdm, // token out
factory: address(0)
});
uint256[] memory amounts = router.getAmountsOut(amountIn, routes);
// amounts[0] == amountIn, amounts[1] == expected amount out (at oracle rate minus fee)Quoting a multihop swap
Executing a swap (exact input)
Adding liquidity
Immutable configuration
Token order
Pool resolution
Quoting
Swap execution
Add / remove liquidity
See also
Last updated