IButtonswapRouter
Inherits: IETHButtonswapRouter
Functions
getPair
Returns the Pair contract for given tokens. Returns the zero address if no pair exists
function getPair(address tokenA, address tokenB) external view returns (address pair);
Parameters
Name | Type | Description |
---|---|---|
tokenA | address | First token address |
tokenB | address | Second token address |
Returns
Name | Type | Description |
---|---|---|
pair | address | The pair address |
isCreationRestricted
Returns the factory state of isCreationRestricted
function isCreationRestricted() external view returns (bool _isCreationRestricted);
Returns
Name | Type | Description |
---|---|---|
_isCreationRestricted | bool | The isCreationRestricted state of the factory. |
quote
Given some amount of an asset and pair pools, returns an equivalent amount of the other asset
function quote(uint256 amountA, uint256 poolA, uint256 poolB) external pure returns (uint256 amountB);
Parameters
Name | Type | Description |
---|---|---|
amountA | uint256 | The amount of token A |
poolA | uint256 | The balance of token A in the pool |
poolB | uint256 | The balance of token B in the pool |
Returns
Name | Type | Description |
---|---|---|
amountB | uint256 | The amount of token B |
getAmountOut
Given an input amount of an asset and pair pools, returns the maximum output amount of the other asset Factors in the fee on the input amount.
function getAmountOut(uint256 amountIn, uint256 poolIn, uint256 poolOut) external pure returns (uint256 amountOut);
Parameters
Name | Type | Description |
---|---|---|
amountIn | uint256 | The input amount of the asset |
poolIn | uint256 | The balance of the input asset in the pool |
poolOut | uint256 | The balance of the output asset in the pool |
Returns
Name | Type | Description |
---|---|---|
amountOut | uint256 | The output amount of the other asset |
getAmountIn
Given an output amount of an asset and pair pools, returns a required input amount of the other asset
function getAmountIn(uint256 amountOut, uint256 poolIn, uint256 poolOut) external pure returns (uint256 amountIn);
Parameters
Name | Type | Description |
---|---|---|
amountOut | uint256 | The output amount of the asset |
poolIn | uint256 | The balance of the input asset in the pool |
poolOut | uint256 | The balance of the output asset in the pool |
Returns
Name | Type | Description |
---|---|---|
amountIn | uint256 | The required input amount of the other asset |
getAmountsOut
Given an ordered array of tokens and an input amount of the first asset, performs chained getAmountOut calculations to calculate the output amount of the final asset
function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts);
Parameters
Name | Type | Description |
---|---|---|
amountIn | uint256 | The input amount of the first asset |
path | address[] | An array of token addresses [tokenA, tokenB, tokenC, ...] representing the path the input token takes to get to the output token |
Returns
Name | Type | Description |
---|---|---|
amounts | uint256[] | The output amounts of each asset in the path |
getAmountsIn
Given an ordered array of tokens and an output amount of the final asset, performs chained getAmountIn calculations to calculate the input amount of the first asset
function getAmountsIn(uint256 amountOut, address[] calldata path) external view returns (uint256[] memory amounts);
Parameters
Name | Type | Description |
---|---|---|
amountOut | uint256 | The output amount of the final asset |
path | address[] | An array of token addresses [tokenA, tokenB, tokenC, ...] representing the path the input token takes to get to the output token |
Returns
Name | Type | Description |
---|---|---|
amounts | uint256[] | The input amounts of each asset in the path |
getMintSwappedAmounts
Returns how much of the much of mintAmountA will be swapped for tokenB and for how much during a mintWithReservoir operation.
function getMintSwappedAmounts(address tokenA, address tokenB, uint256 mintAmountA)
external
view
returns (uint256 tokenAToSwap, uint256 swappedReservoirAmountB);
Parameters
Name | Type | Description |
---|---|---|
tokenA | address | First token address |
tokenB | address | Second token address |
mintAmountA | uint256 | The amount of tokenA to be minted |
Returns
Name | Type | Description |
---|---|---|
tokenAToSwap | uint256 | The amount of tokenA to be exchanged for tokenB from the reservoir |
swappedReservoirAmountB | uint256 | The amount of tokenB returned from the reservoir |
getBurnSwappedAmounts
Returns how much of tokenA will be withdrawn from the pair and how much of it came from the reservoir during a burnFromReservoir operation.
function getBurnSwappedAmounts(address tokenA, address tokenB, uint256 liquidity)
external
view
returns (uint256 tokenOutA, uint256 swappedReservoirAmountA);
Parameters
Name | Type | Description |
---|---|---|
tokenA | address | First token address |
tokenB | address | Second token address |
liquidity | uint256 | The amount of liquidity to be burned |
Returns
Name | Type | Description |
---|---|---|
tokenOutA | uint256 | The amount of tokenA to be withdrawn from the pair |
swappedReservoirAmountA | uint256 | The amount of tokenA returned from the reservoir |