UNPKG

@dahlia-labs/token-utils

Version:

Token-related math and transaction utilities.

42 lines 1.26 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.TokenAmount = void 0; const token_math_1 = require("@ubeswap/token-math"); class TokenAmount extends token_math_1.TokenAmount { // amount _must_ be raw, i.e. in the native representation constructor(token, amount) { super(token, amount); } new(token, amount) { // unsafe but nobody will be extending this anyway probably return new TokenAmount(token, amount); } /** * Parses a token amount from a decimal representation. * @param token * @param uiAmount * @returns */ static parse(token, uiAmount) { const prev = (0, token_math_1.parseAmountFromString)(token, uiAmount, ".", ","); return new TokenAmount(token, prev); } /** * String representation of this token amount. */ toString() { return `TokenAmount[Token=(${this.token.toString()}), amount=${this.toExact()}`; } /** * JSON representation of the token amount. */ toJSON() { return { ...super.toJSON(), _isTA: true, uiAmount: this.toExact(), }; } } exports.TokenAmount = TokenAmount; //# sourceMappingURL=tokenAmount.js.map