Prize pool composition
The total prize pool accumulates throughout the game:place_bid.rs:120
Example prize pool growth
See prize pool example
See prize pool example
Starting with a 0.014 SOL initial bid:
The prize pool grows exponentially as each bid is 2x the previous.
| Bid # | Amount | Prize Pool |
|---|---|---|
| 1 | 0.014 SOL | 0.014 SOL |
| 2 | 0.028 SOL | 0.042 SOL |
| 3 | 0.056 SOL | 0.098 SOL |
| 4 | 0.112 SOL | 0.210 SOL |
| 5 | 0.224 SOL | 0.434 SOL |
| 6 | 0.448 SOL | 0.882 SOL |
| 7 | 0.896 SOL | 1.778 SOL |
Distribution scenarios
There are two different distribution scenarios depending on the number of bids:Scenario 1: Less than 5 bids (early game end)
If the game ends with fewer than 5 total bids, the distribution is simplified:
Code reference:
place_bid.rs:166-196
In this scenario, there’s no royalty distribution to earlier bidders. The winner receives 90% of the entire prize pool.
Scenario 2: 5 or more bids (standard distribution)
When the game has 5 or more bids, the distribution includes royalties:Calculate platform fee from last 5 bids
Platform fee = (Sum of last 5 bids) × Platform fee percentageThe platform fee percentage is configurable and set to 10% by default.
Determine royalty pool
Royalty pool = 4th bid from the endThis specific bid amount becomes the total royalty to distribute among eligible bidders.
Calculate and distribute royalties
All bidders except the last 5 receive weighted royalties based on their bid amount and position.
place_bid.rs:198-236
Platform fee calculation
The platform fee structure differs based on game size:For games with < 5 bids
For games with ≥ 5 bids
create_game.rs:114
Royalty distribution system
Eligibility
To receive royalties, you must:- ✅ Have placed a bid before the last 5 bids
- ✅ Be part of a game with at least 6 total bids
- ✅ Wait for the game to end
The last 5 bidders (including the winner) do NOT receive royalties. Only earlier bidders are eligible.
Weighted formula
Royalties are distributed using a weighted formula that considers both:- Position weight: Earlier bids get higher weights
- Bid amount: Larger bids get proportionally more royalty
place_bid.rs:238-278
Royalty calculation example
See detailed royalty calculation
See detailed royalty calculation
Game scenario: 8 total bids
Total prize pool: 3.570 SOLLast 5 bids sum: 0.112 + 0.224 + 0.448 + 0.896 + 1.792 = 3.472 SOLPlatform fee: 3.472 × 10% = 0.3472 SOLRoyalty pool: 0.112 SOL (from Dave’s bid)Eligible bidders: Alice, Bob, Carol (first 3 bidders)Weight calculation:
| Bid # | Bidder | Amount | Status |
|---|---|---|---|
| 1 | Alice | 0.014 SOL | Eligible for royalty |
| 2 | Bob | 0.028 SOL | Eligible for royalty |
| 3 | Carol | 0.056 SOL | Eligible for royalty |
| 4 | Dave | 0.112 SOL | Royalty pool amount |
| 5 | Eve | 0.224 SOL | Last 5 - No royalty |
| 6 | Frank | 0.448 SOL | Last 5 - No royalty |
| 7 | Grace | 0.896 SOL | Last 5 - No royalty |
| 8 | Henry | 1.792 SOL | Winner - No royalty |
- Alice (index 0): weight = 3 - 0 = 3
- Bob (index 1): weight = 3 - 1 = 2
- Carol (index 2): weight = 3 - 2 = 1
- Total weight = 3 + 2 + 1 = 6
- Alice: (3 × 0.014 × 0.112) / (6 × 0.098) = 0.0080 SOL
- Bob: (2 × 0.028 × 0.112) / (6 × 0.098) = 0.0107 SOL
- Carol: (1 × 0.056 × 0.112) / (6 × 0.098) = 0.0107 SOL
- Alice: 0.014 + 0.0080 = 0.0220 SOL
- Bob: 0.028 + 0.0107 = 0.0387 SOL
- Carol: 0.056 + 0.0107 = 0.0667 SOL
Winner payout
The winner (last bidder) receives:place_bid.rs:219-225
The smart contract ensures the game account maintains rent-exempt balance. The winner receives everything above this minimum threshold.
Player state updates
When distribution occurs, each player’s state is updated:For royalty recipients
For the winner
place_bid.rs:227-230 and place_bid.rs:269-273
The
safe flag indicates a player has been successfully paid out. This prevents double-payouts and serves as a permanent on-chain record.Distribution flow diagram
Security guarantees
Atomic distribution
All distributions happen atomically within a single transaction:- ✅ Platform fee transfer
- ✅ Royalty transfers to all eligible bidders
- ✅ Winner transfer
- ✅ Player state updates
Rent exemption
The smart contract ensures the game account maintains rent-exempt balance:Overflow protection
All calculations use checked arithmetic:Viewing your earnings
You can check your earnings through:On-chain player state
Query your player account to see:Game history
All distributions are recorded on-chain and visible in:- Transaction history on Solana explorers
- Game account state changes
- Player account balance changes
Next steps
How to play
Learn the complete gameplay flow
Bidding rules
Understand the bidding mechanics and requirements