Skip to content

Correct Non-Parimutuel Payout Logic #110

@hman38705

Description

@hman38705

issues : 2

Great issue: Correct Non-Parimutuel Payout Logic

Description
The implementation in claim_winnings contains let winnings = bet.amount;, which only returns the user's original stake upon winning. The core value proposition of a prediction market—where winners split the pool of losers—is broken, leading to "trapped" capital (losers' stakes) that can never be claimed and removing all financial incentive for participation.

Requirements and context

  • Implement pool-ratio based payout math: winnings = (bet.amount * total_staked) / winning_outcome_stake.
  • Ensure rounding favors the protocol (e.g., truncate down).
  • Must be efficient and easy to review.

Suggested execution

  • Fork the repo and create a branch: git checkout -b fix/issue-2-payout-math
  • Implement the parimutuel formula in the winnings calculation.

Implementation changes

  • Update bets.rs (around line 140) to calculate proportional winnings instead of returning the stake.

Test and commit

  • Run tests with varied stake amounts to ensure correct distribution.
  • Validate that the total balance of the contract remains consistent after all claims.

Example commit message
fix: implement parimutuel payout logic in claim_winnings

Guidelines

  • Clear documentation for mathematical assumptions.
  • Timeframe: 72 hours.

Metadata

Metadata

Assignees

Labels

Stellar WaveIssues in the Stellar wave program

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions