feat(polymarket): support batched filter parameters on 3 endpoints#533
Merged
Conversation
Filter params 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 and Hyperliquid routes. Batched fields per endpoint: - `/markets` condition_id, market_slug, token_id, event_slug - `/users` user - `/users/positions` user, token_id, condition_id, market_slug The remaining Polymarket endpoints stay scalar for now: - `/markets/activity` is a UNION ALL fan-out across 5 ledger tables; warrants a separate perf review before batching. - `/markets/oi` keeps its "provide exactly one of condition_id or market_slug" contract; adding multi-value support there changes the response semantic. - `/markets/ohlc` and `/markets/positions` are per-token time-series / leaderboard surfaces — mirrors the scalar-only contract on Hyperliquid OHLC and EVM/SVM/TVM `/pools/ohlc`. Side effects: - `/markets` SQL switches from a CASE-dispatch WHERE clause (first non-null filter wins) to additive AND filters. This is the same shape used elsewhere in the codebase. Behavior change for callers that previously passed two scoping filters at once (e.g. `condition_id=A&market_slug=B`): the CASE silently used the first non-null one and ignored the rest. After this change, both filters apply together, so mismatched combinations now correctly return an empty result. - `token_id` resolution in `/markets` and `/users/positions` now uses `asset_id IN (SELECT toUInt256(arrayJoin(...)))` so multiple token ids resolve to the union of their condition ids. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
20239c6 to
a062991
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
/markets,/users,/users/positions—?condition_id=A,B, repeated?condition_id=A&condition_id=B, and single?condition_id=Aall parse, matching the convention on/v1/{evm,svm,tvm}/*and the new Hyperliquid batched routes (feat(hyperliquid): support batched filter parameters across 8 endpoints #532)./marketsSQL from CASE-dispatch (first non-null filter wins) to additive AND filters, which both enables batching and aligns the endpoint with the rest of the codebase.Endpoints / params
/marketscondition_id,market_slug,token_id,event_slug/usersuser/users/positionsuser,token_id,condition_id,market_slugDeferred
/markets/activity— UNION ALL fan-out across 5 ledger tables; needs perf review./markets/oi— keeps its "exactly one of condition_id or market_slug" contract; multi-value support would change response semantics./markets/ohlcand/markets/positions— per-token time series / leaderboard. Mirrors scalar-only OHLC contracts elsewhere.Behavior change on
/marketsPrevious SQL used a
CASE WHEN isNotNull(...)dispatch where the first non-null filter wins and the rest are silently ignored. After this PR,/marketscomposes filters additively (AND): every passed filter must match. Callers that relied on the implicit drop-the-others behavior — e.g.?condition_id=A&market_slug=B— will now see filters interact, with mismatched combinations correctly returning an empty result. Single-filter calls (the documented usage) are unchanged.Test plan
bun run tsc --noEmitcleanmainbaseline on the same cluster — single-value calls match within variance; batched calls scale 1.5–2.5× per added value🤖 Generated with Claude Code