polymarket-cpp-client icon indicating copy to clipboard operation
polymarket-cpp-client copied to clipboard

Do we have any plan migrate to v2

Open MichiganLu opened this issue 7 months ago • 7 comments

Thanks for the cpp implementation. Now do we have a plan to migrate to V2 client?

MichiganLu avatar Apr 22 '26 10:04 MichiganLu

PR #5 is merged now. It adds the V2 migration plan and notes in the README so the repo is clear about the current state.

SebastianBoehler avatar May 08 '26 19:05 SebastianBoehler

Merged #6.

The C++ client now signs and posts CLOB V2 orders: V2 domain/version, V2 exchange addresses, timestamp/metadata/builder fields, owner/deferExec/postOnly payload fields, and POLY_1271 support. I also added fixed-vector signer tests against the official Python V2 SDK.

SebastianBoehler avatar May 08 '26 20:05 SebastianBoehler

@SebastianBoehler Does it working properly for you with POLY_1271 ? I faced same issue as was reported for official code: https://github.com/Polymarket/clob-client-v2/issues/66 , https://github.com/Polymarket/py-clob-client-v2/issues/64 .

KonstantinUtkin avatar May 21 '26 04:05 KonstantinUtkin

Hey, I looked into the two upstream threads.

The C++ client has the order-side POLY_1271 support implemented: for type 3 it uses the funder/deposit wallet as both maker and signer, and signs the V2 order with the wrapped ERC-1271 format.

The part this repo does not handle yet is the deposit-wallet relayer setup. So the wallet still needs to be the actual deployed deposit wallet, funded, approved, and balance-synced before the CLOB order path will work. From the upstream comments, the common checks are:

  • use the real deposit wallet/proxy address as funder, not just a bridge/deposit address
  • make sure eth_getCode(funder) is non-empty; if it is empty, the wallet is still counterfactual/not deployed
  • approvals need to be made from the deposit wallet, then call balance allowance update with signature_type=3
  • derive/use CLOB API creds from the owner signer, then initialize trading with POLY_1271 and the deposit wallet funder

I have not verified a live funded POLY_1271 order from this C++ repo end-to-end yet, so I would treat the current support as correct signing/payload support, not a full deposit-wallet onboarding client. If you still see the signer/api-key error with a deployed funder wallet, send a redacted order payload and the relevant addresses and I can compare it against the official V2 shape.

SebastianBoehler avatar May 21 '26 06:05 SebastianBoehler

Something strange, I should say. Order placing (using this lib) finally worked for me when I set both maker and signer values to proxy (portfolio) address, i.e. neither "deposit" nor real (EOA) account address. While docs saying I should use "deposit". Maybe docs are just unclear? Signer itself was still using private key of real (EOA) wallet.
The other part is that I was unable to derive api key using this lib, while it worked with typescript lib, where I had to set my portfolio (proxy) addres as "funderAddress" parameter:

const client = new ClobClient({
  host: "https://clob.polymarket.com",
  chain: 137, // Polygon mainnet
  signer: signer,
  creds: undefined,
  signatureType: SignatureTypeV2.POLY_1271,
  funderAddress: "0x1234567890"
});

KonstantinUtkin avatar May 21 '26 16:05 KonstantinUtkin

Thanks, that helps. I think you found a real bug in this C++ client.

The order path was already using the configured funder/proxy address for POLY_1271, but API-key auth was not: create_or_derive_api_credentials(..., funder) accepted the funder argument and then ignored it while building the L1 auth headers. That explains why deriving credentials worked through the TypeScript client path but not here.

I opened and merged #13 to fix this. L1 API-key auth and L2 HMAC auth now use the supplied funder/proxy address when one is configured, so the auth identity matches the wallet identity used by POLY_1271 orders.

And yes, I agree the docs are easy to misread here. In this context, "deposit wallet" means the deployed portfolio/proxy wallet that holds pUSD and is used as the order maker/signer. It does not mean a bridge deposit address or the owner EOA.

SebastianBoehler avatar May 21 '26 18:05 SebastianBoehler

Now key deriving is also working, thank you for the fix!

KonstantinUtkin avatar May 22 '26 05:05 KonstantinUtkin