Repository navigation
feat: GET /premium/:assetA/:assetB with staleness enforcement - #567
Conversation
|
@mansur-codes 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! 🚀 |
525bad5 to
9ed01ac
Compare
|
Merged into The staleness design is the good part. Three decisions worth naming:
One thing I added: the API-key scope. The route registered as: }>('/premium/:assetA/:assetB', async (req, reply) => {with no Worth knowing why this keeps happening: scope lives in the route's options object, which is easy to omit entirely when a handler is written straight after the path string. There is no test that fails when a route forgets one — #623 built exactly that guard for the GraphQL side (every field must declare a scope, enforced against the schema), and the REST side would benefit from the same thing. If you want a follow-up with real value, that is it: boot the app, enumerate registered routes, and fail when a non-internal one has no scope. It would have caught this, and it would have caught the five that #429 and #437 dropped earlier this week. A note on timing: Lens's Render service is suspended at the moment, so |
Summary
Adds
GET /premium/:assetA/:assetB— returns the most recent on-chain price and best CEX price for a pair, the spread in basis points, and both sources and timestamps. Refuses to answer when either side is older than a configurable staleness bound (PREMIUM_STALENESS_SECONDS), naming which side was stale. Network is required via?network=and validated on every request. OpenAPI spec updated and env drift guard satisfied.Related issue
Closes #217
Type of change
Checklist
npx tsc --noEmitpassesnpm run buildpasses