Project Structure
Matching Engine
Usesnodejs-order-book - a high-performance CLOB library.
Capabilities
- 300,000+ matches per second
- Price-time priority
- Partial fills support
- Market and Limit orders
How It Works
Matching Example
Orderbook before:1
First Match
Match with bid 55c (100 tokens) - Trade at 55c
2
Second Match
Match with bid 50c (150 tokens) - Trade at 50c
3
Complete
Order fully filled (0 remaining)
Order Signing
Uses@polymarket/order-utils for EIP-712 signatures.
Why This Library
- Signatures compatible with CTFExchange
- Audited and production-proven
- Correct type handling
Gasless Signing Flow
Key insight: The user signs nothing. The operator signs for them (gasless).
Executor
Settles matched orders on-chain.Execution Flow
Data Storage
Redis (Hot Data)
- Active orderbooks
- Open orders
- Recent trades (last 50)
Convex (Persistent)
- Market definitions
- User profiles
- Trade history
- User positions
Blockchain (Source of Truth)
- Actual token balances
- Finalized transactions
- Contract state
