Skip to content

feat(clob): support PolyV2 position IDs - #112

Merged
kartojal merged 2 commits into
mainfrom
codex/dev-549-position-id-orders
Sep 2, 2026
Merged

feat(clob): support PolyV2 position IDs#112
kartojal merged 2 commits into
mainfrom
codex/dev-549-position-id-orders

Conversation

@kartojal

@kartojal kartojal commented Aug 31, 2026

Copy link
Copy Markdown
Contributor

Summary

  • add explicit position_id support for limit and market orders with exclusive token/position validation
  • route position-backed orders through Exchange V3 signing on Polygon and Amoy, bypassing server version and neg-risk lookups
  • propagate position IDs through order books, tick sizes, fee metadata, amount calculation, signing, serialization, and submission
  • support position IDs in market-data reads while preserving the protocol token_id and tokenId wire fields
  • add integration tests, request serialization coverage, API documentation, README guidance, and a changelog entry

Reference

Rust implementation of the behavior introduced in Polymarket/clob-client-v2#104:
Polymarket/clob-client-v2#104

Validation

  • cargo test --all-features
  • cargo test
  • cargo build --all-targets --all-features
  • cargo +nightly-2025-11-24 fmt --all -- --check
  • cargo +1.88.0 clippy --all-targets --all-features -- -D warnings
  • cargo +1.88.0 clippy --all-targets -- -D warnings
  • git diff --check

Note

Medium Risk
Touches order construction, EIP-712 signing, and contract selection—errors could produce unfillable or wrongly signed orders—but behavior is heavily tested and token-only paths are largely unchanged.

Overview
Adds Polymarket V2 position-backed trading alongside existing CTF token orders. Limit and market builders gain position_id(); callers must supply exactly one of token_id or position_id.

Position orders always use Exchange V3: EIP-712 domain version "3", exchange_v3 on Polygon/Amoy, same V2-shaped wire payload (tokenId carries the position ID). They skip GET /version and neg-risk during build/sign. Token orders keep V1/V2 auto-detection and version-mismatch retry on post.

Signing and types: OrderPayload::V3, new_v3, and v3() accessors; V3 shares serialization with V2. Poly1271 is documented for V2/V3 orders.

Market data and metadata: Read paths (midpoint, books, tick size, fees, market_by_token, etc.) treat position IDs like tokens, still serialized as token_id on the wire.

README, module docs, changelog, request docs, config tests, and integration tests cover position limit/market flows, mutual exclusion of IDs, and serialization.

Reviewed by Cursor Bugbot for commit 4d2cc8a. Bugbot is set up for automated code reviews on this repo. Configure here.

@kartojal kartojal added the wip label Aug 31, 2026
@kartojal
kartojal marked this pull request as ready for review September 1, 2026 08:03

@cesarenaldi cesarenaldi left a comment

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.

The implementation matches the intended minimal clob-client-v2 port. The remaining test-fixture and terminology points are non-blocking.

@kartojal
kartojal merged commit dc94839 into main Sep 2, 2026
12 checks passed
@kartojal kartojal mentioned this pull request Sep 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants