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 one attoShare of every outcome: 1 ETH creates one Yes, one No, and one Invalid share. Protocol holding fees 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, and the LP minted is the smaller of ⌊yesUsed × supply / yesReserve⌋ and ⌊noUsed × supply / noReserve⌋. Removal rounds each reserve output down. Initial alternative odds round the smaller deposited reserve down. Conditional Yes is NO / (YES + NO) and Conditional No is YES / (YES + NO); in basis points, Conditional Yes is ⌊10,000 × NO / (YES + NO)⌋. Client slippage bounds round a minimum down and a maximum up.