Repository navigation
Description
Background
GET /compare/:asset/summary?window=7d reports how far Lens was from an oracle over a window: mean deviation, worst deviation, and time spent outside a band. GET /compare/:asset/history returns the samples themselves. Both are in src/routes/oracle.ts.
Both read their samples through queryOracleComparisonHistory with a limit that defaults to 1000 (src/routes/oracle.ts line 114). The query ends with (src/services/oracleComparison.ts line 300):
ORDER BY timestamp ASC LIMIT $nSo when a window holds more than 1,000 samples, the summary is computed from the oldest 1,000 and the rest are ignored. Nothing in the response says the data was cut. samples reads 1000 and freshestComparison is an old timestamp, which a careful reader might notice. Most will not.
The cut also breaks one figure outright. computeOracleSummaryStatistics treats the last sample it was given as lasting until the end of the window (src/services/oracleComparison.ts, the nextTime = Math.min(Date.now(), windowEnd.getTime()) branch near line 379). If the 1,000th sample is outside the band, all the time between it and the end of the window is counted as "outside the band", even though thousands of unread samples cover that time.
/history has the matching problem: it returns the oldest rows first, has no cursor, and gives no sign that more exist. A client cannot reach the newest data in a busy window except by guessing from.
What to build
- The summary must describe the whole window. Aggregate in SQL, or read the window in pages. Do not compute a summary from a silently cut list.
- If you keep any cap, the response must say so: a
truncatedflag and the number of samples used. - Fix the last-sample rule so a cut list can never inflate
timeOutsideBandSeconds. - Decide what
limitmeans on/summary. If it has no meaning there, remove it from the route and the spec. - Make
/historypageable with the helpers insrc/pagination.ts(parseLimit,encodeCursor,decodeCursor,slicePage): addnextCursorandhasMore, as/poolsand/pairsdo. Keep thepointskey. - Update
openapi.yamlfor both routes and regenerate.
Where to look
src/routes/oracle.tslines 26 to 134 and 176 to 269src/services/oracleComparison.tsqueryOracleComparisonHistory(line 269) andcomputeOracleSummaryStatistics(line 321)src/pagination.ts, andsrc/routes/pools.tslines 59 to 121 for a route that uses itsrc/__tests__/oracleHistory.test.ts
Done when
- A test with more samples than the old limit shows the summary uses all of them, or reports
truncated: truewith the count - A test shows
timeOutsideBandSecondsis not inflated when the last sample read is outside the band and later samples exist -
/compare/:asset/historyreturnsnextCursorandhasMore, and a test pages through a window without a duplicate or a gap - The existing oracle history tests pass, or each change is explained
-
openapi.yamlis updated and the generated files are regenerated -
npx tsc --noEmitandnpm testpass
Drips Wave · Complexity: Intermediate · 150 points
Repo: Divinity-Labs/Lens. Install with npm ci, typecheck with npx tsc --noEmit, test with npm test. Tests are vitest. Do not run jest: it reports zero tests and proves nothing.
You cannot reach the production service. Prove your change with local tests and fixtures. Mock the database (pgPool, prisma) the way the existing tests in src/__tests__/ and tests/ do.
Generated files are checked byte for byte by CI. If you add or change a route, edit openapi.yaml by hand and then regenerate the generated files and commit them: npm run openapi:gen (writes openapi.json and the README sections), npm run client:gen (the TypeScript client schema) and, if you touched the GraphQL schema, npm run graphql:schema:gen (writes schema.graphql). The full list is in the scripts section of package.json; also read CONTRIBUTING.md. If a check fails and the diff looks empty, it is line endings: commit with LF.
Prices are high-precision decimals. Do not add a new place where a price or amount goes through parseFloat, Number() or ::float before it reaches the caller.
MCP tools must return exactly the fields the matching REST route returns (tests/mcp-lens.test.ts asserts equality), and the MCP tool modules must not import the database driver directly. Reads are injected.
Do not remove or loosen an existing API-key scope, CORS rule or rate limit, and do not replace src/app.ts wholesale. Past pull requests did both by accident.
Do not weaken a test to make it pass. No real user data, wallet addresses of real users, keys, tokens or connection strings in code, tests or fixtures. Never shorten a Stellar address or contract id; copy it in full from the file that defines it.
Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk
Activity
AbuJulaybeeb commentedon Nov 22, 2026
@AbuJulaybeeb has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @AbuJulaybeeb to this issue.
drakep commentedon Nov 22, 2026
@drakep has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @drakep to this issue.
ibochielizabeth-spec commentedon Nov 22, 2026
@ibochielizabeth-spec has applied to work on this issue as part of the Stellar Wave Program's 11th wave.
ℹ️ Repo Maintainers: To accept this application, review their application or assign @ibochielizabeth-spec to this issue.
drips-wave commentedon Nov 24, 2026
Congratulations, @ibochielizabeth-spec! 🎉 Your application was accepted by the repo's maintainers, and the issue is due on November 25, 2026.
🧑💻 @ibochielizabeth-spec: Please resolve the issue such that the repo's maintainers have enough time to review your contribution before the due date. You'll earn Points for completing the issue on-time, which will make you eligible for a share of the Stellar Wave Program's reward pool.
Warning
When opening a PR, please link it to this issue to ensure it gets tracked accurately. Points are awarded when this issue is marked as completed by the maintainer.
🤠 Repo maintainers: Please keep an eye on the contributor's progress and review their work before the due date. You can manage this issue, including adjusting its complexity and points, here.
🌊 Happy Wave 🌊