Skip to content

fix(client): send order=volume and order=liquidity as their numeric fields on list_markets - #293

Open
naruto11eth wants to merge 1 commit into
mainfrom
feature/dev-632-list-markets-order-alias
Open

fix(client): send order=volume and order=liquidity as their numeric fields on list_markets#293
naruto11eth wants to merge 1 commit into
mainfrom
feature/dev-632-list-markets-order-alias

Conversation

@naruto11eth

@naruto11eth naruto11eth commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Summary

list_markets(order="volume") returned markets sorted as text: every value on the first page started with a 9, topping out at 999.99, while the true maximum in the same filter set was around 83,000,000.

Gamma keeps market volume and liquidity as text columns, a leftover of the original ingestion writing toFixed(2) strings, and orders by the raw column. The numeric companions volumeNum and liquidityNum were added later specifically for numeric filtering and ordering, and the ETL writes the same value into both fields, so the only difference is the column type. There is no meaningful alphabetical volume sort, the SDK already treats volumeNum as the numeric field for its volume_num_min / volume_num_max filters, and the Market model already exposes volume as a Decimal. Gamma itself already maps order=liquidity to the numeric column on the keyset endpoint; it has not done the same for volume yet.

list_markets now sends volume as volumeNum and liquidity as liquidityNum, per comma-separated token in order, so "volume,id" goes out as "volumeNum,id". Every other token, the direction (ascending), and multi-field ordering are forwarded unchanged. The mapping is markets-only; events and series store volume as a number and are untouched. Response fields keep their current names and types.

Behaviour change

  • order="volume" now returns numerically ordered markets. order="liquidity" is unchanged in practice since the service already orders it numerically; the mapping keeps the two spellings interchangeable.
  • Pagination cursors carry a fingerprint of the query, and Gamma binds its own cursor to the effective sort fields. A cursor obtained from an earlier release with order="volume" or order="liquidity" will not resume after upgrading; the SDK raises its usual query-parameter mismatch error. Cursors created by this release are interchangeable between the two spellings.

Docs

The list_markets docstring (sync and async) now describes order: comma-separated market field names with ascending setting the direction, examples, that volume and liquidity sort by their numeric values, and the cursor caveat.

Tests

  • Mapping per token: volume, liquidity, volume,id, createdAt, volume with whitespace, and a trailing empty token.
  • Pass-through unchanged for volumeNum, liquidityNum, volume24hr, startDate, id, with ascending preserved.
  • Cursor fingerprints for order="volume" and order="volumeNum" are identical.
  • list_events_spec(order="volume") is not rewritten.

The TypeScript client accepts the same free-form order string and gets an equivalent change separately. Longer term the mapping belongs in Gamma; this stays harmless once that lands.


Note

Medium Risk
Intentional breaking change for saved pagination cursors and different sort order for order="volume"; scope is limited to public market listing query params.

Overview
list_markets now rewrites comma-separated order tokens so volume and liquidity are sent to Gamma as volumeNum and liquidityNum, fixing lexicographic sorting on the text columns while leaving other sort fields and ascending unchanged. The alias applies only in list_markets_spec; list_events and other list endpoints are untouched.

Sync and async list_markets docstrings document supported order values, numeric sorting for volume/liquidity, and that pagination cursors from older SDK versions with order="volume" or order="liquidity" cannot be resumed after upgrade (while volume vs volumeNum spellings share the same query fingerprint in this release).

Unit tests cover token mapping, pass-through, cursor fingerprint parity, and markets-only scope.

Reviewed by Cursor Bugbot for commit 3dd2636. Bugbot is set up for automated code reviews on this repo. Configure here.

…ields on list_markets

Gamma keeps market volume and liquidity as text columns and orders by the
raw column, so order="volume" sorted lexicographically (999.99 above 83M).
The numeric twins hold the same value, so list_markets now sends those
tokens as volumeNum and liquidityNum, per comma-separated token, and leaves
every other field untouched. Markets only; events and series store volume
as a number. Gamma already applies the liquidity mapping itself, so that
entry only keeps the two names interchangeable.

Cursors issued by earlier releases with order="volume" or "liquidity"
no longer resume; the SDK reports a query-parameter mismatch.
@naruto11eth
naruto11eth force-pushed the feature/dev-632-list-markets-order-alias branch from 050612a to 3dd2636 Compare September 7, 2026 05:20
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.

1 participant