Skip to content

Feat/screener liquidity definition - #354

Merged
Miracle656 merged 1 commit into
Divinity-Labs:mainfrom
decrypted-dev:feat/screener-liquidity-definition
Oct 23, 2026
Merged

Miracle656 merged 1 commit into
Divinity-Labs:mainfrom
decrypted-dev:feat/screener-liquidity-definition

Conversation

@decrypted-dev

Copy link
Copy Markdown
Contributor

Closes #283

Summary

Defines liquidity in the OpenAPI spec and route documentation, validates that the underlying query calculation matches the definition, and names the unit in the response.

Details & Specification

  • Definition: For each watched pair on the selected network, liquidity represents total AMM reserves denominated in the quote/counter asset (asset_b), computed across all active liquidity pools (source = 'AMM') as:
    $$\sum (\text{reserve_a} \times \text{spot_price} + \text{reserve_b})$$
    evaluated at each pool's latest snapshot spot price.
  • Unit: Denominated in the quote asset (asset_b), exposed explicitly as liquidity_unit on each row (e.g., USDC for XLM/USDC).
  • Network Scoping: Echoes network in the top-level /screener response and documents ?network= in openapi.yaml and openapi.json.
  • Number Changes: No numeric change was required to the stored calculation, as (ps.reserve_a * ps.spot_price + ps.reserve_b) already faithfully evaluates total liquidity in units of asset_b.

Verification

  • npm test src/__tests__/screener.test.ts: Passes all 18 tests, including tests verifying the SQL formula structure and liquidity_unit naming.
  • npm test tests/openapi.test.ts: Passes and verifies OpenAPI parity.
  • npm test: Full test suite passes (631 passed).

@drips-wave

drips-wave Bot commented Oct 16, 2026

Copy link
Copy Markdown

@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! 🚀

Learn more about application limits

Miracle656 added a commit that referenced this pull request Oct 22, 2026
  tsc --noEmit   clean
  vitest         97 files, 1127 passing (up from 93 / 1068)
  dropped-tests  none

  #325  GET /movers for market gainers and losers
  #327  GET /correlation for basket construction
  #485  net arbitrage spread against fees
  #494  declare the resources capability and expose pages over MCP

Two fixes on merge.

#325 shipped the route file and the OpenAPI entry but never registered it.
The repo's own guard caught it:

  AssertionError: Documented but unregistered: ["GET /movers"]

So the endpoint was documented, generated into clients, and did not exist.
registerMoversRoutes already followed the house signature, so wiring it was an
import and a call next to registerScreenerRoutes. That guard is worth its
weight -- a documented route that 404s is worse than an undocumented one,
because a client is generated against it.

#327 added a console.error to src/routes/correlation.ts, which the logging
hygiene test forbids. Now createLogger, the same change #388 and #318 needed
in the previous batch. Three PRs in two batches have tripped that test, which
suggests the rule is not discoverable enough from the outside -- worth a line
in CONTRIBUTING rather than catching it per-PR.

NOT merged, each failing on its own branch rather than from merge order:
  #460  Phoenix AMM adapter -- 5 failures alone, including its own
        networkVenueConfig and venues/registry tests
  #353  1 tsc error     #354  1 tsc error     #482  4 tsc errors
  #393 #431 #434 #472 conflict

Claude-Session: https://claude.ai/code/session_01USgemLt4Rnz4SGB1Srf3GB

@Miracle656 Miracle656 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Screened against current main and this does not pass on its own branch, so a rebase alone will not fix it.

Merged alone it gives type errors against main. Run npx tsc --noEmit on a fresh rebase and you will see them.

Please rebase, get npx tsc --noEmit and npx vitest run both clean locally, and re-request. I would rather take this than not — it is held on correctness, not on wanting it.

@decrypted-dev
decrypted-dev force-pushed the feat/screener-liquidity-definition branch from ab6c9da to 41e6181 Compare October 22, 2026 13:51
@decrypted-dev

Copy link
Copy Markdown
Contributor Author

Screened against current main and this does not pass on its own branch, so a rebase alone will not fix it.

Merged alone it gives type errors against main. Run npx tsc --noEmit on a fresh rebase and you will see them.

Please rebase, get npx tsc --noEmit and npx vitest run both clean locally, and re-request. I would rather take this than not — it is held on correctness, not on wanting it.

done boss
please review and merge

@decrypted-dev

Copy link
Copy Markdown
Contributor Author

Screened against current main and this does not pass on its own branch, so a rebase alone will not fix it.

Merged alone it gives type errors against main. Run npx tsc --noEmit on a fresh rebase and you will see them.

Please rebase, get npx tsc --noEmit and npx vitest run both clean locally, and re-request. I would rather take this than not — it is held on correctness, not on wanting it.

review and merge boss

@Miracle656
Miracle656 merged commit c9ed2d3 into Divinity-Labs:main Oct 23, 2026
0 of 2 checks passed
@Miracle656

Copy link
Copy Markdown
Collaborator

Merged to main as c9ed2d3. The earlier type errors are gone and it's clean against current main.

This is a better change than its title suggests. /screener was reporting a liquidity number with no stated unit, source or formula — which makes it uninterpretable: a consumer can't tell whether two rows are comparable, or even what currency the figure is in.

Putting liquidity_unit on each row is the part that matters. Documenting the definition in a comment helps whoever reads the source; shipping the unit with the data helps everyone who doesn't. Naming the network in the response is the same instinct.

The formula comment is correct, which I checked because this is exactly the kind of note that gets written down wrong. spot_price is asset_b per asset_a, so reserve_a * spot_price is reserve_a valued in asset_b — and for a constant-product pool that equals reserve_b, making the sum the whole pool's value in quote terms rather than a double count. Deriving the unit from pair_key.split('/')[1] with a 'quote' fallback is a reasonable way to get there without a second query.

One thing I did on merge: regenerated clients/typescript/src/schema.d.ts. Since #403 landed earlier today, any PR touching openapi.yaml also has to update the generated client or CI's git diff --exit-code -- clients/typescript fails. Worth knowing for your next one — npm run client:gen.

Lens: 115 files, 1,423 tests passing, typecheck clean.

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.

liquidity is a column with no definition

2 participants