Skip to content

fix: implement real parimutuel payout calculation in claim_winnings#339

Merged
hman38705 merged 2 commits intosolutions-plug:mainfrom
oncleweynom:fix/issue-91-parimutuel-distribution
Mar 27, 2026
Merged

fix: implement real parimutuel payout calculation in claim_winnings#339
hman38705 merged 2 commits intosolutions-plug:mainfrom
oncleweynom:fix/issue-91-parimutuel-distribution

Conversation

@oncleweynom
Copy link
Copy Markdown

Closes #194

  • Deduct protocol fee (calculate_tiered_fee) at bet placement time
  • Store net (post-fee) amount in bet.amount, total_staked, outcome_stakes
  • Parimutuel formula: winnings = (bet.amount * total_staked) / winning_outcome_stake
  • Fees are collected via collect_fee and withdrawable by admin
  • Referral rewards computed from actual fee charged
  • Resolve OracleConfig duplicate fields in types.rs
  • Add winner_counts and total_claimed fields to Market struct
  • Fix lib.rs: remove duplicate/broken function definitions, simplify initialize signature
  • Fix merge-conflict artifacts in bets_test.rs, test.rs, common/mod.rs
  • Fix integration_test.rs and lifecycle_test.rs call signatures
  • Update all affected test assertions to reflect net amounts

Fixes #91 winners now receive proportional share of the net pool. Example: 10 users bet 100 XLM each, 2 win -> each receives 500 XLM (0% fee).

Pull Request

📋 Description

Brief description of the changes in this PR.

🎯 Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Performance improvement
  • Code refactoring
  • Test addition/update
  • CI/CD update

🔗 Related Issues

Closes #(issue number)
Relates to #(issue number)

📝 Changes Made

  • Change 1
  • Change 2
  • Change 3

🧪 Testing

Test Coverage

  • Unit tests added/updated
  • Integration tests added/updated
  • All tests passing locally
  • Test coverage maintained/improved

Manual Testing

  • Tested on testnet
  • Tested locally
  • Edge cases tested

Test Results:

[Paste test output or describe manual testing performed]

📸 Screenshots (if applicable)

[Add screenshots for UI changes]

✅ Checklist

Code Quality

  • Code follows project style guidelines
  • Self-review completed
  • Comments added for complex code
  • No unnecessary console.log or debug code
  • No commented-out code

Documentation

  • Documentation updated (if needed)
  • API documentation updated (if applicable)
  • CHANGELOG.md updated
  • README updated (if needed)

Testing & Quality

  • All tests pass (cargo test)
  • No linting errors (cargo clippy)
  • Code formatted (cargo fmt)
  • No new warnings introduced
  • Gas benchmarks run (if applicable)

Security

  • Security implications considered
  • No sensitive data exposed
  • Input validation added
  • Authorization checks in place

Git

  • Branch is up to date with main
  • Commits are atomic and well-described
  • Commit messages follow convention
  • No merge conflicts

🔍 Reviewer Notes

[Any specific areas you'd like reviewers to focus on]

📊 Performance Impact

  • No performance impact
  • Performance improved
  • Performance impact acceptable (explain below)

Details:
[Describe any performance implications]

🚀 Deployment Notes

[Any special deployment considerations, migration steps, or configuration changes needed]

📚 Additional Context

[Add any other context about the PR here]


By submitting this PR, I confirm that:

  • I have read and followed the CONTRIBUTING.md guidelines
  • My code follows the project's coding standards
  • I have tested my changes thoroughly
  • I am ready for code review

- Deduct protocol fee (calculate_tiered_fee) at bet placement time
- Store net (post-fee) amount in bet.amount, total_staked, outcome_stakes
- Parimutuel formula: winnings = (bet.amount * total_staked) / winning_outcome_stake
- Fees are collected via collect_fee and withdrawable by admin
- Referral rewards computed from actual fee charged
- Resolve OracleConfig duplicate fields in types.rs
- Add winner_counts and total_claimed fields to Market struct
- Fix lib.rs: remove duplicate/broken function definitions, simplify initialize signature
- Fix merge-conflict artifacts in bets_test.rs, test.rs, common/mod.rs
- Fix integration_test.rs and lifecycle_test.rs call signatures
- Update all affected test assertions to reflect net amounts

Fixes solutions-plug#91  winners now receive proportional share of the net pool.
Example: 10 users bet 100 XLM each, 2 win -> each receives 500 XLM (0% fee).
@drips-wave
Copy link
Copy Markdown

drips-wave bot commented Mar 27, 2026

@oncleweynom Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@hman38705 hman38705 merged commit 676e20f into solutions-plug:main Mar 27, 2026
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.

Hardcoded Payout Ratio in claim_winnings Implement Comprehensive API Endpoint Tests

2 participants