Skip to main content

IPair

Table of contents

Constructors

Properties

Methods

Constructors

constructor

new IPair(at): IPair

Wraps a smart contract exposing standard token FFI.

Parameters

NameTypeDescription
atAddressAddress of the smart contract.

Returns

IPair

Defined in

assembly/interfaces/IPair.ts:30

Properties

_origin

_origin: Address

Defined in

assembly/interfaces/IPair.ts:23

Methods

balanceOf

balanceOf(_account, _id): u256

Parameters

NameType
_accountAddress
_idu64

Returns

u256

Defined in

assembly/interfaces/IPair.ts:244


balanceOfBatch

balanceOfBatch(_accounts, _ids): u256[]

Parameters

NameType
_accountsAddress[]
_idsu64[]

Returns

u256[]

Defined in

assembly/interfaces/IPair.ts:254


burn

burn(_ids, _amounts, _to, masToSend): Amounts

Burn LB tokens for each bins where the user removes liquidity. This function will not transfer the LBToken from the caller, it is expected that the tokens have already been transferred to this contract through another contract. That is why this function shouldn't be called directly, but through one of the remove liquidity functions of the router that will also perform safety checks. The lengths of the arrays must be the same.

Parameters

NameTypeDescription
_idsu64[]The ids of the bins where the liquidity will be removed. It will burn LB tokens for each of these bins.
_amountsu256[]The amount of LB tokens to burn for each bin.
_toAddressThe address that will receive the tokens.
masToSendu64The amount of Massa to send for storage

Returns

Amounts

  • The amount of token X and token Y that the user will receive.

Defined in

assembly/interfaces/IPair.ts:160


collectFees

collectFees(account, ids, masToSend): Amounts

Collect the fees accumulated by a user.

Parameters

NameTypeDescription
accountAddress-
idsu64[]-
masToSendu64The amount of Massa to send for storage

Returns

Amounts

amountX The amount of token X collected and sent to _account

amountY The amount of token Y collected and sent to _account

Defined in

assembly/interfaces/IPair.ts:342


feeParameters

feeParameters(): FeeParameters

Get the fees parameters for this pair

Returns

FeeParameters

Defined in

assembly/interfaces/IPair.ts:72


findFirstNonEmptyBinId

findFirstNonEmptyBinId(id, sentTokenY): Result<u32>

Parameters

NameType
idu32
sentTokenYbool

Returns

Result<u32>

Defined in

assembly/interfaces/IPair.ts:201


flashLoan

flashLoan(token, amount, masToSend): void

Execute a flash loan. The caller must implement the IFlashLoanCallback interface and have the flashLoanCallback function. The flashLoanCallback function will be called by the pair contract to execute the logic of the flash loan. The caller must return true if the flash loan was successful, and false otherwise. The caller is expected to transfer the amount + fee of the token to this contract.

Parameters

NameTypeDescription
tokenIERC20The token to flash loan
amountu256The amount of tokens to flash loan
masToSendu64The amount of Massa to send for storage

Returns

void

Defined in

assembly/interfaces/IPair.ts:178


forceDecay

forceDecay(): void

Returns

void

Defined in

assembly/interfaces/IPair.ts:225


getBin

getBin(_id): Bin

Get the bin information for a given id

Parameters

NameTypeDescription
_idu32The id of the bin

Returns

Bin

Defined in

assembly/interfaces/IPair.ts:83


getFactory

getFactory(): Address

Returns

Address

Defined in

assembly/interfaces/IPair.ts:216


getOracleParameters

getOracleParameters(): OracleParameters

Returns

OracleParameters

Defined in

assembly/interfaces/IPair.ts:348


getOracleSampleFrom

getOracleSampleFrom(timeDelta): OracleSampleReturn

Parameters

NameType
timeDeltau64

Returns

OracleSampleReturn

Defined in

assembly/interfaces/IPair.ts:353


getPairInformation

getPairInformation(): PairInformation

Returns

PairInformation

Defined in

assembly/interfaces/IPair.ts:191


getTokenX

getTokenX(): IERC20

Returns

IERC20

Defined in

assembly/interfaces/IPair.ts:183


getTokenY

getTokenY(): IERC20

Returns

IERC20

Defined in

assembly/interfaces/IPair.ts:187


getUserBins

getUserBins(account): u32[]

Parameters

NameType
accountAddress

Returns

u32[]

Defined in

assembly/interfaces/IPair.ts:196


increaseOracleLength

increaseOracleLength(newSize, masToSend): void

Increases the length of the oracle to the given _newLength by adding empty samples to the end of the oracle. The samples are however initialized to reduce the gas cost of the updates during a swap.

Parameters

NameTypeDescription
newSizeu64-
masToSendu64The amount of Massa to send for storage

Returns

void

Defined in

assembly/interfaces/IPair.ts:370


init

init(factory, tokenX, tokenY, activeId, preset, masToSend): void

Calls the constructor

Parameters

NameType
factoryAddress
tokenXAddress
tokenYAddress
activeIdu32
presetPreset
masToSendu64

Returns

void

Defined in

assembly/interfaces/IPair.ts:39


isApprovedForAll

isApprovedForAll(_owner, _spender): bool

Parameters

NameType
_ownerAddress
_spenderAddress

Returns

bool

Defined in

assembly/interfaces/IPair.ts:261


mint

mint(_ids, _distributionX, _distributionY, _to, masToSend): MintReturn

Mint new LB tokens for each bins where the user adds liquidity. This function will not transfer the tokens from the caller, it is expected that the tokens have already been transferred to this contract through another contract. That is why this function shouldn't be called directly, but through one of the add liquidity functions of the router that will also perform safety checks. Any excess amount of token will be sent to the to address. The lengths of the arrays must be the same.

Parameters

NameTypeDescription
_idsu64[]The ids of the bins where the liquidity will be added. It will mint LB tokens for each of these bins.
_distributionXu256[]The percentage of token X to add to each bin. The sum of all the values must not exceed 100%, that is 1e9.
_distributionYu256[]The percentage of token Y to add to each bin. The sum of all the values must not exceed 100%, that is 1e9.
_toAddressThe address that will receive the LB tokens and the excess amount of tokens.
masToSendu64The amount of Massa to send for storage.

Returns

MintReturn

  • The amount of token X and token Y that the user will receive and the amounts of LB tokens minted for each bin.

Defined in

assembly/interfaces/IPair.ts:125


name

name(): string

Returns

string

Defined in

assembly/interfaces/IPair.ts:229


pendingFees

pendingFees(account, ids): Amounts

Parameters

NameType
accountAddress
idsu64[]

Returns

Amounts

Defined in

assembly/interfaces/IPair.ts:328


safeBatchTransferFrom

safeBatchTransferFrom(_from, _to, _ids, _amounts, masToSend): void

Batch transfers _amount tokens of type _id from _from to _to

Parameters

NameTypeDescription
_fromAddressThe address of the owner of the tokens
_toAddressThe address of the recipient
_idsu64[]The list of token ids
_amountsu256[]The list of amounts to send
masToSendu64The amount of Massa to send for storage

Returns

void

Defined in

assembly/interfaces/IPair.ts:317


safeTransferFrom

safeTransferFrom(_from, _to, _id, amount, masToSend): void

Transfers _amount token of type _id from _from to _to

Parameters

NameTypeDescription
_fromAddressThe address of the owner of the token
_toAddressThe address of the recipient
_idu64The token id
amountu256-
masToSendu64The amount of Massa to send for storage

Returns

void

Defined in

assembly/interfaces/IPair.ts:294


setApprovalForAll

setApprovalForAll(_approved, _sender, masToSend): void

Grants or revokes permission to spender to transfer the caller's tokens, according to approved

Parameters

NameTypeDescription
_approvedboolThe boolean value to grant or revoke permission
_senderAddress-
masToSendu64The amount of Massa to send for storage

Returns

void

Defined in

assembly/interfaces/IPair.ts:277


setFeesParameters

setFeesParameters(fp): void

Parameters

NameType
fpFeeParameters

Returns

void

Defined in

assembly/interfaces/IPair.ts:220


swap

swap(swapForY, to, masToSend): u256

Swap tokens iterating over the bins until the entire amount is swapped. Will swap token X for token Y if _swapForY is true, and token Y for token X if _swapForY is false. This function will not transfer the tokens from the caller, it is expected that the tokens have already been transferred to this contract through another contract. That is why this function shouldn't be called directly, but through one of the swap functions of the router that will also perform safety checks.

Parameters

NameTypeDescription
swapForYboolWhether you've swapping token X for token Y (true) or token Y for token X (false)
toAddressThe address to send the tokens to
masToSendu64The amount of Massa to send for storage

Returns

u256

Defined in

assembly/interfaces/IPair.ts:101


symbol

symbol(): string

Returns

string

Defined in

assembly/interfaces/IPair.ts:234


totalSupply

totalSupply(_id): u256

Parameters

NameType
_idu64

Returns

u256

Defined in

assembly/interfaces/IPair.ts:239