Skip to main content

IRouter

Table of contents​

Constructors​

Properties​

Methods​

Constructors​

constructor​

• new IRouter(at): IRouter

Wraps a smart contract exposing standard token FFI.

Parameters​

NameTypeDescription
atAddressAddress of the smart contract.

Returns​

IRouter

Defined in​

assembly/interfaces/IRouter.ts:22

Properties​

_origin​

• _origin: Address

Defined in​

assembly/interfaces/IRouter.ts:15

Methods​

addLiquidity​

▸ addLiquidity(liquidityParameters, masToSend): AddLiquidity

Add liquidity while performing safety checks This function is compliant with fee on transfer tokens

Parameters​

NameTypeDescription
liquidityParametersLiquidityParametersThe liquidity parameters
masToSendu64The amount of MAS to send for storage

Returns​

AddLiquidity

  • The amount of tokens minted and the ids of the deposits

Defined in​

assembly/interfaces/IRouter.ts:82


addLiquidityMAS​

▸ addLiquidityMAS(liquidityParameters, amountTotal, masToSend): AddLiquidity

Add liquidity with MAS while performing safety checks This function is compliant with fee on transfer tokens

Parameters​

NameTypeDescription
liquidityParametersLiquidityParametersThe liquidity parameters
amountTotalu256The amount of MAS to deposit + the amount of MAS to send for storage
masToSendu64The amount of MAS to send for storage

Returns​

AddLiquidity

  • The amount of tokens minted and the ids of the deposits

Defined in​

assembly/interfaces/IRouter.ts:103


createLBPair​

▸ createLBPair(tokenX, tokenY, activeId, binStep, masToSend): Address

Create a liquidity bin LBPair for _tokenX and _tokenY using the factory

Parameters​

NameTypeDescription
tokenXIERC20The address of the first token
tokenYIERC20The address of the second token
activeIdu32The active id of the pair
binStepu32The bin step in basis point, used to calculate log(1 + binStep)
masToSendu64The amount of MAS to send for storage

Returns​

Address

  • The address of the newly created LBPair

Defined in​

assembly/interfaces/IRouter.ts:58


getSwapIn​

▸ getSwapIn(_pair, _amountOut, _swapForY): GetSwapInReturn

Parameters​

NameType
_pairIPair
_amountOutu256
_swapForYbool

Returns​

GetSwapInReturn

Defined in​

assembly/interfaces/IRouter.ts:543


getSwapOut​

▸ getSwapOut(_pair, _amountIn, _swapForY): GetSwapOutReturn

Parameters​

NameType
_pairIPair
_amountInu256
_swapForYbool

Returns​

GetSwapOutReturn

Defined in​

assembly/interfaces/IRouter.ts:552


init​

▸ init(wmas, factory, v0factory, legacyfactory): void

Calls the constructor.

Parameters​

NameTypeDescription
wmasAddressThe address of WMAS
factoryAddressThe address of the factory
v0factoryAddressThe address of the V0 factory
legacyfactoryAddressThe address of the legagcy factory

Returns​

void

Defined in​

assembly/interfaces/IRouter.ts:34


removeLiquidity​

▸ removeLiquidity(tokenX, tokenY, binStep, amountXMin, amountYMin, ids, amounts, to, deadline, masToSend): Amounts

Remove liquidity while performing safety checks This function is compliant with fee on transfer tokens

Parameters​

NameTypeDescription
tokenXAddressThe address of token X
tokenYAddressThe address of token Y
binStepu32The bin step of the LBPair
amountXMinu256The min amount to receive of token X
amountYMinu256The min amount to receive of token Y
idsu64[]The list of ids to burn
amountsu256[]The list of amounts to burn of each id in ids
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of MAS to send for storage

Returns​

Amounts

  • The amount of tokens received

Defined in​

assembly/interfaces/IRouter.ts:134


removeLiquidityMAS​

▸ removeLiquidityMAS(token, binStep, amountTokenMin, amountMasMin, ids, amounts, to, deadline, masToSend): Amounts

Remove liquidity with MAS while performing safety checks This function is compliant with fee on transfer tokens

Parameters​

NameTypeDescription
tokenAddressThe address of token
binStepu32The bin step of the LBPair
amountTokenMinu256The min amount to receive of token
amountMasMinu256The min amount to receive of MAS
idsu64[]The list of ids to burn
amountsu256[]The list of amounts to burn of each id in ids
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of MAS to send for storage

Returns​

Amounts

  • The amount of tokens received

Defined in​

assembly/interfaces/IRouter.ts:177


swapExactMASForTokens​

▸ swapExactMASForTokens(amountIn, amountOutMin, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps exact MAS for tokens while performing safety checks

Parameters​

NameTypeDescription
amountInu256The amount of MAS to send for swap and storage
amountOutMinu256The min amount of token to receive
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:286


swapExactMASForTokensSupportingFeeOnTransferTokens​

▸ swapExactMASForTokensSupportingFeeOnTransferTokens(amountIn, amountOutMin, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps exact MAS for tokens while performing safety checks supporting for fee on transfer tokens

Parameters​

NameTypeDescription
amountInu256The amount of MAS to send for swap and storage
amountOutMinu256The min amount of token to receive
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:516


swapExactTokensForMAS​

▸ swapExactTokensForMAS(amountIn, amountOutMinMAS, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps exact tokens for MAS while performing safety checks

Parameters​

NameTypeDescription
amountInu256The amount of tokens to send
amountOutMinMASu256The min amount of MAS to receive
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:251


swapExactTokensForMASSupportingFeeOnTransferTokens​

▸ swapExactTokensForMASSupportingFeeOnTransferTokens(amountIn, amountOutMinMAS, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps exact tokens for MAS while performing safety checks supporting for fee on transfer tokens

Parameters​

NameTypeDescription
amountInu256The amount of token to send
amountOutMinMASu256The min amount of MAS to receive
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:476


swapExactTokensForTokens​

▸ swapExactTokensForTokens(amountIn, amountOutMin, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps exact tokens for tokens while performing safety checks

Parameters​

NameTypeDescription
amountInu256The amount of tokens to send
amountOutMinu256The min amount of tokens to receive
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:216


swapExactTokensForTokensSupportingFeeOnTransferTokens​

▸ swapExactTokensForTokensSupportingFeeOnTransferTokens(amountIn, amountOutMin, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps exact tokens for tokens while performing safety checks supporting for fee on transfer tokens

Parameters​

NameTypeDescription
amountInu256The amount of token to send
amountOutMinu256The min amount of token to receive
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:436


swapMASForExactTokens​

▸ swapMASForExactTokens(amountOut, amountInMax, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps MAS for exact tokens while performing safety checks

Parameters​

NameTypeDescription
amountOutu256The amount of token to receive
amountInMaxu256The max amount of Mas to send
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:396


swapTokensForExactMAS​

▸ swapTokensForExactMAS(amountOut, amountInMax, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps tokens for exact MAS while performing safety checks

Parameters​

NameTypeDescription
amountOutu256The amount of MAS to receive
amountInMaxu256The max amount of token to send
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:361


swapTokensForExactTokens​

▸ swapTokensForExactTokens(amountOut, amountInMax, pairBinSteps, isLegacyPools, tokenPath, to, deadline, masToSend): u256

Swaps tokens for exact tokens while performing safety checks

Parameters​

NameTypeDescription
amountOutu256The amount of token to receive
amountInMaxu256The max amount of token to send
pairBinStepsu64[]The bin step of the pairs
isLegacyPoolsbool[]If the pairs are legacy pairs
tokenPathIERC20[]The swap path using the binSteps following _pairBinSteps
toAddressThe address of the recipient
deadlineu64The deadline of the tx
masToSendu64The amount of Massa to send for storage

Returns​

u256

  • The output amount of the swap

Defined in​

assembly/interfaces/IRouter.ts:326