Skip to content

feat(gamma): add feeSchedule and feeType to Market - #82

Open
jenish-25 wants to merge 1 commit into
Polymarket:mainfrom
jenish-25:feat/gamma-market-fee-schedule
Open

feat(gamma): add feeSchedule and feeType to Market#82
jenish-25 wants to merge 1 commit into
Polymarket:mainfrom
jenish-25:feat/gamma-market-fee-schedule

Conversation

@jenish-25

@jenish-25 jenish-25 commented Jul 14, 2026

Copy link
Copy Markdown

Closes #55.

Problem

The gamma API returns feeSchedule and feeType on every market, but gamma::types::response::Market does not model them. With the tracing feature enabled, serde_helpers logs a WARN per unknown field per market fetched:

WARN polymarket_client_sdk_v2::serde_helpers: unknown field in API response
  field=?.feeSchedule value={"exponent":1,"rate":0.07,"rebateRate":0.2,"takerOnly":true}
WARN polymarket_client_sdk_v2::serde_helpers: unknown field in API response
  field=?.feeType value="crypto_fees_v2"

For consumers that treat these WARNs as schema-drift signals, every gamma fetch produces noise that hides real drift.

Change

Adds a FeeSchedule struct and two fields to Market:

pub fee_schedule: Option<FeeSchedule>,
pub fee_type: Option<String>,

FeeSchedule follows the existing nested-type convention in this file (ClobReward, ImageOptimization): all-Option fields, #[non_exhaustive], and rename_all = "camelCase" — so no explicit #[serde(rename)] attributes are needed for feeSchedule/feeType/rebateRate/takerOnly.

Purely additive. Both fields are Option, so markets that omit them continue to deserialize unchanged, and Market is 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 as None.

Verification

cargo test --all-features       554 passed, 0 failed
cargo clippy --all-targets --all-features -- -D warnings    clean
cargo fmt --check               clean

Note

The subfield types (exponent: i32, rate/rebateRate: Decimal, takerOnly: bool) are taken from the payload in #55. I could not reach gamma-api.polymarket.com from my network to sample a wider set of live markets, so if feeType is better modeled as an enum, or exponent is 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 feeSchedule and feeType on Market so responses deserialize without unknown-field noise (notably with the tracing feature).

Adds a nested FeeSchedule type (exponent, rate, rebate_rate, taker_only) and optional fee_schedule / fee_type on Market, using the same camelCase / all-optional / #[non_exhaustive] pattern as other nested response types.

Tests: two httpmock market_by_slug cases—full fee payload typed as Decimal where expected, and a market with neither field leaving both None.

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

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
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.

gamma Market deserializer: unknown fields feeSchedule and feeType cause WARN on every fetch

1 participant