IPair
Table of contents
Constructors
Properties
Methods
- balanceOf
- balanceOfBatch
- burn
- collectFees
- feeParameters
- findFirstNonEmptyBinId
- flashLoan
- forceDecay
- getBin
- getFactory
- getOracleParameters
- getOracleSampleFrom
- getPairInformation
- getTokenX
- getTokenY
- getUserBins
- increaseOracleLength
- init
- isApprovedForAll
- mint
- name
- pendingFees
- safeBatchTransferFrom
- safeTransferFrom
- setApprovalForAll
- setFeesParameters
- swap
- symbol
- totalSupply
Constructors
constructor
• new IPair(at
): IPair
Wraps a smart contract exposing standard token FFI.
Parameters
Name | Type | Description |
---|---|---|
at | Address | Address of the smart contract. |
Returns
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
Name | Type |
---|---|
_account | Address |
_id | u64 |
Returns
u256
Defined in
assembly/interfaces/IPair.ts:244
balanceOfBatch
▸ balanceOfBatch(_accounts
, _ids
): u256
[]
Parameters
Name | Type |
---|---|
_accounts | Address [] |
_ids | u64 [] |
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
Name | Type | Description |
---|---|---|
_ids | u64 [] | The ids of the bins where the liquidity will be removed. It will burn LB tokens for each of these bins. |
_amounts | u256 [] | The amount of LB tokens to burn for each bin. |
_to | Address | The address that will receive the tokens. |
masToSend | u64 | The 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
Name | Type | Description |
---|---|---|
account | Address | - |
ids | u64 [] | - |
masToSend | u64 | The 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
Defined in
assembly/interfaces/IPair.ts:72
findFirstNonEmptyBinId
▸ findFirstNonEmptyBinId(id
, sentTokenY
): Result
<u32
>
Parameters
Name | Type |
---|---|
id | u32 |
sentTokenY | bool |
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
Name | Type | Description |
---|---|---|
token | IERC20 | The token to flash loan |
amount | u256 | The amount of tokens to flash loan |
masToSend | u64 | The 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
Name | Type | Description |
---|---|---|
_id | u32 | The id of the bin |
Returns
Defined in
assembly/interfaces/IPair.ts:83
getFactory
▸ getFactory(): Address
Returns
Address
Defined in
assembly/interfaces/IPair.ts:216
getOracleParameters
▸ getOracleParameters(): OracleParameters
Returns
Defined in
assembly/interfaces/IPair.ts:348
getOracleSampleFrom
▸ getOracleSampleFrom(timeDelta
): OracleSampleReturn
Parameters
Name | Type |
---|---|
timeDelta | u64 |
Returns
OracleSampleReturn
Defined in
assembly/interfaces/IPair.ts:353
getPairInformation
▸ getPairInformation(): PairInformation
Returns
Defined in
assembly/interfaces/IPair.ts:191
getTokenX
▸ getTokenX(): IERC20
Returns
Defined in
assembly/interfaces/IPair.ts:183
getTokenY
▸ getTokenY(): IERC20
Returns
Defined in
assembly/interfaces/IPair.ts:187
getUserBins
▸ getUserBins(account
): u32
[]
Parameters
Name | Type |
---|---|
account | Address |
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
Name | Type | Description |
---|---|---|
newSize | u64 | - |
masToSend | u64 | The 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
Name | Type |
---|---|
factory | Address |
tokenX | Address |
tokenY | Address |
activeId | u32 |
preset | Preset |
masToSend | u64 |
Returns
void
Defined in
assembly/interfaces/IPair.ts:39
isApprovedForAll
▸ isApprovedForAll(_owner
, _spender
): bool
Parameters
Name | Type |
---|---|
_owner | Address |
_spender | Address |
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
Name | Type | Description |
---|---|---|
_ids | u64 [] | The ids of the bins where the liquidity will be added. It will mint LB tokens for each of these bins. |
_distributionX | u256 [] | The percentage of token X to add to each bin. The sum of all the values must not exceed 100%, that is 1e9. |
_distributionY | u256 [] | The percentage of token Y to add to each bin. The sum of all the values must not exceed 100%, that is 1e9. |
_to | Address | The address that will receive the LB tokens and the excess amount of tokens. |
masToSend | u64 | The 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
Name | Type |
---|---|
account | Address |
ids | u64 [] |
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
Name | Type | Description |
---|---|---|
_from | Address | The address of the owner of the tokens |
_to | Address | The address of the recipient |
_ids | u64 [] | The list of token ids |
_amounts | u256 [] | The list of amounts to send |
masToSend | u64 | The 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
Name | Type | Description |
---|---|---|
_from | Address | The address of the owner of the token |
_to | Address | The address of the recipient |
_id | u64 | The token id |
amount | u256 | - |
masToSend | u64 | The 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
Name | Type | Description |
---|---|---|
_approved | bool | The boolean value to grant or revoke permission |
_sender | Address | - |
masToSend | u64 | The amount of Massa to send for storage |
Returns
void
Defined in
assembly/interfaces/IPair.ts:277
setFeesParameters
▸ setFeesParameters(fp
): void
Parameters
Name | Type |
---|---|
fp | FeeParameters |
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
Name | Type | Description |
---|---|---|
swapForY | bool | Whether you've swapping token X for token Y (true) or token Y for token X (false) |
to | Address | The address to send the tokens to |
masToSend | u64 | The 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
Name | Type |
---|---|
_id | u64 |
Returns
u256