-
Notifications
You must be signed in to change notification settings - Fork 30
Open
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave program
Description
Description
In high-inflation or large-pool scenarios, multiplying bet.amount * total_staked (from the planned fix in Issue 2/42) or related reward calculations could overflow i128. While i128 is massive, safe-math patterns are non-negotiable in financial smart contracts to prevent catastrophic accounting failures.
Requirements and context
- Use
checked_mulandchecked_divfor all payout and stake calculations. - Fail gracefully with clear error codes on overflow.
Suggested execution
- Fork the repo and create a branch:
git checkout -b fix/issue-89-safe-math - Globally refactor arithmetic in the rewards module.
Implementation changes
- Modify
bets.rs(around the payout logic) to use Soroban's safe math utilities.
Test and commit
- Verify that extremely large pool sizes do not cause unexpected transaction failures.
Example commit message
fix: implement checked math for all pool-ratio payout calculations
Guidelines
- Arithmetic safety.
- Timeframe: 24 hours.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Stellar WaveIssues in the Stellar wave programIssues in the Stellar wave program