LastHash
Documentation
Open App

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

PhaseDurationDescription
Lobby10 minutesPlayers register, deposit USDC, and submit Round 1 predictions
Round 15 minutesFirst elimination round — ETH price tracked
Intermission 12 minutesRevival window (10% fee) + optional prediction change
Round 25 minutesSecond elimination round
Intermission 22 minutesRevival window (30% fee) + optional prediction change
Round 35 minutesFinal standard round
Overtime5 min/roundSudden-death rounds if >89% survive Round 3 (max 5 rounds)
CompletedIndefiniteWinners 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 MovementLONG PlayersSHORT Players
ETH price went UPSurviveEliminated
ETH price went DOWNEliminatedSurvive
ETH price unchangedSurviveSurvive

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:

  1. Records the round outcome (which side won)
  2. 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 side
  • longDepositTotal[round] / shortDepositTotal[round] — total USDC wagered on each side

When a player changes their prediction during an intermission, the contract:

  1. Subtracts their deposit from the old side's totals
  2. 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 InRevival Available DuringFee
Round 1Intermission 110% of original wager
Round 2Intermission 230% of original wager
Round 3Not available
OvertimeNot 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:

  1. Survivors drop to or below 89% — enough players were eliminated
  2. Maximum overtime rounds reached (5 rounds) — game force-completes
  3. Maximum game duration exceeded (24 hours) — safety cutoff

Prize Pool

Pool Composition

The total prize pool consists of:

  1. All player deposits from registration
  2. 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:

ReasonWhat Happens
Insufficient playersFewer than 4 players registered by lobby end — full refund
Oracle failurePyth Network price feed unavailable — full refund via claimOracleFailureRefund()
Admin cancellationOperator 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.