Skip to content

Live Betting Pool with Dynamic Odds - #1

Open
marcus-shedrach wants to merge 1 commit into
mainfrom
live
Open

Live Betting Pool with Dynamic Odds#1
marcus-shedrach wants to merge 1 commit into
mainfrom
live

Conversation

@marcus-shedrach

Copy link
Copy Markdown
Owner

Live Betting Pool with Dynamic Odds

Executive Summary

A sophisticated multi-outcome betting platform featuring real-time odds calculation, support for complex events with up to 10 different possible outcomes, and comprehensive risk management tools. This contract enables advanced betting scenarios beyond simple win/loss situations, with dynamic odds that adjust as bets are placed.

Technical Architecture

The contract implements a parimutuel pool system where multiple outcomes share a common prize pool. Each outcome maintains its own sub-pool, and the ratio between total pool and outcome pool determines real-time odds. The architecture supports incremental betting (users can add to existing stakes), granular pause controls, and automated payout calculations based on final pool distributions.

Core Mechanics

Pool Creation & Structure: Creators define events with 2-10 distinct outcomes, each with descriptive names. The pool has three critical timestamps (block heights):

  • Start Block: When pool is created (automatic)
  • End Block: When betting closes
  • Settlement Block: Earliest block oracle can settle

This structure ensures predictable betting periods and prevents premature settlement.

Dynamic Odds Engine: Odds continuously recalculate with each new bet:

Current Odds = (Total Pool Across All Outcomes) / (Specific Outcome Pool)

As more money flows to an outcome, its odds decrease (less risky). Outcomes with fewer bets maintain higher odds (more risky, higher potential reward). This creates a self-balancing market where value-seekers naturally distribute bets across outcomes.

Incremental Staking: Unlike many betting contracts, this platform allows users to add to existing stakes:

  • Place initial 5 STX bet on Outcome A
  • Later add 3 more STX to same outcome
  • Total stake becomes 8 STX on Outcome A
  • User's average entry odds automatically calculated

This feature enables dollar-cost averaging strategies and responsive betting to odds changes.

Multi-Layer Pause System: The contract implements granular risk controls:

  1. Individual Pool Pause: Creator can pause their specific pool
  2. Global Emergency Pause: Contract owner can halt entire platform
  3. Automatic Resume: Pause can be lifted when issues resolved

This prevents common issues: suspicious activity, technical problems, disputed results, or platform-wide security concerns.

Key Features & Benefits

For Pool Creators:

  • Flexible Event Modeling: 2-10 outcomes accommodate simple or complex events
  • Oracle Control: Designate trusted settlement authority per pool
  • Pause Authority: Emergency control over your pool
  • Creative Freedom: Design any type of betting market
  • Transparent Operations: All activity visible on-chain

For Sophisticated Bettors:

  • Real-Time Odds: Calculate current odds before every bet
  • Payout Projections: See potential winnings before claiming
  • Multi-Outcome Exposure: Bet on multiple outcomes in same pool
  • Incremental Strategies: Add to positions as odds shift
  • Complete History: Track all your betting activity per pool

For Risk Managers:

  • Minimum Bet Enforcement: 1 STX minimum prevents dust attacks
  • Pause Mechanisms: Quick response to threats
  • Oracle Validation: Only authorized addresses settle
  • Block-Based Timing: Immutable, predictable deadlines
  • Claim Protection: Prevent double-withdrawal exploits

For Platform Operators:

  • Scalable Infrastructure: Handle unlimited concurrent pools
  • Emergency Controls: Platform-wide pause capability
  • Monitoring Tools: Query all pool statistics
  • Revenue Potential: Charge creation fees or take commission (extensible)

Advanced Capabilities

Complex Event Support:

Combat Sports Example:

Event: UFC Title Fight
Outcomes:
1. Fighter A by KO/TKO (shortest path to victory)
2. Fighter A by Submission (technical finish)
3. Fighter A by Decision (goes full distance)
4. Fighter B by KO/TKO
5. Fighter B by Submission
6. Fighter B by Decision
7. Draw (rare but possible)

Each outcome has independent odds based on bettor preferences, creating a rich, nuanced betting market.

Horse Racing Example:

Event: Kentucky Derby
Outcomes:
1. Horse #1 wins
2. Horse #2 wins
...
10. Horse #10 wins

Maximum 10-outcome support perfectly fits 10-horse fields, with odds dynamically adjusting based on public betting patterns.

Political Election Example:

Event: Primary Election
Outcomes:
1. Candidate A
2. Candidate B
3. Candidate C
4. Candidate D
5. Other/Field

Enables prediction markets on multi-candidate races with comprehensive outcome coverage.

Odds Calculation Deep Dive

Understanding the Mathematics:

The odds represent your multiplier if you win. Here's a detailed example:

Initial State:

  • Pool just created, no bets yet
  • All outcomes at theoretical infinite odds

After First Bets:

  • User A bets 10 STX on Outcome 1
  • User B bets 5 STX on Outcome 2
  • User C bets 5 STX on Outcome 3
  • Total Pool: 20 STX

Current Odds:

  • Outcome 1: 20 / 10 = 2.0x odds (2:1)
  • Outcome 2: 20 / 5 = 4.0x odds (4:1)
  • Outcome 3: 20 / 5 = 4.0x odds (4:1)

After More Bets:

  • User D bets 20 STX on Outcome 1
  • Total Pool now: 40 STX
  • Outcome 1 pool now: 30 STX

Updated Odds:

  • Outcome 1: 40 / 30 = 1.33x odds (1.33:1) - decreased!
  • Outcome 2: 40 / 5 = 8.0x odds (8:1) - increased!
  • Outcome 3: 40 / 5 = 8.0x odds (8:1) - increased!

The heavy bet on Outcome 1 made it less profitable while making other outcomes more attractive. This self-balancing mechanism encourages diverse betting.

Payout Calculation: If Outcome 2 wins:

  • User B bet 5 STX, total pool is 40 STX, Outcome 2 pool is 5 STX
  • User B's payout: (5 × 40) / 5 = 40 STX
  • User B's profit: 40 - 5 = 35 STX (7x profit)

Security Architecture

Access Control Matrix:

Function              | Pool Creator | Oracle | Contract Owner | Any User
---------------------|--------------|--------|----------------|----------
create-pool          |      ✓       |   ✓    |       ✓        |    ✓
place-stake          |      ✓       |   ✓    |       ✓        |    ✓
settle-pool          |      ✗       |   ✓    |       ✗        |    ✗
pause-pool           |      ✓       |   ✗    |       ✗        |    ✗
unpause-pool         |      ✓       |   ✗    |       ✗        |    ✗
emergency-pause      |      ✗       |   ✗    |       ✓        |    ✗
claim-winnings       |      ✓       |   ✓    |       ✓        |    ✓

Financial Safety:

  • All STX locked in contract until settlement
  • Only winners can withdraw funds
  • One claim per user per outcome
  • Mathematical guarantee all funds distributed

Timing Safety:

  • Block heights used (not manipulable timestamps)
  • Settlement only after settlement-block
  • Betting only before end-block
  • Predictable, verifiable deadlines

State Safety:

  • Settled pools cannot be re-settled
  • Claimed stakes cannot be re-claimed
  • Paused pools reject new bets
  • Invalid outcomes rejected

Real-World Applications

Sports Betting:

  • Multi-method combat sports (KO, submission, decision)
  • Horse/car racing with multiple competitors
  • Golf tournaments (top 10 finish betting)
  • Tennis matches (set score predictions)

Prediction Markets:

  • Political elections (multi-candidate races)
  • Award show winners (multiple categories)
  • Economic indicators (GDP growth ranges)
  • Corporate events (merger outcomes)

Entertainment:

  • Reality TV eliminations
  • Box office performance ranges
  • Music chart predictions
  • Social media trending predictions

Community & Social:

  • Local sports league outcomes
  • Office pool competitions
  • Charity event fundraising pools
  • Educational quiz competitions

Performance & Scalability

Gas Optimization:

  • Efficient storage structures minimize costs
  • Read-only functions for off-chain queries
  • Batch-friendly design (multiple users can stake simultaneously)
  • Minimal storage updates per transaction

Scalability Metrics:

  • Concurrent Pools: Unlimited (each independent)
  • Bettors per Pool: Unlimited (no artificial caps)
  • Outcomes per Pool: 2-10 (configurable at creation)
  • Stakes per User per Outcome: Unlimited (incremental betting)

Query Performance:

  • Instant odds calculation
  • Real-time payout projection
  • Efficient user history lookup
  • Fast pool statistics retrieval

Extensibility & Future Enhancements

Potential Upgrades: This contract architecture supports future extensions:

  • Commission Model: Add percentage fees to platform or creators
  • Liquidity Providers: Allow users to provide initial liquidity for odds stabilization
  • Outcome Combinations: Support betting on multiple outcomes simultaneously (accumulators)
  • Automated Oracles: Integrate Chainlink or other oracle networks
  • Cross-Pool Arbitrage: Enable betting across multiple related pools
  • Time-Weighted Odds: Early bettors receive bonus multipliers
  • Referral System: Reward users who bring new bettors
  • DAO Governance: Community control over platform parameters

Technical Specifications

Contract Limits:

  • Minimum bet: 1,000,000 microSTX (1 STX)
  • Maximum outcomes: 10 per pool
  • Outcome name length: 50 ASCII characters
  • Event name length: 100 ASCII characters
  • Description length: 200 ASCII characters

Precision:

  • Odds expressed in basis points (10000 = 1:1 odds)
  • All calculations use integer math (no decimals)
  • Rounding errors favor the pool (dust accumulates)

State Management:

  • Pool count tracked globally
  • User stakes tracked per (pool, outcome, user) tuple
  • User totals tracked per (pool, user) tuple
  • Outcome statistics tracked per (pool, outcome) tuple

Comparison with Traditional Betting

Advantages over Centralized Platforms:

  • ✅ Complete transparency (all bets visible)
  • ✅ Mathematical fairness (verifiable payouts)
  • ✅ Censorship resistance (permissionless participation)
  • ✅ Lower fees (no corporate overhead)
  • ✅ Trustless settlement (smart contract execution)

Advantages over Simple Blockchain Betting:

  • ✅ Multi-outcome support (beyond binary bets)
  • ✅ Dynamic odds (responsive to market demand)
  • ✅ Incremental betting (add to positions)
  • ✅ Risk management (pause controls)
  • ✅ Payout projections (informed decision-making)

Trade-offs:

  • ⚠️ Requires oracle trust (settlement centralization)
  • ⚠️ Gas costs (on-chain transactions)
  • ⚠️ Learning curve (blockchain interaction)
  • ⚠️ No customer support (decentralized)
  • ⚠️ Irreversible transactions (no refunds)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant