For the complete documentation index, see llms.txt. This page is also available as Markdown.

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:

Human Amount
Wei Amount

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.01 to 0.99

  • Maximum 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:

example.ts
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);

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 internally

  • Smart contract amounts (split, merge): wei as bigint, you must convert manually

Common Errors to Avoid

1

Wrong decimals

USDT uses 18 decimals (not 6) in this system.

2

Float arithmetic

Use BigInt for precise wei calculations.

3

Price range

Prices must be within [0.01, 0.99].

4

Manual wei conversion for orders

The SDK handles this; provide human-readable amounts.

5

Manual wei conversion for split/merge

You must provide wei amounts directly.