Skip to content

feat: add GET /pegs route for comparative peg deviation monitoring - #353

Open
decrypted-dev wants to merge 2 commits into
Divinity-Labs:mainfrom
decrypted-dev:feat/pegs-route
Open

decrypted-dev wants to merge 2 commits into
Divinity-Labs:mainfrom
decrypted-dev:feat/pegs-route

Conversation

@decrypted-dev

Copy link
Copy Markdown
Contributor

Closes #287

Summary of Changes
Config & Types (src/config.ts):
Added PeggedAssetConfig interface (asset, target, targetPrice, windowHours).
Added parsing and resolution logic for PEGGED_ASSETS_TESTNET, PEGGED_ASSETS_MAINNET, and fallback PEGGED_ASSETS.
Explicit target and peg target prices are configured without guessing from tickers.
Preserves complete 56-character contract IDs / issuer addresses.
GET /pegs Route (src/routes/pegs.ts):
Queries and returns all configured pegged assets in a single response.
Calculates currentPrice, currentDeviationBps, and worstDeviationBps over the configured window.
Unconfigured assets are absent from the response (not reported as zero).
Reports full provenance for each figure: venues, sample count, freshness in seconds, and latest sample timestamp.
Honest representation when there is no liquidity/data: returns null rather than 0 or 500.
Reads req.network ?? activeNetwork, filters queries strictly by network, and echoes network in the response.
OpenAPI Specification & Schemas (openapi.yaml, openapi.json, src/api/schemas.ts):
Declared /pegs route with ?network= parameter and detailed schema definitions (PegReport, PegsResponse).
Synced with openapi.json via the generator script.
Environment & Documentation (.env.example, README.md, .changeset):
Added PEGGED_ASSETS_TESTNET, PEGGED_ASSETS_MAINNET, and PEGGED_ASSETS to .env.example passing the env-drift guard.
Documented /pegs in README.md and created a changeset.
Testing (src/tests/pegs.test.ts):
Verified that all acceptance criteria are met, including network parameter honoring, provenance reporting, omission of unconfigured assets, and honest null-handling for illiquid pairs.
All tests passing with vitest.

@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@decrypted-dev 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.

Stablecoin pegs are checked one asset at a time

1 participant