Amounts and units
Every token amount is a bigint of base units. Never a float.
Token decimals
- Base units sent to the API
- "1234567123456789012345678"
- Shown in the app
- 1,234,567
- As a JavaScript number
- 1234567123456788946485248
Precision lost: 65860430 base units sent to the api
Source: src/lib/units.ts → parseAmount(), formatAmount()
The rules
parseAmount1500000nSent to the API"1500000"Shown1.5
USDC, 6 decimals
Source: src/lib/units.ts
Parse once, at the edge
Typed text becomes a bigint through parseAmount(text, decimals). It returns undefined for anything that isn't a valid amount for that token.
Send strings
The API takes and returns amounts as decimal strings of base units: "1000000" is 1 USDC.
Format only for display
formatAmount shows up to 6 significant digits on screen; whole numbers are never cut. The full value is in the tooltip.
Native HYPE
Native HYPE is the zero address 0x0000…0000 in every API payload. MAX on HYPE keeps 0.01 HYPE back for gas.