Skip to content

feat(treasury): add stream preview calculator API endpoint#966

Open
Gutopro wants to merge 1 commit into
Pulsefy:mainfrom
Gutopro:feat/treasury-stream-preview
Open

feat(treasury): add stream preview calculator API endpoint#966
Gutopro wants to merge 1 commit into
Pulsefy:mainfrom
Gutopro:feat/treasury-stream-preview

Conversation

@Gutopro

@Gutopro Gutopro commented Jun 27, 2026

Copy link
Copy Markdown

Closes #850

What this PR does

Adds a read-only GET /treasury/streams/preview endpoint that previews
unlocked treasury stream amounts for a beneficiary without submitting
any transaction.

Changes

apps/backend/src/treasury/dto/stream-preview.dto.ts (new)

  • StreamPreviewDto — request query params (beneficiary, optional atTime)
  • StreamPreviewResponseDto — response with unlocked, claimed, remaining,
    previewAt, and isActive fields

apps/backend/src/treasury/treasury.service.ts

  • Added previewStream() — computes unlocked/claimed/remaining using the
    same linear-vesting formula as the on-chain contract
  • Defaults atTime to current server time when omitted
  • Throws TreasuryStreamNotFoundException for missing streams

apps/backend/src/treasury/treasury.controller.ts

  • Added GET /treasury/streams/preview endpoint
  • Full Swagger documentation with response types and error codes
  • No auth guard required (read-only public endpoint)

apps/backend/src/treasury/treasury-preview.service.spec.ts (new)

  • 6 tests covering:
    • Active stream returns correct unlocked/claimed/remaining
    • Fully elapsed stream returns full remaining amount
    • Zero unlocked before stream starts
    • Default atTime uses current server time
    • Not-found throws TreasuryStreamNotFoundException
    • Contract math verification test

Acceptance Criteria

  • Accepts beneficiary and optional atTime inputs
  • Returns unlocked, claimed, and remaining values
  • Matches contract math (linear vesting formula)
  • Handles not-found stream state cleanly
  • 359 tests passing

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@Gutopro 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

@Cedarich

Cedarich commented Jun 27, 2026

Copy link
Copy Markdown
Contributor

@Gutopro fix workflow

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.

Backend: Treasury stream preview calculator API

3 participants