Tradegen
Search
K

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()) // 3

Properties

  • token: Instance of Token entity represented by this instance of TokenAmount

Methods

raw

Returns the full token amount, unadjusted for decimals.
raw(): JSBI

toSignificant

toSignificant(
significantDigits: number = 6,
format?: object,
rounding: Rounding = Rounding.ROUND_DOWN
): string

toFixed

toFixed(
decimalPlaces: number = this.currency.decimals,
format?: object,
rounding: Rounding = Rounding.ROUND_DOWN
): string

toExact

toExact(format: object = { groupSeparator: '' }): string

add

add(other: TokenAmount): TokenAmount

subtract

subtract(other: TokenAmount): TokenAmount
Last modified 2yr ago