Documentation
Decimals
The arithmetic here is simple while everything is native HYPE, and that is exactly when code gets written that breaks on the first ERC-20 quote.
| Asset | Decimals | Note |
|---|---|---|
| Every Tartarus token | 18 | Always. Supply is 1e27 raw |
| HYPE | 18 | Native, address(0) in a pool key |
| An approved ERC-20 quote | its own | Read it from GET /v1/protocol, never assume 18 |
Today HYPE is the only approved quote. approvedQuoteTokens in GET /v1/protocol is the live list,
and each launchConfigs[].quoteToken carries decimals.
Whole units and raw units#
Contracts deal only in raw units. The API returns both, and the names tell you which:
| API field | Unit |
|---|---|
amount, out, fee, quote, price | whole units, as a JSON number. For display only |
amountRaw, outRaw, minOutRaw, feeRaw | raw units, as a string. Use these on chain |
The quote endpoint takes whole units (amount=1 means one HYPE) and returns raw units for the
transaction.
Never round-trip through a float#
// Wrong: 1e27 does not fit in a double
const raw = BigInt(Math.floor(quote.out * 1e18));
// Right
const raw = BigInt(quote.outRaw);
const shown = formatUnits(raw, 18);A JavaScript number has 53 bits of precision. A token amount in raw units regularly needs 90. Keep
bigint from the moment a value leaves the API or the chain, and format only at the edge.
Ticks and orientation#
startingTick is defined as tokens per quote in raw units, so it already includes the difference
in decimals. A 6-decimal quote needs a much higher tick than HYPE for the same market cap. The same
goes for sqrtPriceX96: convert with both assets' decimals in mind, and check which one is
currency0. Price and market cap has the formulas.