In a Sauce program, swap withDEX on Polygon with V2 (constant product, x*y=k) and V3 (Algebra-based concentrated liquidity with dynamic fees) pools.@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
- swapV2: Swap via V2 router with path routing
- swapV3: Swap via V3 router with concentrated liquidity (Algebra, dynamic fees)
- addLiquidity: Add liquidity to V2 pools
- removeLiquidity: Remove liquidity from V2 pools
Notes
- V3 uses Algebra protocol (same as Camelot V3): dynamic fees that adjust based on volatility, NOT fixed fee tiers
- V3 uses
limitSqrtPriceinstead ofsqrtPriceLimitX96 - Polygon-only deployment
- V2 uses standard Uniswap V2 interface with 0.3% fee
- Prefer V3 for major pairs (better capital efficiency with dynamic fees)
Its names in a program
On Polygon,Quickswap 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.
QuickSwapV2FactoryABI
import QuickSwapV2FactoryABI from "./protocols/quickswap/QuickSwapV2FactoryABI.json"; Speaks for: v2Factory.
getPair(address tokenA, address tokenB) view returns (address pair): the address is aQuickswap.V2Pair
QuickSwapV2PairABI
import QuickSwapV2PairABI from "./protocols/quickswap/QuickSwapV2PairABI.json";
getReserves() view returns (uint112 _reserve0, uint112 _reserve1, uint32 _blockTimestampLast)token0() view returns (address): the address is a tokentoken1() view returns (address): the address is a tokenswap(uint256 amount0Out, uint256 amount1Out, address to, bytes data)
QuickSwapV2RouterABI
import QuickSwapV2RouterABI from "./protocols/quickswap/QuickSwapV2RouterABI.json"; Speaks for: v2Router.
swapExactTokensForTokens(uint256 amountIn, uint256 amountOutMin, address[] path, address to, uint256 deadline) returns (uint256[] amounts)addLiquidity(address tokenA, address tokenB, uint256 amountADesired, uint256 amountBDesired, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256 amountA, uint256 amountB, uint256 liquidity)removeLiquidity(address tokenA, address tokenB, uint256 liquidity, uint256 amountAMin, uint256 amountBMin, address to, uint256 deadline) returns (uint256 amountA, uint256 amountB)
QuickSwapV3FactoryABI
import QuickSwapV3FactoryABI from "./protocols/quickswap/QuickSwapV3FactoryABI.json"; Speaks for: v3Factory.
poolByPair(address tokenA, address tokenB) view returns (address pool): the address is aQuickswap.V3Pool
QuickSwapV3PoolABI
import QuickSwapV3PoolABI from "./protocols/quickswap/QuickSwapV3PoolABI.json";
globalState() view returns (uint160 price, int24 tick, uint16 fee, uint16 timepointIndex, uint8 communityFeeToken0, uint8 communityFeeToken1, bool unlocked)liquidity() view returns (uint128)tickSpacing() pure returns (int24)token0() view returns (address): the address is a tokentoken1() view returns (address): the address is a token
QuickSwapV3SwapRouterABI
import QuickSwapV3SwapRouterABI from "./protocols/quickswap/QuickSwapV3SwapRouterABI.json"; Speaks for: v3SwapRouter.
exactInputSingle((address tokenIn, address tokenOut, address recipient, uint256 deadline, uint256 amountIn, uint256 amountOutMinimum, uint160 limitSqrtPrice) params) payable returns (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.
