TokenAmount<ChainIdentifier, T, Known>
type TokenAmount<ChainIdentifier, T, Known> = object;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:11
Represents a token amount along with its formatted values and USD valuation helpers
Type Parameters
| Type Parameter | Default type |
|---|---|
ChainIdentifier extends string | string |
T extends Token<ChainIdentifier> | Token<ChainIdentifier> |
Known extends boolean | boolean |
Properties
_amount
_amount: number;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:28
Number representation of the decimal token amount (can lose precision!), might be NaN when
the amount is unknown
amount
amount: string;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:23
Human readable amount with decimal places, might be empty string "" when the amount is unknown
currentUsdValue()
currentUsdValue: (abortSignal?, preFetchedUsdPrice?) => Promise<number>;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:40
Fetches the current USD value of the amount, might return NaN when the amount is unknown
Parameters
| Parameter | Type | Description |
|---|---|---|
abortSignal? | AbortSignal | |
preFetchedUsdPrice? | number | You can supply a pre-fetched usd price to the pricing function |
Returns
Promise<number>
A promise resolving to the current USD value of the token amount
isUnknown
isUnknown: Known extends true ? false : true;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:67
Whether the token amount contains an unknown or undefined amount, in this case numeric values are NaN,
raw amount is undefined, string representation is "" and toString() returns "??? {ticker}"
pastUsdValue?
optional pastUsdValue: number;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:57
USD value of the amount when swap was created - only present for token amounts obtained
from swaps, left for convenience only, use usdValue() instead, which automatically
recognizes which pricing to use (either past value if available or fetches it on-demand),
might be NaN when the amount is unknown
rawAmount
rawAmount: Known extends true ? bigint : undefined;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:19
Raw amount in base units represented as bigint, might be undefined when the amount is unknown
token
token: T;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:32
Token associated with this amount
toString()
toString: () => string;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:62
Returns the string representation of the amount along with the token ticker in format: "{amount} {ticker}",
in case the anmount is unknown returns "??? {ticker}"
Returns
string
usdValue()
usdValue: (abortSignal?, preFetchedUsdPrice?) => Promise<number>;
Defined in: atomiq-sdk/src/types/TokenAmount.ts:50
Gets USD value of the amount, if this amount was returned from a swap it uses the USD value
when the swap was created, otherwise fetches the usd value on-demand, might return NaN
when the amount is unknown
Parameters
| Parameter | Type | Description |
|---|---|---|
abortSignal? | AbortSignal | |
preFetchedUsdPrice? | number | You can supply a pre-fetched usd price to the pricing function |
Returns
Promise<number>
A promise resolving to the current USD value of the token amount