Reference
Trading units and rounding
Every Trading quantity is an integer in an atomic unit, and swap rounding always favors existing liquidity providers.
Units
- ETH and collateral outputs use attoETH (10−18 ETH).
- Shares and LP tokens use attoShares, the 18-decimal atomic
uint256unit: one displayed share is 1018 attoShares. At an empty SecurityPool, one attoETH creates 1018 attoShares (one displayed share) of every outcome. Protocol retention makes the later collateral-to-share ratio dynamic, so clients must use the current mutation result rather than assuming this initial rate. - Fees, slippage, initial conditional price, and displayed conditional price use basis points over 10,000 where applicable.
- Deadlines and question end times are Unix seconds.
- Universe IDs are
uint248. A token ID is(universeId << 8) | outcome, with local outcomes INVALID = 0, YES = 1, NO = 2.
Rounding
Exact input computes net = ⌊gross × (10,000 − fee) / 10,000⌋ and out = ⌊reserveOut × net / (reserveIn + net)⌋. Exact output computes net = ⌈reserveIn × out / (reserveOut − out)⌉ and gross = ⌈net × 10,000 / (10,000 − fee)⌉. These directions favor existing LPs.
Liquidity deposits round reserve use down. Removal rounds each reserve output down. Initial alternative odds round the smaller deposited reserve down. Conditional YES is NO / (YES + NO); Conditional NO is YES / (YES + NO).