feat(polymarket): migrate to CLOB V2 SDK, pUSD collateral, and V2 exchange contracts#106
Merged
JamesLawton merged 1 commit intomainfrom Apr 28, 2026
Merged
Conversation
…hange contracts - Replace @polymarket/clob-client + order-utils with @polymarket/clob-client-v2@1.0.0 - Update ClobClient constructor to options object (chainId → chain, funderAddress) - Update exchange contract addresses to V2 (CTF_EXCHANGE, NEG_RISK_CTF_EXCHANGE) - Add pUSD, COLLATERAL_ONRAMP, COLLATERAL_OFFRAMP constants - Add USDC.e → pUSD wrapping step in clob-buy flow via CollateralOnramp - Update approve flow: pUSD → V2 exchange, CTF → V2 exchange, USDC.e → onramp - Fix proxy wallet ABI: function name is proxy() not execute() (selector 0x34ee9791) - Rewrite SKILL.md for V2: pUSD collateral, re-approval requirement, wrapping flow Tested E2E on V2 test endpoint (clob-v2.polymarket.com): - Approvals: tx 0x6cf87c... - Wrap USDC.e → pUSD: tx 0x00b686... - GTC order posted: orderId 0x4d32e7..., status live - Cancel + orders + positions all verified
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 shipped CLOB V2 on April 28, 2026. This PR migrates our entire Polymarket integration to the new infrastructure , new SDK, new collateral token (pUSD), new exchange contracts, and a new order signing format. The V1 SDK no longer works against production.
What changed
SDK swap
@polymarket/clob-client+@polymarket/order-utilswith@polymarket/clob-client-v2@1.0.0chainId→chain, proxy wallet →funderAddress)SignatureType→SignatureTypeV2(now exported from the v2 client directly)New collateral: pUSD
clob-buyflow via the CollateralOnramp contractV2 exchange contracts
CTF_EXCHANGEto0xE111180000d2663C0091e4f400237545B87B996BNEG_RISK_CTF_EXCHANGEto0xe2222d279d744050d28e00520010520000310F59PUSD,COLLATERAL_ONRAMP,COLLATERAL_OFFRAMPApproval flow updated
approve --broadcastsince V2 uses entirely new contractsBug fix: proxy wallet ABI
proxy()(selector0x34ee9791), notexecute()(0xe8454e54)SKILL.md rewrite
Files changed
packages/polygon-agent-cli/package.json— dependency swappackages/polygon-agent-cli/src/lib/polymarket.ts— constants, SDK client, ABI fixpackages/polygon-agent-cli/src/commands/polymarket.ts— approvals, wrapping step, output labelsskills/polygon-polymarket/SKILL.md— full rewritepnpm-lock.yamlTest plan
Tested end-to-end on production V2 (
clob.polymarket.com, version: 2) with real on-chain transactions:0x6cf87c...(3 approvals: pUSD, CTF, USDC.e→Onramp)0x00b686...0x4d32e7..., status: live0x16acbd...0x488232...0x5a6e4b...