Chapter 35: Key Takeaways
Smart Contract Market Mechanisms
On-Chain Market Lifecycle
- Every on-chain prediction market follows five stages: market creation, token minting (splitting), trading, resolution, and redemption.
- The fundamental invariant: total collateral deposited = total supply of each outcome token. Split creates tokens; merge destroys them. The system is always fully collateralized.
- Three architecture patterns dominate: monolithic (single contract), modular (separate token/trading/oracle contracts), and hybrid (off-chain matching, on-chain settlement). Polymarket uses the hybrid pattern.
Conditional Token Framework (CTF)
- The CTF is a single ERC-1155 contract that manages outcome tokens for all markets. Each token is identified by a unique ID derived from the collateral token, condition ID, and index set.
- The conditionId is deterministically computed:
keccak256(oracle, questionId, outcomeSlotCount). - Index sets are bitmasks representing subsets of outcomes. For a 3-outcome market, index set 5 (binary 101) means "outcome 0 or outcome 2."
- A valid partition is a set of non-overlapping index sets that together cover all outcomes. The split operation requires a valid partition.
- Collection IDs enable deep positions across multiple conditions using XOR composition. XOR is commutative and associative, so order does not matter.
- splitPosition converts collateral into outcome tokens; mergePositions converts a complete set back. These are exact inverses.
- After resolution, redeemPositions allows holders of winning tokens to claim collateral. Losing tokens become worthless.
Augur's Oracle and Dispute Resolution
- Augur uses a decentralized oracle based on REP token staking. The designated reporter submits an initial report; anyone can dispute by staking REP on a different outcome.
- Dispute stakes roughly double each round, creating exponential cost escalation. Sustaining a false outcome through N rounds costs approximately $100 \times 2^N$ REP.
- The fork mechanism is the ultimate backstop: if disputes reach 2.5% of total REP supply, the REP token splits permanently. REP holders choose a side, and the "correct" universe retains value.
- Augur's security bound: maximum secure market size = total REP supply * REP price * fork threshold percentage. At REP = $10 and 11M supply, this is approximately $2.75M.
- The Invalid outcome (Augur v2) handles ambiguous questions. All tokens receive equal payout, incentivizing clear question design.
- Reflexivity problem: Augur's security depends on REP price, which depends on Augur's usage, which depends on its security.
Polymarket Architecture
- Polymarket uses a hybrid architecture: CTF for token logic, UMA Optimistic Oracle for resolution, and an off-chain CLOB for order matching.
- The Neg Risk Adapter converts multi-outcome markets into correlated binary markets. Each outcome gets its own YES/NO pair, with the constraint that YES prices sum to approximately 1.
- Off-chain order matching provides low-latency execution without gas costs per order placement. Only settlement (fills) happens on-chain.
- Polymarket operates on Polygon PoS for low fees and fast confirmations, using USDC as collateral.
Token Economics
- In a binary market: YES price + NO price = 1 (minus fees and spread). Deviations create arbitrage opportunities.
- Complete set arbitrage: If YES + NO > 1, mint a set (cost: 1) and sell both (revenue: > 1). If YES + NO < 1, buy both and merge.
- The annualized return of a prediction market position depends on the purchase price, the true probability, and the time to resolution.
- Outcome tokens are composable DeFi primitives: they can be traded on DEXes, used as collateral in lending, and integrated into structured products.
Security Considerations
- Reentrancy is the most dangerous vulnerability in prediction market contracts. The checks-effects-interactions pattern is mandatory for any function that transfers funds.
- Front-running / MEV affects on-chain AMM-based markets. CLOB architectures with off-chain matching (Polymarket) are less vulnerable.
- Oracle manipulation is the highest-impact attack vector. The cost of corrupting the oracle must exceed the value at risk in the market.
- Smart contract audits are essential. All major prediction market protocols undergo multiple audits and maintain bug bounty programs.
- Access control: Only the designated oracle should be able to resolve a market. Modifier checks (
onlyOracle) must be applied consistently.
Architecture Comparison
| Feature | Augur | Polymarket | Omen (Gnosis) |
|---|---|---|---|
| Token standard | ERC-20 (v1), ERC-1155 (v2) | CTF (ERC-1155) | CTF (ERC-1155) |
| Trading mechanism | LMSR AMM (v1), CLOB (v2) | Off-chain CLOB | AMM (various) |
| Oracle | REP-based voting | UMA Optimistic Oracle | Centralized or Reality.eth |
| Chain | Ethereum L1 | Polygon | Gnosis Chain / Ethereum |
| Key trade-off | Most decentralized oracle, highest gas costs | Best UX, some centralization in matching | Simple, low cost, weaker oracle |
Quick Reference: CTF Operations
| Operation | Input | Output | Gas (approx) |
|---|---|---|---|
| prepareCondition | oracle, questionId, outcomeCount | conditionId | 50,000 |
| splitPosition | collateral amount | outcome tokens (1 of each) | 150,000 |
| mergePositions | complete token set | collateral | 120,000 |
| reportPayouts | payout vector | (state change) | 80,000 |
| redeemPositions | winning tokens | collateral | 180,000 |