# TokenAmount\<T, Known>

```
type TokenAmount<T, Known> = object;
```

Defined in: [atomiq-sdk/src/types/TokenAmount.ts:11](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L11)

Represents a token amount along with its formatted values and USD valuation helpers

## Type Parameters

| Type Parameter                                                                                               | Default type                                                                                   |
| ------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------- |
| `T` *extends* [`Token`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/Token.md) | [`Token`](https://docs.atomiq.exchange/sdk-reference/api/atomiq-sdk/src/type-aliases/Token.md) |
| `Known` *extends* `boolean`                                                                                  | `boolean`                                                                                      |

## Properties

### \_amount

```
_amount: number;
```

Defined in: [atomiq-sdk/src/types/TokenAmount.ts:27](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L27)

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:22](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L22)

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:39](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L39)

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:66](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L66)

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:56](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L56)

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:18](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L18)

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:31](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L31)

Token associated with this amount

***

### toString()

```
toString: () => string;
```

Defined in: [atomiq-sdk/src/types/TokenAmount.ts:61](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L61)

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:49](https://github.com/atomiqlabs/atomiq-sdk/blob/786509324f7f09c427e9ccfe527d82e496f06af5/src/types/TokenAmount.ts#L49)

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
