Repository navigation
feat: add GET /pegs route for comparative peg deviation monitoring - #353
Open
decrypted-dev wants to merge 2 commits into
Open
decrypted-dev wants to merge 2 commits into
decrypted-dev wants to merge 2 commits into
Conversation
|
@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! 🚀 |
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.
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.