Physically moved the polymarket-clob crate from the polymarket_fetch repo into the new position_manager Cargo workspace, and flipped use_server_time to false to eliminate a serial pre-POST latency hit. Commit cdfcca8 in position_manager only.
For Agents
This is Task 2 of the Rust migration for pmv2. The crate
polymarket-clob(formerly at/Users/levander/coding/polymarket_fetch/crates/polymarket-clob/) now lives at/Users/levander/coding/pmv2/position_manager/crates/polymarket-clob/. Thepolymarket_fetchrepo is intentionally left un-buildable until a later task re-points it. Do NOT try to fixpolymarket_fetch’sCargo.tomlreferences — that is deferred work.
What moved
| Before | After |
|---|---|
/Users/levander/coding/polymarket_fetch/crates/polymarket-clob/ | /Users/levander/coding/pmv2/position_manager/crates/polymarket-clob/ |
The crate is a vendored fork of rs-clob-client-v2 — the only place that signs Polymarket CLOB orders (EIP-712 build_order). It is a leaf crate with no workspace-internal dependents other than autotrade.
Commit: cdfcca8 in position_manager. 135 files changed (includes the full vendor tree).
Key decisions
1. Cross-repo move: polymarket_fetch left intentionally broken
git rm --cached was staged in polymarket_fetch but not committed. The old workspace Cargo.toml in polymarket_fetch still references the crate path but the files are gone. This is intentional — a later task will re-point or remove those references. Do not touch polymarket_fetch/Cargo.toml in the meantime.
2. use_server_time(false) flip
Location: crates/polymarket-clob/src/lib.rs line 329
Changed from:
Config::builder().use_server_time(true)to:
Config::builder().use_server_time(false)Effect: Drops the serial GET /time call that preceded every CLOB POST. The server-time path performs an extra round-trip (~20–100ms in practice) to synchronize the timestamp used in HMAC auth headers. With false, Utc::now() is used instead.
EIP-712 signed bytes are NOT affected
build_ordercomputes the EIP-712 signed order bytes independently of this flag. The signed maker/taker/contract triple is identical withuse_server_time(true)orfalse. This is verified by golden-parity tests.
This latency win was documented earlier in position-manager-interface-design under the “Latency win folded in” section.
3. No extra workspace dependencies needed
All { workspace = true } deps declared in polymarket-clob/Cargo.toml (alloy-signer-local, alloy-sol-types, tokio in dev-deps) were already present in position_manager’s [workspace.dependencies]. No additions required.
Gotcha: self-referential include_str! test
The brief called for a test asserting use_server_time(true) is absent from the source:
// WRONG — self-defeating: the file contains this string as a literal in the assert itself
let src = include_str!("lib.rs");
assert!(!src.contains("use_server_time(true)"));The assert! call itself embeds the string "use_server_time(true)" into the source file, so contains(...) would always return true and the test would always fail.
Solution — split-needle at runtime:
let src = include_str!("lib.rs");
let needle = ["use_server_time(", "true)"].concat();
assert_eq!(src.matches(&*needle).count(), 0);The needle is never present as a literal in the source file, so the check is honest.
Test results
All 11 tests pass including the 4 golden-parity signing tests:
order_hash_is_deterministic_and_domain_sensitiveverifying_contract_picks_by_neg_risksigner_recovers_to_eoa_over_our_hashparse_key_yields_known_eoaconnect_does_not_use_server_time(new — verifies the flip)
Related
- position-manager-interface-design — full PM crate design; this migration is Task 2 of Plan 1
- pmv2-autotrade-engine-design — the
polymarket-clobcrate’s role in signing + order submission - autotrade-signing-client-order-ops — signing client and order operation details
- autotrade-eip712-order-hash — EIP-712 order hash construction (unaffected by this change)
- 2026-06-20-fastest-polymarket-trade-submission — latency analysis that motivates the
use_server_time(false)flip