Explanation
The two-way market
Trading is the two-reserve constant-product design from How To Build: Augur Constant Product with Invalid Insurance, adapted to Statoblast. This page explains what happens inside one entry.
Mental model
A SecurityPool is the Statoblast contract that holds ETH collateral for one question, universe, and pool configuration. Its canonical ShareToken is ERC-1155: creating one complete set mints equal Invalid, Yes, and No shares for that pool's universe-specific token IDs; redeeming a complete set burns those three shares and returns collateral at the pool's current dynamic rate.
The Trading factory maps the exact SecurityPool address to one immutable-fee pair. The pair is both the Yes/No constant-product reserve and the transferable LP token; it never accepts Invalid shares. The router, which holds no balances or positions between calls, coordinates complete-set creation or redemption, pair swaps, and bounded asset delivery. Users and liquidity providers keep Invalid shares separately in their wallets. The invariant to remember is:
Swaps and added liquidity are open only while the market is live; Forks and resolution lists what closes a pair. Parent and child SecurityPools are distinct markets and therefore use distinct pairs.
One entry, step by step
The pair maintains k = Yes reserve × No reserve. Entering Yes looks like this; entering No is the mirror image.
- User → Router:
enterPosition(pair, YES)with ETH - Router → SecurityPool:
createCompleteSet{value: ETH}() - SecurityPool → Router: q Invalid + q Yes + q No
- Router → Pair: swap q No for Yes
- Pair → Router: additional Yes
- Router → User: q Invalid + total Yes
Suppose the reserves are 1,000 Yes and 1,000 No, the fee is zero, and 100 complete-set shares are created. Contract math uses attoShares, where one displayed share is 1018 attoShares. Swapping 100 No therefore yields 90.909090909090909090 Yes after flooring to a whole number of attoShares. The wallet receives 190.909090909090909090 Yes and 100 Invalid; the reserves become 909.090909090909090910 Yes and 1,100 No. Flooring the output favors existing liquidity providers.
A No purchase simply reverses the reserves. No position record is created anywhere: wallet Yes, No, Invalid, and LP balances are the complete accounting state.