Decimal Reference
Token amounts and prices in the Thetanuts SDK are always passed as bigint values scaled to the token's native decimal precision. This page documents the decimal scale for every value type you will encounter.
Decimal Table
USDC
6
DECIMALS.USDC
1000000n = 1 USDC
WETH
18
DECIMALS.WETH
1000000000000000000n = 1 WETH
cbBTC
8
DECIMALS.cbBTC
100000000n = 1 cbBTC
Strike / Price
8
DECIMALS.PRICE
185000000000n = $1850
numContracts
collateral decimals
—
Depends on the collateral token
numContracts uses the same decimal precision as the position's collateral token. For a USDC-collateralized option, numContracts is expressed in 6 decimals; for a WETH-collateralized option, it is 18 decimals.
Decimal Constants
import { DECIMALS } from '@thetanuts-finance/thetanuts-client';
DECIMALS.USDC // 6
DECIMALS.WETH // 18
DECIMALS.cbBTC // 8
DECIMALS.PRICE // 8 — strikes and settlement prices
DECIMALS.SIZE // 18 — numContracts (independent of collateral)Conversion Examples
The SDK provides helpers for all conversions. Use them instead of manual multiplication to avoid floating-point precision errors.
To on-chain values
From on-chain values
Real-World Usage
Approving collateral for an order fill
Building an RFQ with a human-readable strike
Reading settlement prices from on-chain
Settlement prices and price feeds return values with 8 decimal places:
Formatting balances for display
Common Mistakes
Do not use JavaScript number arithmetic for on-chain values. JavaScript's 64-bit float loses precision at large integers. Always use bigint or the SDK helpers:
Do not hardcode decimal scales. Use the DECIMALS constants or read .decimals from client.chainConfig.tokens:
See Also
Utilities — Full UtilsModule method reference
Chain Config — Token addresses and decimals per chain
Modules Overview — All 15 modules at a glance
Last updated

