Fractions
#
FractionThe base class which all subsequent fraction classes extend. All the properties and methods are self-explanatory in this class. This sections breifs about all the properties and methods of other classes which inherit Fraction.
#
Properties#
numerator#
denominator#
quotientPerforms floor division.
#
Methods#
invert#
add#
subtract#
multiply#
divide#
toSignificantFormats a fraction to the specified number of significant digits.(Rounding-off)
#
toFixedFormats a fraction to the specified number of decimal places.
#
Percent class extends FractionUsed for formatting percentages (10% instead of 0.1).
#
toSignificantSee toSignificant.
#
toFixedSee toFixed.
#
CurrencyAmount extends Fraction class- this class has a static helper to call the constructor with ETH as currency
#
Properties#
rawReturns the full token amount, without rounding off to decimals.
#
Methods#
add#
subtract#
toSignificantSee toSignificant.
#
toFixedSee toFixed.
#
toExact#
TokenAmount extends currentAmount class#
Properties#
token#
rawSee raw.
#
Methods#
add#
subtract#
toSignificantSee toSignificant.
#
toFixedSee toFixed.
#
toExactSee toExact.
#
Price extends FractionHandles denominating the relative price between two tokens. Where, Denominator and numerator are not rounded off or raw price.
#
Static Methods#
fromRoute#
Properties#
baseToken#
quoteToken#
scalarUsed to adjust the price for the decimals of the base and quote tokens.
#
rawReturns the raw price, without rounding off to decimals.
#
adjustedReturns the price, with rounding off to decimals.
#
Methods#
invert#
multiply#
quoteReturns an equivalent value of the asset, according to the current price.
#
toSignificantSee toSignificant.
#
toFixedSee toFixed.