Repository navigation
feat(env)!: add Environment with production and preproduction presets - #30
Conversation
BREAKING CHANGE: chain 80002 is rejected; pass an Environment with explicit contracts instead.
|
Why added
Heads up: preprod is not a testnet. It's on Polygon mainnet with real contracts and real funds. |
Summary
Adds
polymarket::Environment. It holds every endpoint and contract for a deployment, withproduction()andpreproduction()presets taken from the official SDKs.Before this,
ClobClienthard-coded the production Data API host and the mainnet exchange addresses. It also accepted chain 80002 while signing those orders against the mainnet exchanges.ClobClienthas newEnvironmentconstructors. The existing string constructors use production with only the CLOB host replaced, and accept only chain 137.Config::for_environment()andPositionClientConfig::for_environment()build configs from an environment.order_testreadPOLYMARKET_ENV.live-labeled read-only test against the preproduction CLOB:test_preproduction_live.Preproduction is not a testnet. It runs on Polygon mainnet with the production contracts, so funds are real.
Verification
Commands run and their actual results:
ctest --test-dir build -LE live(Linux Release): 53 of 53 passed.POLYMARKET_RUN_LIVE_SMOKE=1 ctest -R test_preproduction_live: passed.POLYMARKET_ENV=preproduction ./rest_example: read preproduction markets and a book.scripts/quality.py: C++ checks passed.Checks not run and the reason (or none):
README.md: no Node runtime was available locally. CI runs it.test_clob_client_contractssometimes fails its pagination checks. This also happens onmainand is unrelated to this change.Compatibility and evidence
Public API, binary compatibility, or release implications (or none):
ClobClient(url, 80002)now throws. Use anEnvironmentwith explicit contracts instead.ClobClient's layout changed.polymarket/environment.hppand the factories.For protocol changes: no wire or signing changes. Presets come from ts-sdk
environments.tsatf72f9b3and py-sdkenvironments.pyat3f5b181.For live checks: only read-only preproduction CLOB calls were made live. Host routing and contract selection are covered by local fixtures.