BuniCornRouter02
Code
Address
BuniCornRouter02
is deployed at 0x689E37aFb4236A5cF808cA05a8D1c564200fA0E4 on the Binance SmartChain mainnet.
Read-Only Functions
factory
Returns the factory address.
quote
Given some asset amount and reserves, returns an amount of the other asset representing equivalent value.
getAmountsOut
First calls verifyPoolsPathSwap to verify the validity of the poolsPath
and path
variables.
Then, given an input asset amount and an array of token and corresponding pool addresses, calculates all subsequent maximum output token amounts by calling getTradeInfo for each pair of token addresses in the path in turn, and using these to call getAmountOut.
getAmountsIn
First calls verifyPoolsPathSwap to verify the validity of the poolsPath
and path
variables.
Then, given an output asset amount and an array of token addresses, calculates all preceding minimum input token amounts by calling getTradeInfo for each pair of token addresses in the path in turn, and using these to call getAmountIn.
State-Changing Functions
addLiquidity
Adds liquidity to an existing stable pool.
pool
should already be an existing pool of the token pair oftokenA
andtokenB
. Otherwise, the transaction will revert.msg.sender
should have already given the router an allowance of at leastamountADesired
/amountBDesired
ontokenA
/tokenB
.Always adds assets at the ideal ratio, according to the price when the transaction is executed.
Name | Type | |
tokenA |
| The contract address of the desired token. |
tokenB |
| The contract address of the desired token. |
pool |
| The contract address of the desired pool to add liquidity to. |
amountADesired |
| The amount of tokenA to add as liquidity if the B/A price is <= amountBDesired/amountADesired (A depreciates). |
amountBDesired |
| The amount of tokenB to add as liquidity if the A/B price is <= amountADesired/amountBDesired (B depreciates). |
amountAMin |
| Bounds the extent to which the B/A price can go up before the transaction reverts. Must be <= amountADesired. |
amountBMin |
| Bounds the extent to which the A/B price can go up before the transaction reverts. Must be <= amountBDesired. |
vReserveRatioBounds |
| Bounds the extent to which the virtual B/A price can move before the transaction reverts. |
to |
| Recipient of the liquidity tokens. |
deadline |
| Unix timestamp after which the transaction will revert. |
amountA |
| The amount of tokenA sent to the pool. |
amountB |
| The amount of tokenB sent to the pool. |
liquidity |
| The amount of liquidity tokens minted. |
removeLiquidity
Removes liquidity from a specified stable pool.
msg.sender
should have already given the router an allowance of at least liquidity on the pool.
Name | Type | |
tokenA |
| The contract address of the desired token. |
tokenB |
| The contract address of the desired token. |
pool |
| The contract address of the desired pool to remove liquidity from. |
liquidity |
| The amount of liquidity tokens to remove. |
amountAMin |
| The minimum amount of tokenA that must be received for the transaction not to revert. |
amountBMin |
| The minimum amount of tokenB that must be received for the transaction not to revert. |
to |
| Recipient of the underlying assets. |
deadline |
| Unix timestamp after which the transaction will revert. |
amountA |
| The amount of tokenA received. |
amountB |
| The amount of tokenB received. |
removeLiquidityWithPermit
Removes liquidity from an ERC-20⇄ERC-20 pool without pre-approval, thanks to permit.
Name | Type | |
tokenA |
| The contract address of the desired token. |
tokenB |
| The contract address of the desired token. |
pool |
| The contract address of the desired pool to remove liquidity from. |
liquidity |
| The amount of liquidity tokens to remove. |
amountAMin |
| The minimum amount of tokenA that must be received for the transaction not to revert. |
amountBMin |
| The minimum amount of tokenB that must be received for the transaction not to revert. |
to |
| Recipient of the underlying assets. |
deadline |
| Unix timestamp after which the transaction will revert. |
approveMax |
| Whether or not the approval amount in the signature is for liquidity or |
v |
| The v component of the permit signature. |
r |
| The r component of the permit signature. |
s |
| The s component of the permit signature. |
amountA |
| The amount of tokenA received. |
amountB |
| The amount of tokenB received. |
swapExactTokensForTokens
Swaps an exact amount of input tokens for as many output tokens as possible. The token and pool routes are specified by the poolsPath
and path
variables respectively.
The first element of path
is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). The nth element of poolsPath
is the first pool to be used for the nth and (n+1)th elements of path
. It therefore is a requirement for poolsPath
to be a size smaller than path
, ie. poolsPath.length = path.length - 1
.
msg.sender
should have already given the router an allowance of at leastamountIn
on the input token.
Name | Type | |
amountIn |
| The amount of input tokens to send. |
amountOutMin |
| The minimum amount of output tokens that must be received for the transaction not to revert. |
poolsPath |
| An array of pool addresses. |
path |
| An array of token addresses. |
to |
| Recipient of the output tokens. |
deadline |
| Unix timestamp after which the transaction will revert. |
amounts |
| The input token amount and all subsequent output token amounts. |
swapTokensForExactTokens
Receive an exact amount of output tokens for as few input tokens as possible. The token and pool routes are specified by the poolsPath
and path
variables respectively.
The first element of path
is the input token, the last is the output token, and any intermediate elements represent intermediate pairs to trade through (if, for example, a direct pair does not exist). The nth element of poolsPath
is the first pool to be used for the nth and (n+1)th elements of path
. It therefore is a requirement for poolsPath
to be a size smaller than path
, ie. poolsPath.length = path.length - 1
.
msg.sender
should have already given the router an allowance of at leastamountInMax
on the input token.
Name | Type | |
amountOut |
| The amount of output tokens to receive. |
amountInMax |
| The maximum amount of input tokens that can be required before the transaction reverts. |
poolsPath |
| An array of pool addresses. |
path |
| An array of token addresses. |
to |
| Recipient of the output tokens. |
deadline |
| Unix timestamp after which the transaction will revert. |
amounts |
| The input token amount and all subsequent output token amounts. |
Interface
Last updated