Chapter 35: Quiz

Smart Contract Market Mechanisms

Test your understanding of conditional tokens, on-chain market designs, Augur's oracle system, and Polymarket's architecture.


Question 1

What does the "split" operation do in the Conditional Token Framework (CTF)?

A) Divides a prediction market into two smaller markets B) Converts collateral into a complete set of outcome tokens (one per outcome) C) Splits a large order into smaller orders for better execution D) Separates the market's liquidity pool into multiple pools

Show Answer **B)** In the CTF, splitting deposits collateral (e.g., 1 USDC) into one token for each outcome (e.g., 1 YES + 1 NO for a binary market). This is the primary mechanism for entering a prediction market position. The reverse operation, "merge," combines a complete set back into collateral.

Question 2

How is a conditionId computed in the Conditional Token Framework?

A) It is a random UUID generated at market creation B) It is keccak256(abi.encodePacked(oracle, questionId, outcomeSlotCount)) C) It is the block hash of the block where the market was created D) It is assigned sequentially by the factory contract

Show Answer **B)** The conditionId is deterministically computed as the keccak256 hash of the oracle address, the questionId (bytes32), and the number of outcome slots. This means the same condition always produces the same ID regardless of when or where it is prepared.

Question 3

True or False: In the CTF, a single ERC-1155 contract manages outcome tokens for ALL prediction markets that use it.

Show Answer **True.** The CTF is a single ERC-1155 contract where each outcome token is identified by a unique token ID derived from the conditionId and the index set. Multiple markets share the same contract, which simplifies composability and reduces deployment costs.

Question 4

What is an "index set" in the Conditional Token Framework?

A) A database index for fast token lookups B) A bitmask representing a subset of outcomes, used to define position tokens C) The set of all market IDs in the protocol D) The list of oracle addresses that can resolve a condition

Show Answer **B)** An index set is a bitmask where each bit represents an outcome. For a 3-outcome market (A, B, C): index set 5 (binary 101) represents "A or C." Index sets enable complex positions like "the winner will be either A or C" within a single token.

Question 5

In Augur's dispute resolution system, what happens when the initial reporter's outcome is challenged?

A) The market is immediately resolved to the challenger's outcome B) A dispute round begins where REP holders can stake on the outcome they believe is correct, with escalating stake requirements C) The market is cancelled and all funds are returned D) An off-chain arbitrator decides the outcome

Show Answer **B)** When a report is disputed, a dispute round begins. REP holders stake tokens on the outcome they believe is correct. Each successive round requires a larger stake (roughly doubling). This escalation ensures that the cost of sustaining a false outcome grows exponentially.

Question 6

Fill in the blank: In a binary prediction market, the fundamental collateral invariant states that _.

Show Answer **Total collateral deposited = Total supply of any single outcome token.** Because every split creates exactly one of each outcome token from one unit of collateral, and every merge destroys one of each to return one unit, the total collateral always equals the total supply of each individual outcome token.

Question 7

What is the purpose of Augur's "fork" mechanism?

A) To create a copy of the Augur codebase for a new version B) To resolve the most contentious disputes by splitting the REP token into two versions, one for each disputed outcome C) To distribute protocol fees to REP holders D) To upgrade the smart contracts

Show Answer **B)** The fork is Augur's ultimate dispute resolution mechanism. When dispute costs reach a threshold (2.5% of total REP supply), the protocol forks the REP token into two versions --- one for each disputed outcome. REP holders must choose a side, permanently. This makes it economically irrational to sustain a false outcome because the attacker would need to hold the majority of all REP.

Question 8

Which architecture pattern does Polymarket use?

A) Monolithic: a single contract handles all operations B) Modular on-chain: separate contracts for tokens, AMM, and oracle C) Hybrid: off-chain order matching with on-chain settlement and token custody D) Fully off-chain with periodic on-chain checkpoints

Show Answer **C)** Polymarket uses a hybrid architecture. The Conditional Token Framework handles token logic on-chain, UMA provides oracle services, but order matching happens off-chain via a Central Limit Order Book (CLOB). This provides a familiar trading experience with low latency while maintaining on-chain custody and settlement.

Question 9

What problem does the "Neg Risk Adapter" solve in Polymarket?

A) It reduces the risk of smart contract bugs B) It converts a multi-outcome market into multiple correlated binary markets where outcomes are negatively correlated C) It provides insurance against market manipulation D) It reduces gas costs for large trades

Show Answer **B)** The Neg Risk Adapter handles markets with mutually exclusive outcomes (e.g., "Who will win the election?"). Instead of a single multi-outcome market, it creates correlated binary markets (A vs not-A, B vs not-B, etc.) with a constraint that the sum of all YES prices equals approximately 1. This leverages the existing binary market infrastructure while correctly modeling the negative correlation between outcomes.

Question 10

In the CTF, what is a "collection ID" and how are deep positions computed?

A) A collection ID identifies a user's portfolio; deep positions are large trades B) A collection ID is computed by XORing multiple condition-level identifiers, enabling positions that are conditional on multiple events C) A collection ID is a database key for indexing positions D) A collection ID is the token contract address

Show Answer **B)** A collection ID combines positions across multiple conditions using XOR. For example, if you hold "YES on Condition A" (collection for A) and "YES on Condition B" (collection for B), the deep position collection ID is the XOR of both. XOR is commutative and associative, so the order of conditions does not matter.

Question 11

A prediction market has YES tokens trading at $0.72 and NO tokens at $0.30. What arbitrage opportunity exists?

A) Buy YES tokens (they are underpriced) B) Buy NO tokens (they are underpriced) C) Buy both YES and NO (the sum is 1.02 > 1.00, so sell a complete set for a risk-free $0.02 profit per pair) D) No arbitrage opportunity exists

Show Answer **C)** When YES + NO > 1.00, you can buy one of each for $1.02 total, then merge them into $1.00 of collateral. Wait --- that loses $0.02. The correct arbitrage is the reverse: *mint* a complete set for $1.00, then *sell* YES for $0.72 and NO for $0.30, collecting $1.02. Profit: $0.02 per set minus gas costs. Actually, re-reading: if you can BUY YES at 0.72 and BUY NO at 0.30, the total cost is 1.02, which is MORE than the 1.00 redemption value. So the arbitrage goes the other direction: SPLIT collateral into tokens (cost: 1.00) and sell them on the market (revenue: 1.02). Net profit: $0.02 per pair.

Question 12

What is the "Invalid" outcome in Augur v2, and why was it added?

Show Answer The "Invalid" outcome was added to handle ambiguous or poorly-defined market questions. If a market resolves as Invalid, all outcome tokens receive equal payout (e.g., each token in a binary market redeems for $0.50). This protects traders from situations where the resolution source is unclear or the question is poorly specified. It also creates an incentive for market creators to write clear, unambiguous questions.

Question 13

True or False: The CTF's splitPosition function requires that the caller already holds collateral tokens and has approved the CTF contract to spend them.

Show Answer **True.** To split collateral into outcome tokens, the caller must hold the collateral token (e.g., USDC) and must have called `approve()` on the collateral token contract to authorize the CTF to transfer the collateral. The CTF calls `transferFrom` to pull the collateral before minting outcome tokens.

Question 14

In Augur's dispute resolution, the required stake roughly doubles each round. If the initial report requires 100 REP and there are 8 dispute rounds, what is the approximate total REP staked across all rounds?

A) 800 REP B) 25,500 REP C) 51,100 REP D) 12,750 REP

Show Answer **C)** The stake at each round is approximately: 100, 200, 400, 800, 1600, 3200, 6400, 12800, plus the initial 100 for the first report and the initial 100 for the first dispute (cumulating as a geometric series). More precisely, the cumulative cost through round r is approximately $100 \times (2^{r+1} - 1)$. For 8 rounds: $100 \times (2^9 - 1) = 100 \times 511 = 51,100$ REP. This exponential escalation makes sustained manipulation extremely expensive.

Question 15

What advantage does the CTF's ERC-1155 standard provide over using separate ERC-20 contracts for each outcome token?

A) ERC-1155 tokens are faster to transfer B) A single contract manages all tokens, reducing deployment costs, enabling batch transfers, and simplifying composability C) ERC-1155 provides better security guarantees D) ERC-1155 tokens can only be transferred by the contract owner

Show Answer **B)** With ERC-1155, one contract manages all outcome tokens (identified by token IDs). This avoids deploying a new ERC-20 contract for every outcome of every market, supports batch operations (transferring multiple token types in one transaction), and provides a unified interface for DeFi integrations.

Question 16

Explain the difference between Polymarket's CLOB (Central Limit Order Book) and an AMM (Automated Market Maker) for prediction market trading.

Show Answer **CLOB:** Orders are submitted by users specifying a price and quantity. A matching engine pairs buy orders with sell orders at compatible prices. Provides precise price control, no impermanent loss for liquidity providers, and zero slippage for orders within the spread. Polymarket uses off-chain matching with on-chain settlement. **AMM:** Liquidity sits in a pool governed by a mathematical formula (e.g., constant product $x \times y = k$). Traders swap against the pool, with the formula determining the price. Provides always-available liquidity but suffers from impermanent loss, slippage on large trades, and less capital efficiency. CLOBs generally offer better execution quality for active traders, while AMMs offer simpler permissionless liquidity provision.

Question 17

What is the payoutDenominator in the CTF, and what does a non-zero value indicate?

Show Answer The `payoutDenominator` is stored for each condition and starts at zero. When the oracle reports the outcome, the CTF stores payout numerators for each outcome and sets the `payoutDenominator` to a non-zero value (typically 1 or the sum of numerators). A non-zero `payoutDenominator` indicates that the condition has been resolved. The payout fraction for outcome $i$ is `payoutNumerators[i] / payoutDenominator`.

Question 18

Consider this code snippet. What does it compute?

condition_id = Web3.solidity_keccak(
    ['address', 'bytes32', 'uint256'],
    [oracle_address, question_id, outcome_count]
)
Show Answer This computes the **conditionId** for a prediction market in the Conditional Token Framework. It takes the `keccak256` hash of the ABI-encoded oracle address, question ID, and number of outcomes. This deterministic computation means anyone can derive the conditionId without querying the contract.

Question 19

Why does Polymarket use UMA's Optimistic Oracle instead of Chainlink for market resolution?

A) Chainlink is more expensive B) Chainlink provides continuous price feeds for financial data, while UMA's Optimistic Oracle can resolve arbitrary natural-language questions C) Chainlink is not available on Polygon D) UMA is faster

Show Answer **B)** Chainlink specializes in continuous data feeds (asset prices, interest rates) aggregated from multiple sources. Prediction markets require resolving diverse, often subjective questions ("Will Congress pass bill X?") that cannot be reduced to a data feed. UMA's Optimistic Oracle allows anyone to propose an outcome for any question, with a dispute mechanism for incorrect proposals. This flexibility makes it suitable for the wide variety of prediction market questions.

Question 20

True or False: In a properly designed prediction market, the merge operation is the exact inverse of the split operation --- merging one of each outcome token returns exactly one unit of collateral.

Show Answer **True.** Split and merge are inverses by design. Splitting 1 USDC produces 1 YES + 1 NO (in a binary market). Merging 1 YES + 1 NO returns 1 USDC. This bidirectional operation, enforced by the smart contract, is what maintains the collateral invariant and keeps outcome token prices anchored to a sum of approximately 1.

Question 21

A prediction market for a 4-candidate election uses the Neg Risk Adapter. The binary market prices are: Candidate A = 0.45, B = 0.30, C = 0.15, D = 0.12. The sum is 1.02. Describe the arbitrage and calculate the profit per $1,000 invested.

Show Answer Since the sum of prices (1.02) exceeds 1.00, an arbitrageur can: 1. Buy a complete set of NO tokens across all four binary markets. Cost per set: $(1-0.45) + (1-0.30) + (1-0.15) + (1-0.12) = 0.55 + 0.70 + 0.85 + 0.88 = 2.98$. Wait, that is not right for a Neg Risk setup. In the Neg Risk framework, only one candidate wins, so exactly one YES resolves to 1 and the rest resolve to 0. Correct arbitrage: Mint complete sets for each binary market (cost: $1 each = $4 total for all four markets). Sell all YES tokens: $0.45 + 0.30 + 0.15 + 0.12 = $1.02. Keep all NO tokens. After resolution, exactly 3 of 4 NO tokens pay $1 each = $3.00. Total revenue: $1.02 + $3.00 = $4.02. Total cost: $4.00. Profit: $0.02 per cycle. Per $1,000 invested: $1,000 / $4.00 = 250 cycles. Profit: 250 * $0.02 = **$5.00** (0.5% return, minus gas costs).

Question 22

What is the relationship between Augur's REP token price and the maximum market size that Augur can securely support?

Show Answer Augur's security model relies on the assumption that the cost of corrupting the oracle (acquiring >50% of participating REP and staking on the wrong outcome) exceeds the value at risk in any market. The fork threshold is 2.5% of total REP supply. Security bound: Maximum secure market size $\approx$ Total REP supply $\times$ REP price $\times$ 2.5%. If total REP = 11 million and REP = $10: max secure market = 11M * $10 * 0.025 = $2.75M. If REP drops to $2: max secure market = 11M * $2 * 0.025 = $550K. This creates a reflexive problem: as REP price falls, Augur becomes less secure, which may reduce usage, further depressing REP price.

Question 23

What gas optimization does the "batch transfer" feature of ERC-1155 provide for prediction market operations?

Show Answer ERC-1155's `safeBatchTransferFrom` function allows transferring multiple token types (different outcome tokens) in a single transaction. For prediction markets, this means a trader can transfer YES and NO positions across multiple markets in one transaction, saving the per-transaction base gas cost (21,000 gas) that would be paid for each separate ERC-20 transfer. For a portfolio with positions in 10 markets, this can save approximately 180,000 gas (9 * 21,000 base cost savings minus some overhead).

Question 24

Short Answer: Explain why the "checks-effects-interactions" pattern is critical in the redeemPositions function of a prediction market contract.

Show Answer The `redeemPositions` function transfers collateral back to users. If the function makes the external transfer (interaction) before updating internal state (zeroing the user's token balance), an attacker could deploy a contract with a fallback function that re-enters `redeemPositions` before the balance is zeroed, draining additional funds. The checks-effects-interactions pattern prevents this: 1. **Checks**: Verify the market is resolved and the user has winning tokens. 2. **Effects**: Zero the user's token balance and compute the payout. 3. **Interactions**: Transfer the collateral to the user. By zeroing the balance before the transfer, a re-entrant call would find zero balance and no payout.

Question 25

Consider a CTF with a 3-outcome condition (outcomes A, B, C). The valid index sets are:

Index Set Binary Outcomes
1 001 {A}
2 010 {B}
3 011 {A, B}
4 100 {C}
5 101 {A, C}
6 110 {B, C}
7 111 {A, B, C}

Which of the following are valid partitions of the full outcome space?

I. {1, 2, 4} = {A}, {B}, {C} II. {3, 4} = {A or B}, {C} III. {1, 6} = {A}, {B or C} IV. {1, 2, 3} = {A}, {B}, {A or B} V. {5, 2} = {A or C}, {B}

Show Answer A valid partition requires: (a) no overlap between index sets (bitwise AND of any pair = 0), and (b) complete coverage (bitwise OR of all = 7 for 3 outcomes). - **I. {1, 2, 4}**: 1 AND 2 = 0, 1 AND 4 = 0, 2 AND 4 = 0. 1 OR 2 OR 4 = 7. **Valid.** - **II. {3, 4}**: 3 AND 4 = 011 AND 100 = 0. 3 OR 4 = 111 = 7. **Valid.** - **III. {1, 6}**: 1 AND 6 = 001 AND 110 = 0. 1 OR 6 = 111 = 7. **Valid.** - **IV. {1, 2, 3}**: 1 AND 3 = 001 AND 011 = 001 != 0. **Invalid** (overlapping). - **V. {5, 2}**: 5 AND 2 = 101 AND 010 = 0. 5 OR 2 = 111 = 7. **Valid.**