Precision
Precision and Amount Handling
Token Decimal Systems
Overview
USDT (Collateral Token)
# Human-readable: 100 USDT
usdt_amount = 100
# Contract representation
amount_micro_usdt = usdt_amount * 10**18
# Reverse transformation
usdt_amount = amount_micro_usdt / 10**18 # 100.0 USDTHuman-Readable
Exponential Notation
Outcome Tokens (YES/NO)
Human-Readable
Wei (Contract)
Exponential Notation
Price Representation
Format Specification
Price String
Implied Probability
Cost per Share
Payout (if correct)
Max Profit
Order Amount Specifications
Quote Token Amount (makerAmountInQuoteToken)
Base Token Amount (makerAmountInBaseToken)
Smart Contract Amount Specifications
Split Operation
Merge Operation
Redeem Operation
Floating Point Precision Issues
Problem: IEEE 754 Rounding Errors
Best Practices for Precision
Amount Formatting
Display Formatting
Common Precision Errors
Error 1: Incorrect Decimal Places
Error 2: Float to Wei Conversion
Error 3: Price Outside Valid Range
Position Size Calculations
Total Position Value
Profit and Loss Calculation
Break-even Analysis
API Response Amount Parsing
Parse Balance Response
Next Steps
Last updated