[Contracts] Fix fee-split truncation that permanently strands dust in the contract
Overview & Background
Per-recipient fee splits are computed as split_amount = total_fee * share_bps / 10_000 (truncated), and tiny shares are dropped entirely (if split_amount > 0), while the stream is credited only the full-fee remainder. The sum of split payouts can be strictly less than total_fee (e.g. 1000 split three ways at 3333 bps pays 333×3 = 999). The 1-unit difference is deducted from the stream deposit but paid to nobody — it accumulates as unaccounted tokens locked in the contract forever. Separately, splits.iter().map(|s| s.share_bps).sum() in configure_protocol_fees can panic on u32 overflow under overflow-checks instead of returning InvalidFeeSplit.
Technical Specification & Architecture
- In
contracts/stream_contract/src/lib.rs:3046-3056, assign the division remainder (e.g.total_fee - sum(split_amounts)to the first recipient). - Use checked addition when summing
share_bpsinconfigure_protocol_fees(lib.rs:176) and returnInvalidFeeSpliton overflow/over-10000. - Add a split-fee test asserting the sum of payouts equals
total_feeexactly.
Target Files
contracts/stream_contract/src/lib.rscontracts/stream_contract/src/test.rs
Acceptance Criteria
- [ ] Sum of fee-split payouts always equals
total_feeexactly (no stranded dust). - [ ] Overflowing
share_bpssums returnInvalidFeeSplitinstead of panicking. - [ ] Tests cover non-divisible splits (e.g. 3-way 3333 bps).
@abdulqudus-dev has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
Hi, I'd like to work on this project,, please assign me this issue for a quick fix
ℹ️ Repo Maintainers: To accept this application, review their application or assign @abdulqudus-dev to this issue.
@abrcrmb has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
i’ve got this boss
ℹ️ Repo Maintainers: To accept this application, review their application or assign @abrcrmb to this issue.
Congratulations, @abrcrmb! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @abrcrmb: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
[!WARNING] When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊
This issue has been completed by @abrcrmb as part of the Stellar Wave Program's 11th Wave 🥳
😎 @abrcrmb: You earned 200 Points for completing this issue! Once the Wave's rewards are finalized, you'll be eligible for a percentage of the Wave's reward pool based on the percentage of total points you've earned. Learn more here. You can also Leave a review to share your experience working on this issue.
🧑💻 Repo maintainers: How'd the contributor do? Leave a review to share your experience working with them.