0xtkm
anchor-prediction-market
Rust

Anchor program for a cricket prediction market

Last updated Mar 1, 2026
13
Stars
5
Forks
1
Issues
0
Stars/day
Attention Score
5
Language breakdown
No language data available.
Files click to expand
README

Cricket Prediction Market

The contract allows users to participate in a decentralized prediction market by placing bets on the outcomes of cricket matches.

Market Mechanism (LMSR)

This prediction market uses the Logarithmic Market Scoring Rule (LMSR), a mathematical formula designed specifically for prediction markets. Here's how it works:

Core Formula

The market uses LMSR to determine prices and costs:
  • Cost Function:
C = b · ln(e^(qyes/b) + e^(qno/b))
  • YES Share Price:
Pyes = e^(qyes/b) / (e^(qyes/b) + e^(qno/b))
  • NO Share Price:
Pno = 1 - Pyes

Where:

  • b = Liquidity parameter (controls price sensitivity)
  • q_yes = Number of YES shares
  • q_no = Number of NO shares

Example: "Will India win the 2025 Champions Trophy?"

Let's walk through a trading scenario:

Initial Market State:

b = 1000                # Liquidity parameter qyes = 100000        # Initial YES shares qno = 100000         # Initial NO shares

  • Initial Prices:
P_yes = e^(100,000/1000) / (e^(100,000/1000) + e^(100,000/1000)) = e^100 / (e^100 + e^100) = 0.5 (50%)

Both outcomes start at equal probability

  • Someone buys 50,000 YES shares:
New q_yes = 150,000
P_yes = e^(150,000/1000) / (e^(150,000/1000) + e^(100,000/1000)) = e^150 / (e^150 + e^100) ≈ 0.73 (73%)

Market now shows 73% chance of India winning

  • Another trader buys 75,000 NO shares:
New q_no = 175,000
P_yes = e^150 / (e^150 + e^175) ≈ 0.31 (31%)

Market now shows 31% chance of India winning

How It Works in Practice

  • Trading:
- Buy YES tokens if you think India will win - Buy NO tokens if you think India won't win - Price automatically adjusts with each trade
  • Settlement:
- When the event concludes, winning tokens are worth 1 USDC - Losing tokens are worth 0 USDC
  • Example Trade:
- Current YES price: 0.5 USDC - Buy 1000 YES tokens - Cost = ~500 USDC (plus price impact) - If India wins: Receive 1000 USDC - If India loses: Receive 0 USDC

© 2026 GitRepoTrend · 0xtkm/anchor-prediction-market · Updated daily from GitHub