Skip to main content
In a Sauce program, swap with @sauce/router’s function for the venue (uniswapV2, uniswapV3, uniswapV4, curve, balancerV2, …; Slipstream, PancakeSwap V3 and Algebra pools through uniswapV3), with a minimum output and, where the pool takes one, a price limit (the @sauce/router reference; several pools under one limit, the distributed swap).
Concentrated liquidity AMM on BNB Chain and multiple EVM chains. Built on Uniswap V3 architecture with custom fee tiers and farming integration via the SmartRouter.

What it offers

  • swap: Exact input single-hop swap with fee tier selection via SmartRouter

Notes

  • Fee tiers may differ from Uniswap V3; PancakeSwap includes a 2500 (0.25%) tier
  • SmartRouter struct does NOT include deadline (unlike Uniswap V3’s router)
  • Factory address is the same across all chains; SmartRouter addresses vary
  • NFPM address is consistent across all chains (0x46A15B...)
  • Swapping through the SmartRouter needs the input token approved to it. From a Pot program, @sauce/router’s uniswapV3(pool, tokenIn, tokenOut, amountIn, sqrtPriceLimitX96, minOut, recipient) swaps a PancakeSwap V3 pool (PancakeswapV3.Factory.getPool(tokenA, tokenB, fee)) with no approval: it calls the Pot’s Router, which answers the pool’s pancakeV3SwapCallback from the Pot (the @sauce/router reference)
  • Both tokens must be ERC20-approved to the NFPM for minting positions
  • Prefer V3 over V2 for major pairs on BSC for better capital efficiency

Its names in a program

On Ethereum, PancakeswapV3 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.

PancakeSwapV3FactoryABI

import PancakeSwapV3FactoryABI from "./protocols/pancakeswap-v3/PancakeSwapV3FactoryABI.json"; Speaks for: factory.
  • getPool(address tokenA, address tokenB, uint24 fee) view returns (address pool): the address is a PancakeswapV3.Pool

PancakeSwapV3NFPMABI

import PancakeSwapV3NFPMABI from "./protocols/pancakeswap-v3/PancakeSwapV3NFPMABI.json"; Speaks for: nonfungiblePositionManager.
  • mint((address token0, address token1, uint24 fee, int24 tickLower, int24 tickUpper, uint256 amount0Desired, uint256 amount1Desired, uint256 amount0Min, uint256 amount1Min, address recipient, uint256 deadline) params) payable returns (uint256 tokenId, uint128 liquidity, uint256 amount0, uint256 amount1)

PancakeSwapV3PoolABI

import PancakeSwapV3PoolABI from "./protocols/pancakeswap-v3/PancakeSwapV3PoolABI.json";
  • slot0() view returns (uint160 sqrtPriceX96, int24 tick, uint16 observationIndex, uint16 observationCardinality, uint16 observationCardinalityNext, uint32 feeProtocol, bool unlocked)
  • liquidity() view returns (uint128)
  • fee() view returns (uint24)
  • tickSpacing() view returns (int24)
  • token0() view returns (address): the address is a token
  • token1() view returns (address): the address is a token

PancakeSwapV3SmartRouterABI

import PancakeSwapV3SmartRouterABI from "./protocols/pancakeswap-v3/PancakeSwapV3SmartRouterABI.json"; Speaks for: smartRouter.
  • exactInputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountIn, uint256 amountOutMinimum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountOut)
  • exactOutputSingle((address tokenIn, address tokenOut, uint24 fee, address recipient, uint256 amountOut, uint256 amountInMaximum, uint160 sqrtPriceLimitX96) params) payable returns (uint256 amountIn)

Next steps