Game Mechanics
Game Lifecycle
Every LastHash game follows a fixed sequence of phases. Games are created automatically by the factory contract at regular intervals (default: every 10 minutes) when the previous game's lobby closes.
LOBBY → ROUND 1 → INTERMISSION 1 → ROUND 2 → INTERMISSION 2 → ROUND 3 → [OVERTIME] → COMPLETED
Phase Details
| Phase | Duration | Description |
|---|---|---|
| Lobby | 10 minutes | Players register, deposit USDC, and submit Round 1 predictions |
| Round 1 | 5 minutes | First elimination round — ETH price tracked |
| Intermission 1 | 2 minutes | Revival window (10% fee) + optional prediction change |
| Round 2 | 5 minutes | Second elimination round |
| Intermission 2 | 2 minutes | Revival window (30% fee) + optional prediction change |
| Round 3 | 5 minutes | Final standard round |
| Overtime | 5 min/round | Sudden-death rounds if >89% survive Round 3 (max 5 rounds) |
| Completed | Indefinite | Winners can claim proportional rewards |
A game requires a minimum of 4 players to start. If fewer than 4 players register during the lobby, the game is cancelled and all deposits are refunded.
Elimination Logic
At the end of each round, the contract compares the ETH/USD price at the start and end of the round:
| Price Movement | LONG Players | SHORT Players |
|---|---|---|
| ETH price went UP | Survive | Eliminated |
| ETH price went DOWN | Eliminated | Survive |
| ETH price unchanged | Survive | Survive |
How Prices Are Determined
LastHash uses the Pyth Network oracle for real-time ETH/USD pricing on Base. The oracle provides:
- Sub-second price updates with high confidence intervals
- Tamper-resistant pricing via Pyth's decentralized publisher network
- Price freshness validation — prices older than 2 minutes are rejected
The contract records roundStartPrice when a round begins and roundEndPrice when it ends. The difference determines which side is eliminated.
Pull-Based Elimination
Eliminations are processed using a pull-based pattern for gas efficiency. Rather than iterating over every player to mark eliminations (which would be prohibitively expensive with 500 players), the contract:
- Records the round outcome (which side won)
- Each player's elimination status is checked on-demand when they interact with the contract (submitting predictions, claiming rewards, or attempting revival)
This design keeps gas costs constant regardless of player count.
Prediction Inheritance
Players don't need to actively vote every round. The prediction system uses an inheritance chain:
Round 2 prediction = player's Round 2 vote OR inherited Round 1 prediction
Round 3 prediction = player's Round 3 vote OR inherited Round 2 prediction OR inherited Round 1 prediction
Overtime prediction = player's OT vote OR inherited Round 3 prediction chain
Players can override their inherited prediction during any intermission. If they don't, their most recent active prediction carries forward.
Vote Counting
The contract tracks vote counts and deposit totals for each side in each round:
longVoteCount[round]/shortVoteCount[round]— number of players on each sidelongDepositTotal[round]/shortDepositTotal[round]— total USDC wagered on each side
When a player changes their prediction during an intermission, the contract:
- Subtracts their deposit from the old side's totals
- Adds their deposit to the new side's totals
This ensures accurate tracking for prize pool calculations.
Revival System
Eliminated players get one chance to re-enter the game by paying a revival fee.
Revival Windows
| Eliminated In | Revival Available During | Fee |
|---|---|---|
| Round 1 | Intermission 1 | 10% of original wager |
| Round 2 | Intermission 2 | 30% of original wager |
| Round 3 | Not available | — |
| Overtime | Not available | — |
Revival Rules
- Each player can only revive once per game
- The player must submit a new prediction (LONG or SHORT) when reviving
- The revival fee is paid in USDC and split:
- 50% added to the prize pool (benefits all survivors)
- 50% sent to the platform treasury
Revival Example
Player deposits: $100 USDC
Eliminated in: Round 1
Revival fee: $100 x 10% = $10 USDC
→ $5 added to prize pool
→ $5 to treasury
Player status: Active with new prediction for Round 2
Overtime
When Does Overtime Trigger?
After Round 3 eliminations are processed, if the survivor percentage exceeds 89%, the game enters overtime:
Survivor % = (Active Survivors / Total Participants) x 100
If Survivor % > 89% → Overtime begins
Example: 100 players start. After Round 3, 92 survive. That's 92% > 89%, so overtime is triggered.
Overtime Rules
- Each overtime round is 5 minutes (same as standard rounds)
- Same LONG/SHORT elimination logic applies
- No revival during overtime
- Players can change predictions between overtime rounds
- Maximum 5 overtime rounds before the game is force-completed
Overtime End Conditions
Overtime ends when any of these conditions are met:
- Survivors drop to or below 89% — enough players were eliminated
- Maximum overtime rounds reached (5 rounds) — game force-completes
- Maximum game duration exceeded (24 hours) — safety cutoff
Prize Pool
Pool Composition
The total prize pool consists of:
- All player deposits from registration
- 50% of all revival fees collected during intermissions
Total Prize Pool = Sum of all wagers + 50% of all revival fees
Payout Formula
Each surviving player receives a proportional share based on their wager:
Gross Payout = Total Prize Pool x (Player's Wager / Total Survivor Deposits)
The Total Survivor Deposits is the sum of wagers from all surviving players only (not eliminated players).
Payout Example
Game: 10 players, each wagered different amounts
Total deposits: $1,000
Revival fees collected: $50 (adds $25 to pool)
Total prize pool: $1,025
3 survivors remain with deposits of: $200, $150, $100
Total survivor deposits: $450
Player A ($200 wager): $1,025 x (200/450) = $455.56 gross
Player B ($150 wager): $1,025 x (150/450) = $341.67 gross
Player C ($100 wager): $1,025 x (100/450) = $227.78 gross
After 10% platform fee:
Player A net: $410.00
Player B net: $307.50
Player C net: $205.00
Zero Survivors Scenario
In the rare case where all players are eliminated (e.g., everyone picked the same wrong side), the entire prize pool is sent to the platform treasury. This prevents funds from being permanently locked in the contract.
Game Cancellation
A game may be cancelled under these conditions:
| Reason | What Happens |
|---|---|
| Insufficient players | Fewer than 4 players registered by lobby end — full refund |
| Oracle failure | Pyth Network price feed unavailable — full refund via claimOracleFailureRefund() |
| Admin cancellation | Operator cancels for emergency — full refund |
When a game is cancelled, all players receive their full deposit back with no fees deducted.
Maximum Game Duration
Every game has an absolute maximum duration of 24 hours. If a game is still running after 24 hours (due to excessive overtime or stuck phases), it is automatically force-completed. This is a safety mechanism to prevent funds from being indefinitely locked.