Skip to content

fix: NewMarket/MarketResolved WS filtering + MAKER_REBATE deserialization#299

Open
yovanoc wants to merge 2 commits intoPolymarket:mainfrom
yovanoc:fix/ws-market-events-and-maker-rebate
Open

fix: NewMarket/MarketResolved WS filtering + MAKER_REBATE deserialization#299
yovanoc wants to merge 2 commits intoPolymarket:mainfrom
yovanoc:fix/ws-market-events-and-maker-rebate

Conversation

@yovanoc
Copy link
Copy Markdown

@yovanoc yovanoc commented Mar 20, 2026

Summary

Two bug fixes:

1. WS stream silently drops NewMarket/MarketResolved events

subscribe_market_with_options filters all messages by the subscriber's asset_ids_set. For NewMarket and MarketResolved, this check always fails because:

  • NewMarket events contain the new market's asset IDs, which are unknown to the subscriber
  • MarketResolved events contain the resolved market's asset IDs, which may differ from subscribed ones

These are broadcast-style events and should always be yielded to consumers. The server correctly sends them to all connections with custom_feature_enabled, but the client-side filter discards them.

Fix: Always yield NewMarket and MarketResolved variants regardless of asset_ids_set.

2. MakerRebate deserializes to Unknown("MAKER_REBATE")

The ActivityType enum uses #[serde(rename_all = "UPPERCASE")], which converts MakerRebateMAKERREBATE. The API returns MAKER_REBATE (with underscore), so it falls through to Unknown("MAKER_REBATE").

Fix: Add explicit #[serde(rename = "MAKER_REBATE")] and #[strum(serialize = "MAKER_REBATE")] on the MakerRebate variant.


Note

Low Risk
Low risk: small, targeted fixes to client-side WS message filtering and enum (de)serialization; main risk is slightly increased WS message volume for market subscriptions.

Overview
Fixes market WebSocket subscriptions to always forward broadcast-style WsMessage::NewMarket and WsMessage::MarketResolved events instead of filtering them out by subscribed asset_ids.

Updates ActivityType::MakerRebate to explicitly (de)serialize as MAKER_REBATE, preventing API values from falling through to Unknown.

Written by Cursor Bugbot for commit 9160e60. This will update automatically on new commits. Configure here.

…assets and fix MAKER_REBATE deserialization

NewMarket and MarketResolved are broadcast events with new/different asset IDs
that will never match the subscriber's asset_ids_set, causing them to be
silently dropped. These events should always be yielded to consumers.

MakerRebate was deserializing to Unknown("MAKER_REBATE") because
rename_all = "UPPERCASE" produces "MAKERREBATE" not "MAKER_REBATE".
Added explicit serde/strum rename attributes.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.46%. Comparing base (eb1bcd9) to head (9160e60).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #299      +/-   ##
==========================================
- Coverage   85.47%   85.46%   -0.02%     
==========================================
  Files          32       32              
  Lines        5129     5124       -5     
==========================================
- Hits         4384     4379       -5     
  Misses        745      745              
Flag Coverage Δ
rust 85.46% <100.00%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

2 participants