TokenAmount
Responsible for formatting token amounts with specific decimal places. Derived from Fraction entity.
Example
import { Token, TokenAmount } from '@tradegen/sdk'
const token = new Token(ChainId.ALFAJORES, '0x0000000000000000000000000000000000000001', 18, 'XIAO', 'Mao')
const tokenAmount = new TokenAmount(token, '3000000000000000000')
console.log(tokenAmount.toExact()) // 3Properties
token: Instance of Token entity represented by this instance of TokenAmount
Methods
raw
Returns the full token amount, unadjusted for decimals.
raw(): JSBItoSignificant
toSignificant(
significantDigits: number = 6,
format?: object,
rounding: Rounding = Rounding.ROUND_DOWN
): stringtoFixed
toFixed(
decimalPlaces: number = this.currency.decimals,
format?: object,
rounding: Rounding = Rounding.ROUND_DOWN
): stringtoExact
toExact(format: object = { groupSeparator: '' }): stringadd
add(other: TokenAmount): TokenAmountsubtract
subtract(other: TokenAmount): TokenAmountLast updated
Was this helpful?