rs-order-utils
🦀 Rust implementation of Polymarket CLOB (Central Limit Order Book) order utilities with EIP-712 typed data signatures.
This library provides a complete Rust port of the TypeScript clob-order-utils package, enabling you to create and sign Polymarket exchange orders using EIP-712 standard.
Installation
Add this to your Cargo.toml:
[]
= "0.4.2"
= "1"
= "1"
= { = "1.0", = ["full"] }
V2 protocol support —
0.3.0adds av2module (additive, non-breaking) that mirrors the 11-field V2 CTF Exchange order struct and thePoly1271smart-contract signature type. V1 consumers require no code changes. See the V2 Quick Start below.
Release history lives in CHANGELOG.md.
Quick Start
use ;
use PrivateKeySigner;
use ;
async
V2 Quick Start
use ;
use PrivateKeySigner;
use ;
use Side;
async
Key V2 differences (vs V1):
- 11-field signed struct (dropped
taker,nonce,feeRateBps;expirationmoved to un-signed payload only) - Domain version bumped to
"2" SignatureType::Poly1271added for EIP-1271 smart-contract walletssideserialized as"BUY"/"SELL"in API payload (V1 uses"0"/"1")
V2 signatures are cross-validated byte-for-byte against the official TypeScript @polymarket/clob-client-v2 SDK for the EOA, PolyProxy, and PolyGnosisSafe signature types. Poly1271 is excluded from cross-language parity until the TS SDK adopts the ERC-7739 nested TypedDataSign wrapping that the deposit wallet's on-chain isValidSignature requires (see CHANGELOG.md). See tests/v2_cross_language_vectors.rs.
Usage
# Run examples
# Run tests
# Run tests with output
Security Considerations
- 🔒 Private Keys: Never hardcode private keys. Use environment variables or secure key management
- 🔐 EIP-712: All orders are signed using EIP-712 to prevent phishing attacks
- ✅ Signer Verification: The builder verifies that the signer matches the wallet address
- 🛡️ Domain Separation: Orders are bound to specific chain and contract addresses
Notice
⚠️ AI-Generated Code: This library was generated with AI assistance. While it has been tested, users should:
- Review the code thoroughly before using in production
- Conduct their own security audits
- Test extensively with their specific use cases
- Use at their own risk
License
MIT
Acknowledgments
- Original TypeScript implementation: Polymarket clob-order-utils
- Built with Alloy - the modern Ethereum Rust library
Made with 🦀 by the Polymarket community