docs: Polymarket Infrastructure Tools — companion guide for production CLOB operations - #98
Open
osr21 wants to merge 1 commit into
Open
Conversation
Six production tools for developers building on clob-client-v2: - CLOB Indexer: on-chain fill settlement via eth_getLogs (addresses ghost fill issue Polymarket#34) - OMS: position tracking + P&L reconciliation independent of CLOB API balance cache - Market Maker: V2-native two-sided quoting with kill switch - Smart Order Router: TWAP/VWAP for large positions (avoids market impact) - Arbitrage Engine: Kalshi/Manifold/PredictIt cross-venue spread detection - CLOB Simulator: local matching engine for testing before spending real USDC Directly addresses the POLY_1271 deposit wallet cluster (Polymarket#97, Polymarket#95, Polymarket#75, Polymarket#73, Polymarket#67, Polymarket#66) by providing an OMS audit layer and on-chain settlement confirmation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Polymarket Infrastructure Tools — Companion Toolkit for
clob-client-v2This PR adds a companion guide (
docs-infra-tools-companion.md) documenting six open-source infrastructure tools built on top ofclob-client-v2. Each tool solves a specific operational problem that surfaces once you move beyond basic order placement.Docs repo: https://github.com/osr21/polymarket-infra-tools
Live dashboard: https://polymarket-hub.replit.app/infra-tools/
Why this PR
The six most-upvoted open issue clusters in this repo (and
py-clob-client-v2,rs-clob-client-v2) point to the same gap: developers know how to place orders with the SDK, but they don't have tooling to answer the harder operational questions that come next:MATCHEDbut no on-chain settlement)OrderFilledon-chainsignerfield on every orderbalance: 0after FAK fills (cache saturation)The Six Tools
1. CLOB Indexer
Streams
OrderFilledevents from the Polymarket Exchange contract on Polygon viaeth_getLogs. Provides on-chain ground-truth for fill settlement — independent of the CLOB API. Addresses the ghost-fill problem (issue #34 inpy-clob-client-v2): the CLOB marks ordersMATCHEDbefore on-chain settlement completes; the Indexer confirms only what actually settled.2. Order Management System (OMS)
Tracks positions, cost basis, realized/unrealized P&L, and a double-entry accounting ledger. Reconciles against Indexer fills. The local position view remains accurate when the CLOB balance cache saturates — the root cause of the
balance: 0errors reported across all three V2 repos.3. Market Maker
V2-native two-sided quote engine. Posts BID + ASK around a configurable fair value with spread control, inventory skewing, and a hard kill switch. Written in TypeScript against the V2 contract addresses — the
poly-market-makerPython keeper still targets V1 and breaks on V2 due toFilterParamsremoval andorder_version_mismatch.4. Smart Order Router (SOR)
Breaks large orders into TWAP or VWAP slices. Submitting a $5,000+ position as a single order sweeps multiple book levels and signals intent to the market. 10-slice TWAP over 5 minutes typically improves average fill by 1–3% on mid-liquidity markets.
5. Arbitrage Engine
Polls Kalshi, Manifold, and PredictIt for equivalent market prices and compares against Polymarket CLOB mid-prices. Surfaces spread opportunities above a configurable threshold. All three venue APIs are public with no auth. Execution requires simultaneous leg placement on both venues — the guide covers the timing and slippage risks in detail.
6. CLOB Simulator
In-memory price-time-priority matching engine that accepts the same order format as the live CLOB. Pre-seeded with two-sided order books for testing. This is the most directly useful tool for
clob-client-v2developers: validate your V2 signing flow, tick-precision handling, and fee calculations locally before touching the live CLOB with real USDC.POLY_1271 Deposit Wallet — Operational Layer
The POLY_1271 issue cluster (#97, #95, #75, #73, #67, #66) is a SDK-layer fix, but there's a second layer: even after the SDK is fixed, deposit-wallet operations need runtime verification that the API key binds correctly to the deposit wallet (not the EOA). The OMS adds this audit:
Connection to This Repo
The companion guide explains exactly how each tool integrates with
clob-client-v2:@polymarket/clob-client-v2importsThe guide lives at
docs-infra-tools-companion.mdin the root — consistent with the existingREADME.mdandexamples/pattern in this repo.Checklist
@polymarket/clob-client-v2types and conventionsNote
Low Risk
Documentation-only addition with no runtime, auth, or dependency changes.
Overview
Adds
docs-infra-tools-companion.md, a new root-level companion guide for developers running production systems on@polymarket/clob-client-v2.The doc introduces six external polymarket-infra-tools capabilities (CLOB Indexer, OMS, market maker, SOR, cross-venue arb, local simulator), with problem/solution framing, sample API usage, and links to the tools repo and live dashboard. It also maps common open issues in this repo (ghost fills, balance cache, POLY_1271 signer, tick precision, etc.) to which tool mitigates them, plus a short getting-started section.
Documentation only — no application code or dependency changes.
Reviewed by Cursor Bugbot for commit 04d4dc9. Bugbot is set up for automated code reviews on this repo. Configure here.