clob-client-rust
Rust client for Polymarket CLOB (ported from the official TypeScript clob-client).
This crate focuses on:
- Order building + EIP-712 signing parity
- Typed endpoint calls
- TS v5.1.0 parity additions: Readonly API Key + RFQ client + HTTP PUT + optional geo token
Important behavior note:
- Tick size is not auto-resolved from the backend. If you need a market-specific tick, fetch it externally and pass it in. Otherwise the SDK uses the fallback tick
"0.01".
Install
[]
= "0.1"
Auth models (TS parity)
1) L2 auth (signer + API key creds)
Used for trading flows (create/post/cancel) and authenticated reads.
use ClobClient;
use EthersSigner;
use ApiKeyCreds;
use Arc;
let signer = new;
let creds = ApiKeyCreds ;
let mut client = new;
2) Readonly API key headers (TS parity)
Important TS parity note:
- TypeScript
client.getOpenOrders()still uses L2 auth (HMAC headers). - The readonly key is used only in the standalone TS example
getOpenOrdersWithReadonlyKey.ts, by manually callingGET /data/orderswith extra headers.
Rust parity example (same as TS example, via http_helpers):
use GET_OPEN_ORDERS;
use ;
use SignedOrder;
use HashMap;
let endpoint = format!;
let mut headers = new;
headers.insert;
headers.insert;
let mut params = new;
params.insert;
let opts = RequestOptions ;
let val = get.await?;
let arr = if val.is_array else ;
let orders: = from_value?;
Geo block token
TypeScript injects geo_block_token into every request automatically. In Rust it is optional:
let client = client.with_geo_block_token;
When set, the SDK injects geo_block_token into query parameters for supported calls.
RFQ client (TS v5.1.0)
RFQ is exposed as a sub-client similar to TS: client.rfq().
use GetRfqQuotesParams;
let quotes = client
.rfq
.get_rfq_quotes
.await?;
Accept/approve will:
- fetch the quote
- build a signed order via
client.create_order(...) - post the action payload to the RFQ endpoint
Tick size behavior stays explicit (fallback is "0.01").
Readonly API key management
The SDK exposes the endpoints added in TS v5.1.0:
create_readonly_api_keyget_readonly_api_keysdelete_readonly_api_keyvalidate_readonly_api_key
TS parity:
create/get/deleterequire L2 auth.validate_readonly_api_keyis a public GET (query params), no L2 needed.
See the examples in examples/.
HTTP helpers (GET/POST/PUT/DELETE)
http_helpers provides typed request wrappers including put_typed/put.
Examples
Build/sign only (no network):
Readonly open orders (TS parity headers):
RFQ quotes: