[Contracts] Fix hybrid-cliff tail rate computed from the wrong amount
Overview & Background
In create_hybrid_cliff_stream, the linear tail rate is computed as let linear_amount = net_amount - total_fee; — but net_amount is already the post-fee deposit (collect_fee defines net_amount = amount - total_fee). This double-deducts the fee and, worse, never subtracts cliff_unlock_amount. The doc comment and error docs both state the correct formula: (net - cliff) / linear_duration. With no fee configured the tail rate becomes net / duration instead of (net - cliff) / duration, so the drip pace and the emitted rate_per_second/end-time are materially wrong. The bug is masked by integer-division coincidences in tests (1000/400-cliff/600s gives 1/s under both formulas).
Technical Specification & Architecture
- In
contracts/stream_contract/src/lib.rs:1205-1206, change tolet linear_amount = net_amount - cliff_unlock_amount;. - Add a hybrid-cliff test with a non-divisible amount (e.g. 1000, cliff 200, duration 80) that asserts an intermediate claimable to lock the 10/s rate.
- Enable protocol fees in at least one hybrid-cliff test — the current suite never does, which is what hides this bug.
Target Files
contracts/stream_contract/src/lib.rscontracts/stream_contract/src/test.rs
Acceptance Criteria
- [ ] Tail rate equals
(net_amount - cliff_unlock_amount) / linear_duration. - [ ] A fee-enabled hybrid-cliff test asserts an intermediate claimable amount.
- [ ] Emitted
rate_per_secondand projected end time match the documented formula.
@SahheedTech has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
Hello maintainer, I would love to solve this pls assign
ℹ️ Repo Maintainers: To accept this application, review their application or assign @SahheedTech to this issue.
@wagmiiii has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
i can do it
ℹ️ Repo Maintainers: To accept this application, review their application or assign @wagmiiii to this issue.
Congratulations, @wagmiiii! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @wagmiiii: 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 marked as completed on GrantFox!
@wagmiiii's PR #1941 was approved and merged by @K1NGD4VID.
🏆 @wagmiiii: You earned 40 FoxPoints for this contribution! Your current tier: Builder (1,665 total points). Track your full progress on GrantFox.
👏 Great work, @wagmiiii! Keep contributing to LabsCrypt.
This issue has been completed by @wagmiiii as part of the Stellar Wave Program's 11th Wave 🥳
😎 @wagmiiii: 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.