Skip to content

fix(screener): drop market_cap, which duplicated liquidity, and scope to one network - #195

Merged
Miracle656 merged 1 commit into
Miracle656:mainfrom
blockchain-maxis:fix/screener-market-cap
Sep 30, 2026
Merged

Miracle656 merged 1 commit into
Miracle656:mainfrom
blockchain-maxis:fix/screener-market-cap

Conversation

@blockchain-maxis

Copy link
Copy Markdown

closes #186

Summary

/screener returned COALESCE(pl.liquidity::float, 0) under both liquidity and market_cap, so sorting or filtering by market cap silently sorted or filtered liquidity. Lens has no circulating-supply data, so a real market cap can't be computed. Per the issue, the honest default is to remove it.

Changes

  • market_cap removed from the response, the sortBy allowlist, the filter set and the CTE.
  • ?market_cap= and ?sortBy=market_cap now return 400 with an explanation, rather than being silently ignored. An ignored filter would be another confidently wrong answer.
  • Network predicate (the gap the issue asks us to state): fixed, not just noted. All three CTEs (price_points, pool_snapshots, price_aggregates) now filter on network = $1, taken from req.network (?network= / x-network, default: active network). Before this, testnet and mainnet rows were pooled and a pair could be ranked on the other chain's data.
  • Tests: new src/__tests__/screener.test.ts (15 tests): no market_cap in the response, both 400s, sort direction and default, every filter bound to the right parameter, page size and cursor (keyset condition), malformed cursor, network scoping on all three CTEs, x-network, an unknown network, and a 500 that doesn't leak the error.
  • Changeset added per CONTRIBUTING (patch).

Docs

/screener and market_cap appear in neither README.md nor openapi.yaml/openapi.json (nor docs/ or clients/), so there was nothing to remove there. I did not add the route to the OpenAPI spec, to keep this PR to the issue.

Verification

Fork PRs run no CI here, so this was run locally:

  • npx tsc --noEmit: clean
  • npx vitest run src/__tests__/screener.test.ts: 15 passed
  • Against the original screener.ts, 7 of those 15 fail (the market_cap and network cases); the other 8 cover behaviour that was already correct
  • npx vitest run (full suite): 415 passed, 1 skipped, 0 failed

… to one network

/screener returned COALESCE(pl.liquidity, 0) under both liquidity and
market_cap, so sorting or filtering by market cap silently used
liquidity. Lens has no circulating-supply data, so remove the field from
the response, sort allowlist and filter set, and answer ?market_cap= and
sortBy=market_cap with a 400 instead of ignoring them.

The three CTEs also had no network predicate and pooled testnet and
mainnet rows. Scope them to req.network (default: active network).

Add route tests covering sort, filters, pagination, cursor and network.
@drips-wave

drips-wave Bot commented Sep 30, 2026

Copy link
Copy Markdown

@blockchain-maxis 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

@Miracle656
Miracle656 merged commit 9abd1f0 into Miracle656:main Sep 30, 2026
1 check passed
Miracle656 added a commit that referenced this pull request Sep 30, 2026
Every function in src/aggregator/vwap.ts now takes a required network and
filters price_points and pool_snapshots on it, getAMMPrice filters both
legs of its pool lookup, /price/:assetA/:assetB passes req.network through
to the aggregator, and the aggregate refresh worker runs once per enabled
network instead of pinning itself to whichever network the instance
happens to be indexing.

Merged locally: src/__tests__/price.test.ts conflicted only because #184
and 1c7e200 appended test blocks to the same tail; resolved as a union.
The README paragraph was corrected on merge — #195, #202 and #205 landed
network scoping for /screener, /pools, /depth and /prices/history after
this branch was written, so the list of still-unscoped endpoints was
stale.

Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB
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.

/screener reports liquidity twice, and calls one of them market cap

2 participants