Precision
Understanding token decimals, price formats, and amount conversions is critical for correct trading.
Token Decimal System
Both USDT (collateral) and outcome tokens (YES/NO) use 18 decimal places:
1 USDT
1,000,000,000,000,000,000 (10^18)
0.5 USDT
500,000,000,000,000,000
100 USDT
100,000,000,000,000,000,000
Price Format
Prices are strings representing implied probability:
Valid range:
0.01to0.99Maximum 4 decimal places
"0.50"= 50% probability = $0.50 per token = $1.00 payout if correct
Wei Conversion
The SDK provides a safeAmountToWei utility for converting human-readable amounts to wei:
import { safeAmountToWei } from '@opinion-labs/opinion-clob-sdk';
// Convert human amount to wei
const weiAmount = safeAmountToWei(100.0, 18); // 100 USDT -> wei
console.log(weiAmount); // 100000000000000000000n (BigInt)
// For smart contract operations, pass BigInt directly
await client.split(123, weiAmount);Use BigInt for wei amounts to avoid JavaScript number precision issues.
Example comparisons:
You can also construct wei values directly with BigInt:
Order Amount Handling
When placing orders, provide amounts in human-readable format (not wei). The SDK handles conversion internally.
The distinction is important:
Order amounts (
makerAmountInQuoteToken,makerAmountInBaseToken): human-readable strings, SDK converts internallySmart contract amounts (
split,merge): wei asbigint, you must convert manually
Common Errors to Avoid
Wrong decimals
USDT uses 18 decimals (not 6) in this system.
Float arithmetic
Use BigInt for precise wei calculations.
Price range
Prices must be within [0.01, 0.99].
Manual wei conversion for orders
The SDK handles this; provide human-readable amounts.
Manual wei conversion for split/merge
You must provide wei amounts directly.