feat(#386): add aggregateStreams utility for cross-stream analytics - #500
Merged
Chuks-coderr merged 2 commits intoAug 27, 2026
Merged
Chuks-coderr merged 2 commits into
Chuks-coderr merged 2 commits into
Conversation
…nalytics
Adds aggregateStreams(streams[]) which computes:
- totalValueLocked: sum of remaining active stream deposits (in stroops)
- averageRate: mean flow rate across active streams (stroops/sec)
- statusBreakdown: { active, cancelled, completed } counts
TVL reflects currently locked tokens by subtracting the already-
released amount (flowRate x elapsed) from each active stream's
deposit. Elapsed is capped at endTime to handle completed/expired
active streams correctly.
Also includes co-shipped changes for issues SoroStream#385, SoroStream#387, SoroStream#388 in the
same set of source files.
Closes SoroStream#386
|
@boseshittu2323-design 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! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements the
aggregateStreams(streams[])utility function as described in issue #386.Computes cross-stream analytics across any set of streams:
totalValueLocked— sum of remaining active stream deposits in stroops (TVL)averageRate— mean flow rate across all active streams in stroops/secondstatusBreakdown—{ active, cancelled, completed }counts for the whole setTVL is computed by subtracting already-released tokens (
flowRate × elapsed) from each active stream's deposit. Elapsed is capped atendTimeto correctly handle streams that have run past their end.Changes
src/types.ts: AddedStreamsAggregateinterfacesrc/utils.ts: ImplementedaggregateStreams()src/index.ts: ExportedaggregateStreamsandStreamsAggregatetest/issues_385_386_387_388.test.ts: 6 test cases covering empty list, TVL computation, status breakdown, already-streamed subtraction, and averageRate fallbackTesting
Closes #386