fix(routes): scope single-market queries by network - #204
Conversation
|
@Bayyan16 is attempting to deploy a commit to the Khubair Nasir's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
Warning Review limit reached
More reviews will be available in 59 minutes and 18 seconds. Learn how PR review limits work. Your organization has used up its prepaid credits, and credit purchases are no longer available. Enable the review add-on in the billing tab to keep reviews running — you're only billed for reviews past your plan's rate limits ($0.25/file). ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits. 🚦 How do rate limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
CI note: the current The error is: ENOENT: no such file or directory, scandir '/home/runner/work/percolator-sdk'This appears to be caused by the existing local SDK dependency: "@percolatorct/sdk": "file:../../percolator-sdk"The GitHub Actions workflow checks out only The route fix itself was validated locally with: pnpm exec vitest run tests/routes/funding.test.ts tests/routes/open-interest.test.ts tests/routes/insurance.test.ts tests/routes/markets.test.tsResult: Test Files 4 passed
Tests 75 passedSo this PR’s code changes are scoped to #192, while the current CI install failure appears to be a pre-existing workflow/dependency resolution issue unrelated to the route changes. |
Summary
Fixes #192.
This PR scopes single-market DB-backed route queries by the active configured network to prevent cross-network slab collisions.
Previously, several single-market endpoints queried
market_statsbyslab_addressonly. If the same slab address exists across networks, for example devnet and mainnet, the API could resolve the wrong row or return an incorrect 404 depending on which database row was matched first.This PR adds
network = getNetwork()filtering to the affected single-market lookups so each route resolves market data only for the active deployment network.Fixed routes
This PR updates the following single-market route lookups:
GET /funding/:slabGET /open-interest/:slabGET /insurance/:slabmarketsroutesThe route queries now scope
market_statslookups with both:Why this is needed
Single-market endpoints should be deterministic for the currently configured network.
Querying only by
slab_addressis not sufficient when the same slab address can exist on multiple networks. In a shared database containing rows from more than one network, a slab-only query can cause:Adding the
networkfilter ensures the API only returns data from the active configured network.Test updates
The affected tests were updated to match the new query chain:
Test mocks now include:
The Supabase mocks were also cleaned up so they support chained
.eq()calls consistently.Validation
Ran the affected route test suite:
pnpm exec vitest run tests/routes/funding.test.ts tests/routes/open-interest.test.ts tests/routes/insurance.test.ts tests/routes/markets.test.tsResult:
Also verified the PR only changes the intended route and test files.