Lifecycle Overview
State Definitions
1. Created
Market Created
Trigger:
createMarket(actorHandle, duration)State: Market exists but may have no submissions yetConstraints:- Duration must be between 1 hour and 30 days
- Actor handle specified
- Pool starts at 0 ETH
PredictionMarketV2.sol:139-159
Contract Constants
Contract Constants
2. Active (Accepting Submissions)
Active Market
Condition:
block.timestamp < endTime - BETTING_CUTOFFActions Allowed:- Submit predictions with ETH stake
- View current submissions and pool size
- Cannot resolve market
- Cannot claim payouts
PredictionMarketV2.sol:167-198
Submission Validation
3. Betting Closed
Betting Closed
Condition:
endTime - BETTING_CUTOFF ≤ block.timestamp < endTimeDuration: Final 1 hour before market endState: No new submissions accepted, waiting for market to end4. Market Ended (Awaiting Resolution)
Market Ended
Condition:
block.timestamp >= endTime && !resolvedNext Steps:- Oracle fetches actual text from X API
- Owner calls
resolveMarket()with actual text - OR if only 1 submission exists: anyone can call
refundSingleSubmission()
- Normal Resolution (≥2 submissions)
- Single Submission Refund
PredictionMarketV2.sol:207-244
5. Resolved
Market Resolved
Condition:
resolved == true && winningSubmissionId != 0State:- Winner determined by minimum Levenshtein distance
- First submitter wins ties (deterministic)
- Pool ready for winner to claim
Winner Determination Logic
Why First Submitter Wins Ties?
Why First Submitter Wins Ties?
This creates an incentive to submit early and confidently. Waiting to see others’ submissions provides no advantage because:
- All submissions are committed on-chain (can’t change after submitting)
- Comparison is against actual text, not other submissions
- Early submission shows conviction
6. Claimed
Payout Claimed
Trigger: Winner calls
claimPayout(submissionId)Final State: ETH transferred to winner, fees accumulated for withdrawalPredictionMarketV2.sol:250-273
Payout Calculation
Pull-based fees: Fees accumulate in
pendingFees[feeRecipient] and are withdrawn separately. This prevents griefing attacks where a malicious fee recipient reverts transfers.Special Cases
The NULL Sentinel
Predicting Silence
Markets can resolve with
__NULL__ if the target doesn’t post.Use Case: Betting that a public figure will not post during the market windowExample: Jensen Huang Stays Silent
Example: Jensen Huang Stays Silent
From Example 4 in the whitepaper:
Winner: Null trader at distance 0 (exact match)
| Submitter | Prediction | Distance |
|---|---|---|
| Null trader | __NULL__ | 0 |
| Human (guessing) | “Jensen will flex about Blackwell…“ | 46 |
| AI Roleplay | ”NVIDIA Blackwell Ultra is sampling…“ | 90 |
AI roleplay agents always generate text - they cannot predict silence. The
__NULL__ sentinel enables a market primitive that binary contracts cannot express.Emergency Withdrawal
Admin Safety Valve
Trigger: Owner only, 7+ days after market end, market not resolvedAction: Refund all participants, mark market as resolvedPurpose: Recover funds if oracle fails or resolution becomes impossible
PredictionMarketV2.sol:425-447
State Diagram Details
Time-Based Transitions
Guard Conditions
Each state transition has strict guard conditions:- Create Market
- Submit Prediction
- Resolve Market
- Claim Payout
Events Emitted
Every state transition emits events for off-chain tracking:View Functions
Query market state at any time:getMarketDetails()
Returns:
- Actor handle
- End time
- Total pool
- Resolved status
- Winning submission ID
- Creator
- All submission IDs
getSubmissionDetails()
Returns:
- Market ID
- Submitter address
- Predicted text
- Amount staked
- Claimed status
getMarketSubmissions()
Returns array of all submission IDs for a market
getUserSubmissions()
Returns array of all submission IDs for a user
Key Takeaways
Deterministic: Every state transition has clear conditions and guard rails
Fair: First submitter wins ties, betting cutoff prevents front-running
Safe: Pull-based fees, reentrancy guards, emergency withdrawal
Transparent: All state changes emit events for off-chain tracking
Next Steps
Fee Structure
Learn how the 7% platform fee is distributed
Levenshtein Distance
Deep dive into the scoring mechanism