Skip to content

fix(contracts): implement market resolution payout value conservation - #2073

Merged
Olowodarey merged 2 commits into
Arena1X:mainfrom
Toromo7:feature/open-market-payout-resolution
Oct 20, 2026
Merged

Olowodarey merged 2 commits into
Arena1X:mainfrom
Toromo7:feature/open-market-payout-resolution

Conversation

@Toromo7

@Toromo7 Toromo7 commented Oct 20, 2026

Copy link
Copy Markdown
Contributor
  • Add compute_payout_breakdown() helper function with checked arithmetic
  • Update claim_payout() to use centralized payout calculation
  • Ensure payouts + fees == pool within documented tolerance (±N stroops)
  • Add comprehensive test suite with 9 test cases covering:
    • Value conservation verification
    • Single winner and multiple winners scenarios
    • Fully one-sided markets (all on winning side)
    • Edge cases: large stakes, small stakes, many winners
    • Batch distribution value conservation
  • Document implementation details and mathematical proof

Resolves value conservation requirement where sum of all payouts plus fees must equal the market's total pool within rounding tolerance. Uses checked arithmetic throughout to prevent overflow.

Files changed:

  • contracts/open-market/src/prediction.rs
  • contracts/open-market/tests/payout_conservation_tests.rs (new)
  • contracts/open-market/PAYOUT_CONSERVATION_IMPLEMENTATION.md (new)

closes #2029

- Add compute_payout_breakdown() helper function with checked arithmetic
- Update claim_payout() to use centralized payout calculation
- Ensure payouts + fees == pool within documented tolerance (±N stroops)
- Add comprehensive test suite with 9 test cases covering:
  * Value conservation verification
  * Single winner and multiple winners scenarios
  * Fully one-sided markets (all on winning side)
  * Edge cases: large stakes, small stakes, many winners
  * Batch distribution value conservation
- Document implementation details and mathematical proof

Resolves value conservation requirement where sum of all payouts
plus fees must equal the market's total pool within rounding tolerance.
Uses checked arithmetic throughout to prevent overflow.

Files changed:
- contracts/open-market/src/prediction.rs
- contracts/open-market/tests/payout_conservation_tests.rs (new)
- contracts/open-market/PAYOUT_CONSERVATION_IMPLEMENTATION.md (new)
@vercel

vercel Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
insight-arena-4rll Error Error Oct 20, 2026 11:13am UTC

@drips-wave

drips-wave Bot commented Oct 20, 2026

Copy link
Copy Markdown

@Toromo7 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

- Removed duplicate function definition that was causing compile error
- Added comprehensive documentation to the original function
- Kept value conservation logic intact with checked arithmetic
- Fixes: duplicate definitions compile error in prediction.rs
@Olowodarey
Olowodarey merged commit ec9c536 into Arena1X:main Oct 20, 2026
2 of 5 checks passed

This branch had an error being deployed

1 failed deployment
Preview — e81f3b96 Deployed Oct 20, 2026 by vercel[bot]
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.

[Contract] — Open Market Resolution Payout Conservation

2 participants