Findings from binding the vendored rs-clob-client-v2 into the polymarket-clob crate (Plan 3b, Task 1). Covers import paths, type quirks, builder patterns, and clippy landmines introduced by enabling the "clob" feature across the workspace.
Import Paths
The SDK does not re-export everything at the crate root. Use these exact paths:
| Symbol | Path |
|---|---|
U256 | polymarket_client_sdk_v2::types::U256 |
Unauthenticated | polymarket_client_sdk_v2::auth::state::Unauthenticated |
Client | polymarket_client_sdk_v2::clob::Client |
Config | polymarket_client_sdk_v2::clob::Config |
Unauthenticated is NOT re-exported at crate root
use polymarket_client_sdk_v2::Unauthenticateddoes not compile. You must use the fullauth::statepath.
U256 Parsing and Display
U256 is alloy’s primitive, re-exported from the SDK’s types module.
- Parse from string:
U256::from_str(s)viastd::str::FromStrtrait. - Do NOT use:
from_str_radix— alloy’sU256does not expose this method. - Display:
u256_val.to_string()emits decimal, not hex. This is important when serialising token IDs for CLOB requests.
Client Construction
Client::new(host: &str, config: Config) -> Result<Client<Unauthenticated>>There is no chain ID argument — the chain is implicit in the host/config. Do not pass it.
Builder Patterns
OrderBookSummaryRequest uses a bon builder:
let req = OrderBookSummaryRequest::builder()
.token_id(u256_val)
.build();.build() returns the struct directly — not a Result. Do not unwrap or ?.
MarketResponse Field Types
MarketResponse field types that differ from what you might expect:
| Field | Type | Notes |
|---|---|---|
end_date_iso | Option<DateTime<Utc>> | Nullable |
minimum_tick_size | Decimal | Flat Decimal, NOT TickSize |
neg_risk | bool | Direct bool |
tokens | Vec<Token> | See Token fields below |
Token fields:
token_id: U256outcome: String
TickSizeResponse.minimum_tick_size (a separate response type) is TickSize — call .as_decimal() to get a Decimal.
Clippy Landmines from the "clob" Feature
Enabling features = ["clob"] causes cargo clippy --workspace --all-targets to lint the vendored crate. Several issues require suppression.
Vendored Config::default() impl
The vendored Config has a manual Default impl that clippy flags as clippy::derivable_impls. Suppress on the vendored impl:
#[expect(clippy::derivable_impls, reason = "vendored code")]
impl Default for Config { ... }Vendored example required-features
Four vendored examples (async, authenticated, aws_authenticated, builder_authenticated) were missing "tracing" in their required-features. Add it to fix the clippy gate.
single_option_map
A function returning Option with a single .map() call triggers clippy::single_option_map. Two remedies:
- Suppress with
#[expect(clippy::single_option_map, reason = "...")] - Renaming with an
_optsuffix alone does not satisfy the lint — the suppression attribute is still needed.
The plan’s secs_until was renamed to secs_until_opt and also needed #[expect(clippy::single_option_map)].
unused_self
Methods that reference self only in the signature trigger clippy::unused_self. Fix by making them associated functions:
fn foo(m: &MarketType) { ... }
// call as:
Self::foo(&self.market);struct_excessive_bools
Existing #[allow(clippy::struct_excessive_bools)] suppressions must be converted to #[expect(..., reason = "...")] under workspace lint rules (the workspace Cargo.toml uses expect everywhere).
For Agents
The workspace enforces
#[expect]not#[allow]for clippy suppressions. Any vendored or new code added underfeatures = ["clob"]must follow the same convention or the gate will fail.