Skip to content

feat: add streamedTotalLocal and sumStreamedTotal utils - #886

Merged
Jaydbrown merged 2 commits into
conduit-protocol:mainfrom
Yerimahjr:feat/streamed-total-local
Oct 1, 2026
Merged

Jaydbrown merged 2 commits into
conduit-protocol:mainfrom
Yerimahjr:feat/streamed-total-local

Conversation

@Yerimahjr

Copy link
Copy Markdown
Contributor

Summary

Adds streamedTotalLocal(stream, nowSec?) and sumStreamedTotal(streams, nowSec?) to src/utils.ts, the client-side counterparts of StreamsModule.streamedTotal(), mirroring the existing withdrawableLocal / sumWithdrawable pair.

Closes #796

Changes

  • streamedTotalLocal: cumulative amount streamed from a StreamInfo snapshot, with the same endTime-then-pausedAt clamp order as withdrawableLocal. Unlike withdrawableLocal, withdrawn is not subtracted, so the value keeps counting up after withdrawals.
  • sumStreamedTotal: sums streamedTotalLocal across streams.
  • Exported from the package root and /utils; documented in docs/api.md and CHANGELOG.md.
  • Tests in src/tests/utils.test.ts, including a consistency check that streamedTotalLocal(s) - withdrawn matches withdrawableLocal(s) so the two can't drift apart.

Design note: cancelled streams

StreamInfo has no cancellation timestamp, so the amount streamed up to a cancel can't be projected locally. A cancelled stream reports its withdrawn amount (a lower bound that never overstates) instead of continuing to accrue. withdrawableLocal returns 0 for cancelled streams, but 0 would drop already-streamed amounts from a "total streamed" display. Happy to change this if the contract's streamed_total behaves differently after cancellation.

Testing

  • src/tests/utils.test.ts: 94 passing (19 new).
  • tsc --noEmit clean; eslint on the changed files has no new findings.
  • Unrelated pre-existing failures in factory.test.ts, governor.test.ts and relayer-stress.test.ts (8 tests) occur identically on a clean upstream/main.

@drips-wave

drips-wave Bot commented Sep 29, 2026

Copy link
Copy Markdown

@Yerimahjr Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@Jaydbrown
Jaydbrown merged commit 0382f66 into conduit-protocol:main Oct 1, 2026
1 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add streamedTotalLocal/sumStreamedTotal utils mirroring the existing withdrawableLocal/sumWithdrawable

2 participants