Skip to content

feat(realtime): add protocol.params validator and store - #415

Open
gbolly122 wants to merge 1 commit into
Refract-Protocol:mainfrom
gbolly122:feat/295-protocol-params
Open

gbolly122 wants to merge 1 commit into
Refract-Protocol:mainfrom
gbolly122:feat/295-protocol-params

Conversation

@gbolly122

Copy link
Copy Markdown

Summary

Adds the protocol.params snapshot topic validator and shared store for issue
#295. The payload is validated with a strict schema (partial or unknown keys are
rejected), applied as a last-write-wins snapshot guarded by version/timestamp
ordering, and exposed through helpers that clamp in-progress coverage/deposit
values when a pushed ceiling is lowered.

Closes #295

Type of change

  • New feature
  • Tests / CI

What changed

  • src/lib/realtime/protocolParameters.ts
    • ProtocolParametersSnapshot contract covering pool ceiling, protocol fee,
      LP premium share, supported risk classes, and per-class coverage limits.
    • validateProtocolParametersPayload strict runtime validation.
    • ProtocolParametersStore with applySnapshot, seedFromRest, and
      out-of-order/duplicate rejection.
    • evaluateInProgressForm for inline warnings and clamping.
  • src/lib/realtime/protocolParameters.test.ts
    • valid snapshot acceptance
    • partial/unknown-key rejection
    • ordering/duplicate handling
    • form clamp/warning behavior

Validation

npx vitest run src/lib/realtime/protocolParameters.test.ts
Test Files  1 passed (1)
Tests       2 passed (2)

Checklist

  • I read CONTRIBUTING.md
  • Tests added for the change
  • Full local gate — blocked by pre-existing main issues: 16 tracked files
    are 0 bytes and src/app/cover/page.tsx is truncated, so tsc/vitest fail
    on main before this change.
  • No secrets or env values committed
  • Behaviour documented in code comments and this PR

Notes for reviewers

This is the topic contract/validation/store layer. Page wiring (/cover,
/provide, landing stats) depends on the missing hooks/pages noted above; the
module is deliberately self-contained so it can merge independently of that
restoration work.

@drips-wave

drips-wave Bot commented Oct 21, 2026

Copy link
Copy Markdown

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

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 a Protocol Parameters and Coverage Limits Realtime Topic

1 participant