[Contracts] Settle accrued amounts before modify_rate moves the accrual anchor
Overview & Background
modify_rate sets stream.rate_per_second = new_rate_per_second; stream.last_update_time = now; with no settlement of accrued amounts — directly contradicting the rationale documented in top_up_stream: "last_update_time is intentionally left untouched: it is the accrual anchor for calculate_claimable, and advancing it to now would discard any already-vested, unwithdrawn tokens." Anything vested but unclaimed at the moment of the rate change is folded back into the unstreamed remainder, so the recipient must wait for the new rate to re-accrue tokens that were already theirs. A sender can call modify_rate with rate 1 to arbitrarily defer vested wages. No test checks claimable continuity across the change.
Technical Specification & Architecture
- In
contracts/stream_contract/src/lib.rs:2768-2769, settle (withdraw or credit) the claimable amount before movinglast_update_time, mirroringtransfer_recipient's settle-then-handover flow (lib.rs:788-796). - Add tests asserting claimable continuity: tokens vested before the rate change remain claimable after it.
Target Files
contracts/stream_contract/src/lib.rscontracts/stream_contract/src/test.rs
Acceptance Criteria
- [ ] Vested-but-unclaimed tokens are not re-locked by a rate change.
- [ ]
calculate_claimableis continuous acrossmodify_rate. - [ ] Tests cover rate increase, decrease, and the rate-1 deflation attack.
@Kami-no-san has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
Hi Maintainer,
I’d like to take this on. I will update
modify_rateincontracts/stream_contract/src/lib.rsto settle accrued claimable tokens before advancinglast_update_time(following the settle-then-handover pattern intransfer_recipientso vested amounts aren't re-locked), and add tests incontracts/stream_contract/src/test.rsverifyingcalculate_claimablecontinuity across rate increases, decreases, and rate-1 deflation attempts.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @Kami-no-san to this issue.
@king-daveed has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
i can resolve
ℹ️ Repo Maintainers: To accept this application, review their application or assign @king-daveed to this issue.
Congratulations, @king-daveed! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @king-daveed: 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 @king-daveed as part of the Stellar Wave Program's 11th Wave 🥳
😎 @king-daveed: 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.