Skip to content

feat(#386): add aggregateStreams utility for cross-stream analytics - #500

Merged
Chuks-coderr merged 2 commits into
SoroStream:mainfrom
boseshittu2323-design:feat/386-aggregate-streams
Aug 27, 2026
Merged

Chuks-coderr merged 2 commits into
SoroStream:mainfrom
boseshittu2323-design:feat/386-aggregate-streams

Conversation

@boseshittu2323-design

Copy link
Copy Markdown
Contributor

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/second
  • statusBreakdown{ active, cancelled, completed } counts for the whole set

TVL is computed by subtracting already-released tokens (flowRate × elapsed) from each active stream's deposit. Elapsed is capped at endTime to correctly handle streams that have run past their end.

Changes

  • src/types.ts: Added StreamsAggregate interface
  • src/utils.ts: Implemented aggregateStreams()
  • src/index.ts: Exported aggregateStreams and StreamsAggregate
  • test/issues_385_386_387_388.test.ts: 6 test cases covering empty list, TVL computation, status breakdown, already-streamed subtraction, and averageRate fallback

Testing

npx vitest run test/issues_385_386_387_388.test.ts
# 24 tests pass

Closes #386

…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
@drips-wave

drips-wave Bot commented Aug 26, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

@Chuks-coderr
Chuks-coderr merged commit ed25612 into SoroStream:main Aug 27, 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 stream analytics aggregation helper

2 participants