feat(gamma): add feeSchedule and feeType to Market - #82
Open
jenish-25 wants to merge 1 commit into
Open
Conversation
The gamma API returns feeSchedule and feeType on every market, but Market did not model them. With the tracing feature enabled, serde_helpers emitted a WARN per field per market fetched, drowning genuine schema-drift signals. Both fields are optional, so markets that omit them still deserialize. Closes Polymarket#55
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.
Closes #55.
Problem
The gamma API returns
feeScheduleandfeeTypeon every market, butgamma::types::response::Marketdoes not model them. With thetracingfeature enabled,serde_helperslogs a WARN per unknown field per market fetched:For consumers that treat these WARNs as schema-drift signals, every gamma fetch produces noise that hides real drift.
Change
Adds a
FeeSchedulestruct and two fields toMarket:FeeSchedulefollows the existing nested-type convention in this file (ClobReward,ImageOptimization): all-Optionfields,#[non_exhaustive], andrename_all = "camelCase"— so no explicit#[serde(rename)]attributes are needed forfeeSchedule/feeType/rebateRate/takerOnly.Purely additive. Both fields are
Option, so markets that omit them continue to deserialize unchanged, andMarketis already#[non_exhaustive]so no downstream construction breaks.Tests
Two tests added to
tests/gamma.rs(httpmock, no network):market_fee_schedule_should_deserialize— asserts the field values from the issue's payload deserialize into typed values.market_without_fee_schedule_should_deserialize— asserts a market with neither field still deserializes, with both asNone.Verification
Note
The subfield types (
exponent: i32,rate/rebateRate:Decimal,takerOnly: bool) are taken from the payload in #55. I could not reachgamma-api.polymarket.comfrom my network to sample a wider set of live markets, so iffeeTypeis better modeled as an enum, orexponentis ever fractional, happy to adjust.Note
Low Risk
Additive serde-only response modeling with optional fields; no API client or runtime behavior changes beyond deserialization.
Overview
Models Gamma API
feeScheduleandfeeTypeonMarketso responses deserialize without unknown-field noise (notably with thetracingfeature).Adds a nested
FeeScheduletype (exponent,rate,rebate_rate,taker_only) and optionalfee_schedule/fee_typeonMarket, using the same camelCase / all-optional /#[non_exhaustive]pattern as other nested response types.Tests: two httpmock
market_by_slugcases—full fee payload typed asDecimalwhere expected, and a market with neither field leaving bothNone.Reviewed by Cursor Bugbot for commit 6f9e67e. Bugbot is set up for automated code reviews on this repo. Configure here.