Skip to content

feat(hyperliquid): support batched filter parameters across 8 endpoints#532

Merged
0237h merged 1 commit into
mainfrom
feat/hyperliquid-batched-params
May 13, 2026
Merged

feat(hyperliquid): support batched filter parameters across 8 endpoints#532
0237h merged 1 commit into
mainfrom
feat/hyperliquid-batched-params

Conversation

@0237h
Copy link
Copy Markdown
Collaborator

@0237h 0237h commented May 12, 2026

Summary

  • Flip filter parameters to batched on 8 Hyperliquid endpoints — ?coin=BTC,ETH, repeated ?coin=BTC&coin=ETH, and single ?coin=BTC all parse, matching the convention on /v1/{evm,svm,tvm}/*.
  • Fix a long-standing alias-shadow bug on /users where {coin:Nullable(String)} AS coin projection collided with the source column, silently turning the coin/dex filter into a no-op. The filter now applies — see the Behavior change note below.
  • /vaults/depositors SQL rewritten to carry vault through CTEs (no more literal projection) so multi-vault responses are correct.
  • Tightened hyperliquidCoinSchema / hyperliquidTokenSchema to reject commas and whitespace so the createQuerySchema union splitter fires on CSV input.

Endpoints / params

Endpoint Batched params
/markets coin, dex, base_token, quote_token
/markets/activity coin, dex, user
/markets/liquidations coin, dex, liquidated_user
/markets/oi coin, dex
/users user, coin, dex
/users/positions user, coin, dex
/vaults vault
/vaults/depositors vault

Intentionally scalar for now:

  • /markets/ohlc and /markets/liquidations/ohlc — mirrors the scalar-only contract on /v1/{evm,svm,tvm}/pools/ohlc.
  • /users/activity — UNION ALL fan-out across 9 ledger tables; needs a perf review before batching.

Behavior change on /users

Prior SQL had {coin:Nullable(String)} AS coin aliased on top of the source column; the WHERE clause coin = {coin:Nullable(String)} was being resolved against the projected literal, not the column. Net effect: ?coin=BTC returned all-coin totals on every response row. After this PR the filter applies as documented, so any client that scoped /users by coin or dex will see different (smaller, correct) aggregate numbers. The response shape is unchanged — single-value calls still echo the filter back as before.

Test plan

  • bun run tsc --noEmit clean
  • Local sweep against dev cluster — 42 functional scenarios (single, CSV, array, mixed, error) across all 8 endpoints pass
  • Multi-value semantics verified — ?coin=BTC,ETH returns rows for users trading either coin with coins_traded reflecting the per-user coin count within the filter set
  • Smoke-check staging after deploy

🤖 Generated with Claude Code

Filter params on Hyperliquid endpoints now accept a single value,
a comma-separated list, or a repeated query key — matching the
batched-parameter convention already used on EVM/SVM/TVM routes.

Batched fields per endpoint:

- `/markets`               coin, dex, base_token, quote_token
- `/markets/activity`      coin, dex, user
- `/markets/liquidations`  coin, dex, liquidated_user
- `/markets/oi`            coin, dex
- `/users`                 user, coin, dex
- `/users/positions`       user, coin, dex
- `/vaults`                vault
- `/vaults/depositors`     vault

OHLC endpoints (`/markets/ohlc`, `/markets/liquidations/ohlc`) and
`/users/activity` are intentionally left scalar — the OHLC pair
mirrors the scalar-only contract on EVM/SVM/TVM `/pools/ohlc`, and
`/users/activity` is a UNION ALL fan-out that warrants separate
perf review before batching.

Side effects:

- `hyperliquidCoinSchema` and `hyperliquidTokenSchema` now reject
  commas and whitespace at the scalar level so the union splitter
  in `createQuerySchema` can fire on CSV input. Otherwise the
  permissive scalar consumed the whole string.
- `/users` SQL aliases the source table and qualifies column
  references in WHERE/GROUP BY. The literal `{coin} AS coin`
  projection shadowed the source column, leaving the prior
  `coin = ...` filter as a no-op — `?coin=BTC` was silently
  returning all-coin totals. The filter now applies correctly,
  which materially changes the numbers returned for any request
  that scoped by coin or dex on `/users`. Single-value scoping
  still echoes the filter back into the response.
- `/vaults/depositors` SQL drops the literal `{vault} AS vault`
  projection and joins CTEs on `(vault, user)` so multi-vault
  responses carry the correct vault per row.
- `hyperliquidDexIdSchema` description trimmed to keep the
  OpenAPI 300-char description cap once the batched suffix is
  appended.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@YaroShkvorets YaroShkvorets temporarily deployed to feat/hyperliquid-batched-params - token-api PR #532 May 12, 2026 19:35 — with Render Destroyed
@0237h 0237h merged commit 3200412 into main May 13, 2026
2 of 3 checks passed
@0237h 0237h deleted the feat/hyperliquid-batched-params branch May 13, 2026 18:27
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.

2 participants