Skip to content

feat(clob): add match_time_nano field to TradeResponse#306

Open
yovanoc wants to merge 5 commits intoPolymarket:mainfrom
yovanoc:feat/match-time-nano
Open

feat(clob): add match_time_nano field to TradeResponse#306
yovanoc wants to merge 5 commits intoPolymarket:mainfrom
yovanoc:feat/match-time-nano

Conversation

@yovanoc
Copy link
Copy Markdown

@yovanoc yovanoc commented Mar 27, 2026

Summary

  • Add match_time_nano: Option<String> to TradeResponse struct
  • Field is documented in the OpenAPI spec but was missing from the Rust struct
  • Uses #[serde(default)] since the field may not always be present

The CLOB /trades endpoint returns match_time_nano with nanosecond-precision match timestamps, which is useful for deterministic ordering of trades that share the same second-precision match_time.


Note

Low Risk
Low risk: adds an optional/deserializable new response field without changing existing parsing behavior, aside from accepting an additional JSON key.

Overview
Adds match_time_nano to TradeResponse to capture nanosecond-precision match timestamps (nanoseconds since epoch) returned by the CLOB trades API.

The field is defaulted for backwards compatibility and deserializes from nullable/string inputs via serde_with::DisplayFromStr + DefaultOnNull.

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

The CLOB /trades endpoint returns match_time_nano (nanosecond precision
match timestamp) as documented in the OpenAPI spec, but the field was
missing from the TradeResponse struct.

Added as Option<String> with serde(default) since the field may not
always be present in the response.
@codecov
Copy link
Copy Markdown

codecov Bot commented Mar 27, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.54%. Comparing base (da07892) to head (afd2c27).

Additional details and impacted files
@@           Coverage Diff           @@
##             main     #306   +/-   ##
=======================================
  Coverage   85.54%   85.54%           
=======================================
  Files          32       32           
  Lines        5167     5167           
=======================================
  Hits         4420     4420           
  Misses        747      747           
Flag Coverage Δ
rust 85.54% <ø> (ø)

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.

Comment thread src/clob/types/response.rs Outdated
pub match_time: DateTime<Utc>,
/// Match time with nanosecond precision (string of nanoseconds since epoch).
#[serde(default)]
pub match_time_nano: Option<String>,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

u64 pls

Copy link
Copy Markdown

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Comment thread src/clob/types/response.rs
#[builder(default)]
#[serde(default)]
#[serde_as(deserialize_as = "DefaultOnNull<DisplayFromStr>")]
pub match_time_nano: u64,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry if that wasn't clear earlier, you could have kept the Option<u64> but this works too

Zorak556 added a commit to Zorak556/polymarket-client-sdk that referenced this pull request Apr 10, 2026
Upstream merges:
- Polymarket#321: accept custom reqwest::Client via Config
- Polymarket#322: BuilderTradeResponse.builder Address → ApiKey
- Polymarket#306: add match_time_nano to TradeResponse
- Polymarket#305: preserve unknown activity side values
- Polymarket#303: version bump to 0.4.5
- Dep bumps: rust_decimal 1.41, uuid 1.23

Local patches:
- Reduce auth header allocations (HeaderValue::from for integers)
- Reorder order_builder size validation before async fee_rate call
- Skip double deserialization when tracing is disabled
- subscribe_book_and_prices: single-stream book + price_change
- subscribe_user/orders/trades: async for tokio::sync::RwLock
- Subscription lag: escalate to error and force resubscribe
- Broadcast capacity: 1024 → 16384
- excludeDepositsWithdrawals param on ActivityRequest
- cancel_order: orderId → orderID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Zorak556 added a commit to Zorak556/polymarket-client-sdk that referenced this pull request Apr 10, 2026
Upstream merges:
- Polymarket#321: accept custom reqwest::Client via Config
- Polymarket#322: BuilderTradeResponse.builder Address → ApiKey
- Polymarket#306: add match_time_nano to TradeResponse
- Polymarket#305: preserve unknown activity side values
- Polymarket#303: version bump to 0.4.5
- Dep bumps: rust_decimal 1.41, uuid 1.23

Local patches:
- Reduce auth header allocations (HeaderValue::from for integers)
- Reorder order_builder size validation before async fee_rate call
- Skip double deserialization when tracing is disabled
- subscribe_book_and_prices: single-stream book + price_change
- subscribe_user/orders/trades: async for tokio::sync::RwLock
- Subscription lag: escalate to error and force resubscribe
- Broadcast capacity: 1024 → 16384
- excludeDepositsWithdrawals param on ActivityRequest
- cancel_order: orderId → orderID

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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