In a Sauce program, swap withDynamic distribution AMM with directional liquidity positioning. Allows LPs to follow price movements automatically with customizable bin strategies. Uses pool addresses directly (no path routing).@sauce/router’s function for the venue (uniswapV2,uniswapV3,uniswapV4,curve,balancerV2, …; Slipstream, PancakeSwap V3 and Algebra pools throughuniswapV3), with a minimum output and, where the pool takes one, a price limit (the@sauce/routerreference; several pools under one limit, the distributed swap).
What it offers
- swap: Exact input single swap via V2 Router, specifying pool address and direction
Notes
- Uses
tokenAInbool instead of separate token addresses to specify swap direction within a pool - Pool address must be provided directly (no built-in path routing like Uniswap)
- Use
factory.lookup(tokenA, tokenB, 0, n)to discover available pools for a pair - Parameter order is unusual:
recipientis the FIRST parameter, not the last - Maverick’s key innovation is directional LP strategies: bins can be configured to move with price in one direction
- LP modes: Static (like Uniswap V3), Right (follow price up), Left (follow price down), Both (follow both)
- Input token must be ERC20-approved to the V2 Router
- From a Pot program,
@sauce/router’smaverickV2(pool, tokenIn, tokenOut, amountIn, minOut, recipient)swaps a Maverick V2 pool through the Pot’s Sauce Router, which pays in the pool’s callback exactly what the pool asks for, so a partial fill strands nothing: what the pool did not take stays in the Pot. It does not use the pool’s pre-pay mode, where the unfilled part of a pushed input would stay in the pool. ThemaverickV2Swapaction is the same call
Its names in a program
On Ethereum,Maverick is a namespace: its contracts need no import.
Deployments
ABI
Where a line says what an address it returns is, a program that calls the function through its namespace calls that contract’s methods on the result directly:<Namespace>.<Contract>.<function>(...).<method>(...). A token’s methods are the ERC-20
functions, and its writes are SafeERC20.
MaverickV2FactoryABI
import MaverickV2FactoryABI from "./protocols/maverick/MaverickV2FactoryABI.json"; Speaks for: v2Factory.
lookup(address tokenA, address tokenB, uint256 startIndex, uint256 endIndex) view returns (address[] pools)
MaverickV2PoolABI
import MaverickV2PoolABI from "./protocols/maverick/MaverickV2PoolABI.json";
getState() view returns ((uint128 reserveA, uint128 reserveB, int64 lastTwaD8, int64 lastLogPriceD8, uint40 lastTimestamp, int32 activeTick, bool isLocked, uint32 binCounter, uint8 protocolFeeRatioD3))fee(bool tokenAIn) view returns (uint256)tickSpacing() view returns (uint256)tokenA() view returns (address): the address is a tokentokenB() view returns (address): the address is a token
MaverickV2RouterABI
import MaverickV2RouterABI from "./protocols/maverick/MaverickV2RouterABI.json"; Speaks for: v2Router.
exactInputSingle(address recipient, address pool, bool tokenAIn, uint256 amountIn, uint256 amountOutMinimum) payable returns (uint256 amountOut)exactOutputSingle(address recipient, address pool, bool tokenAIn, uint256 amountOut, uint256 amountInMaximum) payable returns (uint256 amountIn, uint256 amountOut)
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.
