Math Functions
divRem
Performs division and returns the quotient and remainder. Parametersnumber
required
The numerator.
number
required
The denominator.
[number, number]
An array containing the quotient and remainder.
mulDiv
Multiplies two numbers and then divides by a denominator, with rounding. Parametersnumber
required
The first number.
number
required
The second number.
number
required
The denominator.
'up' | 'down'
required
The rounding direction.
number
The result of the calculation.
mulShr
Multiplies two numbers and then right-shifts the result. Parametersnumber
required
The first number.
number
required
The second number.
number
required
The number of bits to shift.
'up' | 'down'
required
The rounding direction.
number
The result of the calculation.
shlDiv
Left-shifts a number and then divides by another number. Parametersnumber
required
The number to shift.
number
required
The divisor.
number
required
The number of bits to shift.
'up' | 'down'
required
The rounding direction.
number
The result of the calculation.
Price Functions
getPriceFromId
Calculates the price from a bin ID. Parametersnumber
required
The bin step of the liquidity pool.
number
required
The ID of the bin.
number
required
The decimals of the base token.
number
required
The decimals of the quote token.
number
The price.
getIdFromPrice
Calculates the bin ID from a price. Parametersnumber
required
The price.
number
required
The bin step of the liquidity pool.
number
required
The decimals of the base token.
number
required
The decimals of the quote token.
number
The bin ID.
Type Conversion Functions
pairAccountToPair
Converts aPairAccount object to a Pair object.
Parameters
PairAccount
required
The
PairAccount object.Pair
The
Pair object.