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/. The polymarket_fetch repo is intentionally left un-buildable until a later task re-points it. Do NOT try to fix polymarket_fetch’s Cargo.toml references — that is deferred work.

What moved

BeforeAfter
/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_order computes the EIP-712 signed order bytes independently of this flag. The signed maker/taker/contract triple is identical with use_server_time(true) or false. 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_sensitive
  • verifying_contract_picks_by_neg_risk
  • signer_recovers_to_eoa_over_our_hash
  • parse_key_yields_known_eoa
  • connect_does_not_use_server_time (new — verifies the flip)