fix(client): send order=volume and order=liquidity as their numeric fields on list_markets - #293
Open
naruto11eth wants to merge 1 commit into
Open
fix(client): send order=volume and order=liquidity as their numeric fields on list_markets#293naruto11eth wants to merge 1 commit into
naruto11eth wants to merge 1 commit into
Conversation
…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
force-pushed
the
feature/dev-632-list-markets-order-alias
branch
from
September 7, 2026 05:20
050612a to
3dd2636
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
list_markets(order="volume")returned markets sorted as text: every value on the first page started with a 9, topping out at999.99, while the true maximum in the same filter set was around83,000,000.Gamma keeps market
volumeandliquidityas text columns, a leftover of the original ingestion writingtoFixed(2)strings, and orders by the raw column. The numeric companionsvolumeNumandliquidityNumwere 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 treatsvolumeNumas the numeric field for itsvolume_num_min/volume_num_maxfilters, and theMarketmodel already exposesvolumeas aDecimal. Gamma itself already mapsorder=liquidityto the numeric column on the keyset endpoint; it has not done the same forvolumeyet.list_marketsnow sendsvolumeasvolumeNumandliquidityasliquidityNum, per comma-separated token inorder, 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 storevolumeas 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.order="volume"ororder="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_marketsdocstring (sync and async) now describesorder: comma-separated market field names withascendingsetting the direction, examples, thatvolumeandliquiditysort by their numeric values, and the cursor caveat.Tests
volume,liquidity,volume,id,createdAt, volumewith whitespace, and a trailing empty token.volumeNum,liquidityNum,volume24hr,startDate,id, withascendingpreserved.order="volume"andorder="volumeNum"are identical.list_events_spec(order="volume")is not rewritten.The TypeScript client accepts the same free-form
orderstring 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_marketsnow rewrites comma-separatedordertokens sovolumeandliquidityare sent to Gamma asvolumeNumandliquidityNum, fixing lexicographic sorting on the text columns while leaving other sort fields andascendingunchanged. The alias applies only inlist_markets_spec;list_eventsand other list endpoints are untouched.Sync and async
list_marketsdocstrings document supportedordervalues, numeric sorting for volume/liquidity, and that pagination cursors from older SDK versions withorder="volume"ororder="liquidity"cannot be resumed after upgrade (whilevolumevsvolumeNumspellings 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.