Router v2
PancakeSwap is based on Uniswap v2. Read the Uniswap v2 documentation. For more in-depth information on the core contract logic, read the Uniswap v2 Core whitepaper.
Contract info
Contract name: PancakeRouter
View PancakeRouter.sol on GitHub.
BSC
0x10ED43C718714eb63d5aA57B78B54704E256024E
ETH
0xEfF92A263d31888d860bD50809A8D171709b7b1c
zkEVM
0x8cFe327CEc66d1C090Dd72bd0FF11d690C33a2Eb
zkSync
0x5aEaF2883FBf30f3D62471154eDa3C0c1b05942d
Arbitrum
0x8cFe327CEc66d1C090Dd72bd0FF11d690C33a2Eb
Linea
0x8cFe327CEc66d1C090Dd72bd0FF11d690C33a2Eb
Base
0x8cFe327CEc66d1C090Dd72bd0FF11d690C33a2Eb
opBNB
0x8cFe327CEc66d1C090Dd72bd0FF11d690C33a2Eb
Read functions
WETH
function WETH() external pure returns (address);
Returns the canonical address for Binance: WBNB token (WETH being a vestige from Ethereum network origins).
factory
function factory() external pure returns (address);
Returns the canonical address for PancakeFactory.
For explanations of the following, view the Uniswap v2 Internal Functions documentation.
getAmountOut
function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) internal pure returns (uint amountOut);
getAmountIn
function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) internal pure returns (uint amountIn);
getAmountsOut
function getAmountsOut(uint amountIn, address[] memory path) internal view returns (uint[] memory amounts);
getAmountsIn
function getAmountsIn(uint amountOut, address[] memory path) internal view returns (uint[] memory amounts);
quote
function quote(uint amountA, uint reserveA, uint reserveB) internal pure returns (uint amountB);
Write functions
addLiquidity
Adds liquidity to a BEP20⇄BEP20 pool.
tokenA
address
The contract address of one token from your liquidity pair.
tokenB
address
The contract address of the other token from your liquidity pair.
amountADesired
uint
The amount of tokenA you'd like to provide as liquidity.
amountBDesired
uint
The amount of tokenA you'd like to provide as liquidity.
amountAMin
uint
The minimum amount of tokenA to provide (slippage impact).
amountBMin
uint
The minimum amount of tokenB to provide (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
addLiquidityETH
Adds liquidity to a BEP20⇄WBNB pool.
addLiquidityETH
uint
The payable amount in BNB.
token
address
The contract address of the token to add liquidity.
amountTokenDesired
uint
The amount of the token you'd like to provide as liquidity.
amountTokenMin
uint
The minimum amount of the token to provide (slippage impact).
amountETHMin
uint
The minimum amount of BNB to provide (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
removeLiquidity
Removes liquidity from a BEP20⇄BEP20 pool.
tokenA
address
The contract address of one token from your liquidity pair.
tokenB
address
The contract address of the other token from your liquidity pair.
liquidity
uint
The amount of LP Tokens to remove.
amountAMin
uint
The minimum amount of tokenA to remove (slippage impact).
amountBMin
uint
The minimum amount of tokenB to remove (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
removeLiquidityETH
Removes liquidity from a BEP20⇄WBNB pool.
token
address
The contract address of the token to remove liquidity.
liquidity
uint
The amount of LP Tokens to remove.
amountTokenMin
uint
The minimum amount of the token to remove (slippage impact).
amountETHMin
uint
The minimum amount of BNB to remove (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
removeLiquidityETHSupportingFeeOnTransferTokens
Removes liquidity from a BEP20⇄WBNB for tokens that take a fee on transfer.
token
address
The contract address of the token to remove liquidity.
liquidity
uint
The amount of LP Tokens to remove.
amountTokenMin
uint
The minimum amount of the token to remove (slippage impact).
amountETHMin
uint
The minimum amount of BNB to remove (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
removeLiquidityETHWithPermit
Removes liquidity from a BEP20⇄WBNB and receives BNB, without pre-approval, via permit.
token
address
The contract address of the token to remove liquidity.
liquidity
uint
The amount of LP Tokens to remove.
amountTokenMin
uint
The minimum amount of the token to remove (slippage impact).
amountETHMin
uint
The minimum amount of BNB to remove (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1)
.
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.
removeLiquidityETHWithPermitSupportingFeeOnTransferTokens
Removes liquidity from a BEP20⇄WBNB and receives BNB via permit for tokens that take a fee on transfer.
token
address
The contract address of the token to remove liquidity.
liquidity
uint
The amount of LP Tokens to remove.
amountTokenMin
uint
The minimum amount of the token to remove (slippage impact).
amountETHMin
uint
The minimum amount of BNB to remove (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1)
.
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.
removeLiquidityWithPermit
Removes liquidity from a BEP20⇄BEP20, without pre-approval, via permit.
tokenA
address
The contract address of one token from your liquidity pair.
tokenB
address
The contract address of the other token from your liquidity pair.
liquidity
uint
The amount of LP Tokens to remove.
amountTokenMin
uint
The minimum amount of the token to remove (slippage impact).
amountETHMin
uint
The minimum amount of BNB to remove (slippage impact).
to
address
Address of LP Token recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
approveMax
bool
Whether or not the approval amount in the signature is for liquidity or uint(-1)
.
v
uint8
The v component of the permit signature.
r
bytes32
The r component of the permit signature.
s
bytes32
The s component of the permit signature.
swapETHForExactTokens
Receive an exact amount of output tokens for as little BNB as possible.
swapETHForExactTokens
uint
Payable BNB amount.
amountOut
uint
The amount tokens to receive.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapExactETHForTokens
Receive as many output tokens as possible for an exact amount of BNB.
swapExactETHForTokens
uint
Payable BNB amount.
amountOutMin
uint
The minimum amount tokens to receive.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapExactETHForTokensSupportingFeeOnTransferTokens
Receive as many output tokens as possible for an exact amount of BNB. Supports tokens that take a fee on transfer.
swapExactETHForTokensSupportingFeeOnTransferTokens
uint
Payable BNB amount.
amountOutMin
uint
The minimum amount tokens to receive.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapExactTokensForETH
Receive as much BNB as possible for an exact amount of input tokens.
amountIn
uint
Payable amount of input tokens.
amountOutMin
uint
The minimum amount tokens to receive.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapExactTokensForETHSupportingFeeOnTransferTokens
Receive as much BNB as possible for an exact amount of tokens. Supports tokens that take a fee on transfer.
amountIn
uint
Payable amount of input tokens.
amountOutMin
uint
The minimum amount tokens to receive.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapExactTokensForTokens
Receive as many output tokens as possible for an exact amount of input tokens.
amountIn
uint
Payable amount of input tokens.
amountOutMin
uint
The minimum amount tokens to receive.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapExactTokensForTokensSupportingFeeOnTransferTokens
Receive as many output tokens as possible for an exact amount of input tokens. Supports tokens that take a fee on transfer.
amountIn
uint
Payable amount of input tokens.
amountOutMin
uint
The minimum amount tokens to receive.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapTokensForExactETH
Receive an exact amount of ETH for as few input tokens as possible.
amountOut
uint
Payable amount of input tokens.
amountInMax
uint
The minimum amount tokens to input.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
swapTokensForExactTokens
Receive an exact amount of output tokens for as few input tokens as possible.
amountOut
uint
Payable amount of input tokens.
amountInMax
uint
The maximum amount tokens to input.
path (address[])
address
An array of token addresses. path.length
must be >= 2. Pools for each consecutive pair of addresses must exist and have liquidity.
to
address
Address of recipient.
deadline
uint
Unix timestamp deadline by which the transaction must confirm.
Interface
Last updated