Skip to content

feat(svm): add input_decimals and output_decimals to /pools#538

Merged
0237h merged 1 commit into
mainfrom
feat/svm-pools-decimals
May 13, 2026
Merged

feat(svm): add input_decimals and output_decimals to /pools#538
0237h merged 1 commit into
mainfrom
feat/svm-pools-decimals

Conversation

@0237h
Copy link
Copy Markdown
Collaborator

@0237h 0237h commented May 12, 2026

Summary

  • /v1/svm/pools now returns input_decimals and output_decimals (nullable) for each pool, joined from svm-accounts.decimals_state.
  • Customer-reported gap: external clients had to fetch decimals separately to compute prices. With this, /pools is self-contained for price math, matching the convention already used by /v1/svm/swaps, /v1/svm/pools/ohlc, and /v1/svm/tokens.

Why arrayJoin instead of UNION DISTINCT

The decimals CTE references the mint set from pools_with_tokens. The UNION DISTINCT pattern (used in /v1/svm/swaps) caused ClickHouse to re-evaluate pools_with_tokens twice, doubling the wide aggregation cost. Replacing with arrayJoin([token0, token1]) keeps it to a single scan. ~30-40% faster across all filter shapes.

🤖 Generated with Claude Code

Customers calculating prices from /pools had to fetch token decimals
from a second endpoint. Decimals live in `svm-accounts` (separate from
`svm-dex`), but the route handler already has the `accounts` database
wired up — it just wasn't joined here.

Decimals are looked up via `arrayJoin([token0, token1])` rather than
`UNION DISTINCT SELECT token0/1`, scanning `pools_with_tokens` once
instead of twice. ~30-40% faster than the naive shape on mint/amm
filters.

The `/v1/svm/pools` SQL spec already passed without filter at borderline
5s timing; tightening it to use `amm_pool` brings it deterministically
under 2.5s and exercises the customer's actual query path.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@YaroShkvorets YaroShkvorets temporarily deployed to feat/svm-pools-decimals - token-api PR #538 May 12, 2026 21:32 — with Render Destroyed
@0237h 0237h merged commit 3688886 into main May 13, 2026
2 of 3 checks passed
@0237h 0237h deleted the feat/svm-pools-decimals branch May 13, 2026 18:30
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.

3 participants