How It Works
Deep dive into the mechanics that power Seesaw's prediction markets. This section covers the market lifecycle, oracle integration, order matching, and settlement process.
The Core Concept
Seesaw creates binary prediction markets - markets with exactly two outcomes:
Market Timing
Every market follows a precise cadence based on its configured duration and Unix timestamps. Durations range from 60 seconds to 7 days (default: 15 minutes):
market_id = floor(unix_timestamp / duration_seconds)
t_start = market_id × duration_seconds
t_end = t_start + duration_seconds
Example Timeline (UTC) — 15-minute markets
| Market ID | Start Time | End Time | Status |
|---|---|---|---|
| 1936800 | 14:00:00 | 14:15:00 | RESOLVED |
| 1936801 | 14:15:00 | 14:30:00 | TRADING |
| 1936802 | 14:30:00 | 14:45:00 | PENDING |
Multiple markets with different durations can run concurrently for the same asset (e.g., a 1-minute and a 1-hour SOL/USD market).
Complete Lifecycle
State Details
| State | What Happens | Duration |
|---|---|---|
| PENDING | No on-chain account yet | Until created |
| CREATED | Account initialized, awaiting start price | Until t_start |
| TRADING | Order book active, trades execute | Market's duration |
| SETTLING | End price captured, computing outcome | Seconds |
| RESOLVED | Outcome determined, claims available | Until all claimed |
| CLOSED | All accounts closed, rent reclaimed | Final |
Price Mechanics
Shares are priced between 0 and 1 USDC (stored as basis points internally):
The Probability Relationship
Since YES and NO are complementary:
P(YES) + P(NO) = 100%
If YES trades at 0.60:
└── Implied P(UP) = 60%
└── NO should trade at 0.40
└── Implied P(DOWN) = 40%
Order Book Mechanics
Seesaw uses a single unified order book for YES shares. NO orders are automatically converted:
Conversion Rules
| Your Intent | Book Action | Price Conversion |
|---|---|---|
| Buy YES @ P | Bid @ P | None |
| Sell YES @ P | Ask @ P | None |
| Buy NO @ P | Ask @ (1-P) | new_price = 10000 - price |
| Sell NO @ P | Bid @ (1-P) | new_price = 10000 - price |
Oracle Integration
Seesaw uses Pyth Network for price data:
Sampling Rules
Start Price (P_start):
- First Pyth update where
publish_time >= t_start - Must have positive price
- Immutable once captured
End Price (P_end):
- First Pyth update where
publish_time >= t_end - Must have positive price
- Immutable once captured
Resolution Logic
if P_end >= P_start:
outcome = UP
else:
outcome = DOWN
Important: Equality (no change) resolves as UP.
Collateralization
Every share in circulation is backed 1:1 by USDC:
Solvency Invariant
The vault always holds enough to pay all possible winners:
vault_balance >= max(total_yes_shares, total_no_shares)
This ensures the protocol can always settle regardless of outcome.
Fee Structure
| Fee Type | Rate | Recipient | When |
|---|---|---|---|
| Taker Fee | 0.30% | Protocol | On trade |
| Maker Rebate | 0.10% | Order placer | On trade |
| Net | 0.20% | Protocol | — |
Example Calculation
Trade: Buy 100 YES @ 0.50
Notional: 50 USDC
Taker pays: 50 × 1.003 = 50.15 USDC
Maker gets: 50 × 1.001 = 50.05 USDC
Protocol: 0.10 USDC
Settlement Process
After resolution, winners claim their payouts:
Related Documentation
- Order Book Details - Matching engine deep dive
- Oracle Specification - Pyth integration details
- Settlement Rules - Claim process and edge cases