Skip to content

Comments

Fix on-chain commands ignoring --signature-type proxy#5

Open
rursache wants to merge 2 commits intoPolymarket:mainfrom
rursache:fix/proxy-signature-type
Open

Fix on-chain commands ignoring --signature-type proxy#5
rursache wants to merge 2 commits intoPolymarket:mainfrom
rursache:fix/proxy-signature-type

Conversation

@rursache
Copy link
Contributor

@rursache rursache commented Feb 24, 2026

Summary

  • Threads --signature-type through to approve and ctf commands (previously only clob received it)
  • Routes approve set calls through the proxy wallet's proxy(ProxyCall[]) function when in proxy mode
  • Uses the derived proxy address for approve check when in proxy mode
  • Routes ctf split/merge/redeem/redeem-neg-risk through the proxy wallet's proxy() function when in proxy mode
  • EOA mode is completely unchanged

Fixes #1
Fixes #4

What was broken

When signature_type = proxy:

  1. polymarket approve set sent approvals to the EOA, not the proxy — so the exchange had no allowance to spend the proxy's USDC
  2. polymarket approve check checked the EOA's approvals, reporting everything as approved when the proxy had none
  3. polymarket ctf redeem (and split/merge) executed from the EOA instead of through the proxy contract

Changes

File Change
src/main.rs Pass signature_type to approve::execute() and ctf::execute()
src/auth.rs Add IProxyWallet sol! interface with ProxyCall struct and proxy() function, resolve_proxy_address(), proxy_exec() helper
src/commands/approve.rs Proxy-aware check (uses proxy address) and set (routes through proxy wallet's proxy())
src/commands/ctf.rs Proxy-aware split/merge/redeem/redeem-neg-risk via proxy wallet's proxy()
src/output/ctf.rs Make block_number optional (proxy exec only returns tx hash)

Proxy wallet interface

The on-chain Polymarket ProxyWallet contract exposes:

function proxy(ProxyCall[] memory calls) external payable returns (bytes[] memory)

where ProxyCall is (uint8 typeCode, address to, uint256 value, bytes data) with typeCode = 1 for a standard CALL. The proxy_exec() helper in auth.rs wraps each operation in a single-element ProxyCall array with typeCode = 1 and value = 0.

Test plan

  • cargo build compiles successfully
  • cargo test — all 94 unit tests and 49 integration tests pass
  • Manual: polymarket approve check with signature_type: proxy should show the proxy address's approvals
  • Manual: polymarket approve set --signature-type proxy should route approve txs through proxy wallet
  • Manual: polymarket ctf redeem --condition <id> --signature-type proxy should execute via proxy
  • Manual: all commands with --signature-type eoa behave exactly as before

approve and ctf commands were not receiving the signature_type flag
from the CLI, causing all on-chain transactions to be sent directly
from the EOA instead of being routed through the proxy wallet.

Changes:
- Pass signature_type to approve and ctf commands in main.rs
- Add proxy wallet contract interface (IProxyWallet.exec) and helpers
  (resolve_proxy_address, proxy_exec) in auth.rs
- Route approve set calls through proxy.exec() when in proxy mode
- Use derived proxy address for approve check when in proxy mode
- Route ctf split/merge/redeem/redeem-neg-risk through proxy.exec()
  when in proxy mode
- Make ctf output block_number optional (proxy.exec returns only
  tx hash)

Fixes Polymarket#1, fixes Polymarket#4.
@mathitalend
Copy link

mathitalend commented Feb 24, 2026

polymarket approve set --signature-type proxy
this throws the below error
Error: Failed to approve USDC for CTF Exchange via proxy

The IProxyWallet interface used a non-existent `exec(address,bytes)`
function, causing all proxy-mode transactions to revert on-chain.

The actual Polymarket proxy wallet contract (deployed via the factory at
0xaB45c5A4B0c941a2F231C04C3f49182e1A254052) uses:

    function proxy(ProxyCall[] memory calls) external payable

where ProxyCall is (uint8 typeCode, address to, uint256 value, bytes data).

Replace the fabricated `exec` interface with the correct `proxy` function
and construct a single-element ProxyCall array with typeCode=1 (CALL) and
value=0 for each forwarded operation.

Fixes Polymarket#5 (comment)
@rursache
Copy link
Contributor Author

@cursor review again

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.

Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

@rursache
Copy link
Contributor Author

@mathitalend can you try again?

@mathitalend
Copy link

Tried. still same error

@mathitalend
Copy link

FYI. I am trying with the private key of my polymarket account created with gmail login. I imported that into polymarket CLI and trying

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

approve set and all on-chain commands ignore --signature-type proxy, send txs from EOA Redeem Issue

2 participants