> ## Documentation Index
> Fetch the complete documentation index at: https://xoxno.com/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Token amounts

> How to convert human-readable token amounts to smallest unit strings before calling XOXNO quote and transaction endpoints.

Pass token amounts as integer strings in the token's smallest unit.

## Definition

A human-readable amount includes the decimal point users see in wallets. A smallest unit amount is the integer value sent to APIs and contracts.

```text theme={"system"}
smallest_unit = human_readable_amount * 10^decimals
```

## Decision Table

| Product                          | Where to read decimals        | Amount fields                                      |
| -------------------------------- | ----------------------------- | -------------------------------------------------- |
| MultiversX Aggregator            | `/api/v1/pair-config`         | `amountIn`, `amountOut`, `amountOutMin`            |
| Stellar Aggregator               | `/api/v1/tokens`              | `amount_in`, `amount_out`, `amountIn`, `amountOut` |
| Relayer and Gateway transactions | Token metadata or chain rules | `value`, ESDT transfer amounts, contract args      |

## Worked Example

Convert 1 WEGLD with 18 decimals:

```ts theme={"system"}
const human = "1";
const decimals = 18n;
const smallest = BigInt(human) * 10n ** decimals;
console.log(smallest.toString()); // "1000000000000000000"
```

Convert 100 USDC with 6 decimals:

```ts theme={"system"}
const human = "100";
const decimals = 6n;
const smallest = BigInt(human) * 10n ** decimals;
console.log(smallest.toString()); // "100000000"
```

## Edge Cases

| Case                              | Risk                                        | Fix                                                     |
| --------------------------------- | ------------------------------------------- | ------------------------------------------------------- |
| Floating-point conversion         | JavaScript `number` can round large values. | Use `BigInt`, decimal libraries, or string parsers.     |
| Assumed decimals                  | Tokens can use different precisions.        | Read decimals from the product endpoint before quoting. |
| Human-readable amount sent to API | Quote amount is off by powers of ten.       | Convert before request construction.                    |
| Scientific notation               | APIs expect integer strings.                | Serialize as base-10 strings without `e`.               |

<Warning>
  Do not send human-readable amounts to quote endpoints. A decimal mistake can build a transaction for the wrong value.
</Warning>

## Verify

Before signing or broadcasting, compare:

* The input token decimals from metadata.
* The integer string sent in the request.
* The displayed human-readable amount in your UI.
* The returned `amountOut` or `amountIn` converted back with output decimals.

## Related Endpoints

* [MultiversX pair config](/aggregator/pair-config)
* [MultiversX quote](/aggregator/quote)
* [Stellar tokens](/stellar-aggregator/tokens)
* [Stellar quote](/stellar-aggregator/quote)
