Fraction
The base class which all subsequent fraction classes extend. Not meant to be used directly.
#
Properties#
numerator#
denominator#
quotientPerforms floor division.
#
Methods#
invert#
add#
subtract#
multiply#
divide#
toSignificantFormats a fraction to the specified number of significant digits.
- For format options, see toFormat.
#
toFixedFormats a fraction to the specified number of decimal places.
- For format options, see toFormat.
#
PercentResponsible for formatting percentages (10% instead of 0.1).
#
Example#
toSignificantSee toSignificant.
#
toFixedSee toFixed.
#
TokenAmountResponsible for formatting token amounts with specific decimal places.
#
Example#
Properties#
token#
rawReturns the full token amount, unadjusted for decimals.
#
Methods#
add#
subtract#
toSignificantSee toSignificant.
#
toFixedSee toFixed.
#
toExact#
PriceResponsible for denominating the relative price between two tokens. Denominator and numerator must be unadjusted for decimals.
#
ExampleThis example shows the SYS/XYZ price, where SYS is the base token, and XYZ is the quote token. The price is constructed from an amount of XYZ (the numerator) / an amount of WSYS (the denominator).
#
Static Methods#
fromRoute#
Properties#
baseToken#
quoteToken#
scalarUsed to adjust the price for the decimals of the base and quote tokens.
#
rawReturns the raw price, unadjusted for decimals.
#
adjustedReturns the price, adjusted for decimals.
#
Methods#
invert#
multiply#
quoteGiven an asset amount, returns an equivalent value of the other asset, according to the current price.
#
toSignificantSee toSignificant.
#
toFixedSee toFixed.