flowfi icon indicating copy to clipboard operation
flowfi copied to clipboard

[Contracts] Add get_remaining_balance(stream_id) read-only view function to stream contract

Open blurbeast opened this issue 1 month ago • 5 comments

Overview

Callers inspecting a stream via contracts/stream_contract/src/lib.rs can query get_stream(stream_id) and get_claimable(stream_id), but there is no direct view helper to query the unwithdrawn remaining token balance (deposited_amount - withdrawn_amount).

Problem

  • External contracts and off-chain clients frequently need a lightweight read call to check how many tokens remain locked in a stream.

Proposed Changes

  1. Add pub fn get_remaining_balance(env: Env, stream_id: u64) -> Result<i128, ContractError> to StreamContract in contracts/stream_contract/src/lib.rs.
  2. Return 0 if the stream is already cancelled/completed, or stream.deposited_amount.saturating_sub(stream.withdrawn_amount).

Acceptance Criteria

  • [ ] Returns accurate remaining balance before, during, and after partial withdrawals.
  • [ ] Returns ContractError::StreamNotFound for non-existent stream IDs.
  • [ ] Unit test added in contracts/stream_contract/src/test.rs.

blurbeast avatar Oct 18 '26 05:10 blurbeast

@elonwachineke-dot has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello maintainer please kindly review my application and assign this issues to me and I will deliver as soon as possible

ℹ️ Repo Maintainers: To accept this application, review their application or assign @elonwachineke-dot to this issue.

elonwachineke-dot avatar Oct 18 '26 11:10 elonwachineke-dot

@Holer8 has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hello Maintainer, I’ve reviewed the issue description and I’m confident I can work on it effectively. Please assign it to me.

ℹ️ Repo Maintainers: To accept this application, review their application or assign @Holer8 to this issue.

Holer8 avatar Oct 18 '26 11:10 Holer8

@ngoziimmaculatar-star has applied to work on this issue as part of the Stellar Wave Program's 10th wave.

Hi Maintainer, I'd like to work on this issue. Could you assign it to me?

ℹ️ Repo Maintainers: To accept this application, review their application or assign @ngoziimmaculatar-star to this issue.

ngoziimmaculatar-star avatar Oct 18 '26 11:10 ngoziimmaculatar-star

Congratulations, @ngoziimmaculatar-star! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on October 22, 2026.

🧑‍💻 @ngoziimmaculatar-star: 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 🌊

drips-wave[bot] avatar Oct 18 '26 11:10 drips-wave[bot]

This issue has been completed by @ngoziimmaculatar-star as part of the Stellar Wave Program's 10th Wave 🥳

😎 @ngoziimmaculatar-star: 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.

drips-wave[bot] avatar Oct 20 '26 04:10 drips-wave[bot]