Skip to main content

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

NameTypeDescription
tokenAaddressFirst token address
tokenBaddressSecond token address

Returns

NameTypeDescription
pairaddressThe pair address

isCreationRestricted

Returns the factory state of isCreationRestricted

function isCreationRestricted() external view returns (bool _isCreationRestricted);

Returns

NameTypeDescription
_isCreationRestrictedboolThe 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

NameTypeDescription
amountAuint256The amount of token A
poolAuint256The balance of token A in the pool
poolBuint256The balance of token B in the pool

Returns

NameTypeDescription
amountBuint256The 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

NameTypeDescription
amountInuint256The input amount of the asset
poolInuint256The balance of the input asset in the pool
poolOutuint256The balance of the output asset in the pool

Returns

NameTypeDescription
amountOutuint256The 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

NameTypeDescription
amountOutuint256The output amount of the asset
poolInuint256The balance of the input asset in the pool
poolOutuint256The balance of the output asset in the pool

Returns

NameTypeDescription
amountInuint256The 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

NameTypeDescription
amountInuint256The input amount of the first asset
pathaddress[]An array of token addresses [tokenA, tokenB, tokenC, ...] representing the path the input token takes to get to the output token

Returns

NameTypeDescription
amountsuint256[]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

NameTypeDescription
amountOutuint256The output amount of the final asset
pathaddress[]An array of token addresses [tokenA, tokenB, tokenC, ...] representing the path the input token takes to get to the output token

Returns

NameTypeDescription
amountsuint256[]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

NameTypeDescription
tokenAaddressFirst token address
tokenBaddressSecond token address
mintAmountAuint256The amount of tokenA to be minted

Returns

NameTypeDescription
tokenAToSwapuint256The amount of tokenA to be exchanged for tokenB from the reservoir
swappedReservoirAmountBuint256The 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

NameTypeDescription
tokenAaddressFirst token address
tokenBaddressSecond token address
liquidityuint256The amount of liquidity to be burned

Returns

NameTypeDescription
tokenOutAuint256The amount of tokenA to be withdrawn from the pair
swappedReservoirAmountAuint256The amount of tokenA returned from the reservoir