Skip to content

feat(ctf): add support for proxy wallet when calling CTF contract#278

Open
jclmnop wants to merge 2 commits intoPolymarket:mainfrom
jclmnop:feat-proxy-wallet-ctf
Open

feat(ctf): add support for proxy wallet when calling CTF contract#278
jclmnop wants to merge 2 commits intoPolymarket:mainfrom
jclmnop:feat-proxy-wallet-ctf

Conversation

@jclmnop
Copy link
Copy Markdown
Contributor

@jclmnop jclmnop commented Mar 7, 2026

Problem

CTF client can currently only perform write operations (split/merge/redeem) for EOA type wallets. Read operations work for all types.

Solution

I added a wallet_type field to the CTF client (defaults to EOA so default behaviour isn't changed if user doesn't set it).

The send_call() method takes a call to the CTF contract and uses the appropriate mechanism to send the tx based on wallet type. send_call() is only used for split/merge/redeem.

For EOA type it doesn't do anything differently.

The reason I created a separate WalletType enum instead of using the existing SignatureType enum is because GNOSIS isn't yet implemented, and I wanted to limit the variants to types that are actually implemented. If GNOSIS is eventually implemented, then you can just re-use the signature type enum.

Also derived Deserialize on the enum so users can include it in their own configs etc (same for Serialize in case people want to be able to Serialize their own configs to another format or something).

Example usage

For EOA wallets, CTF initialisation is the same:

// Using with default (EOA) wallet type
let ctf = CtfClient::new(provider, ContractClient::CHAIN)?;
ctf.split_position(...).await?;

For proxy wallets, just one extra method is required when initialising the client:

// Using with proxy wallet type
let ctf = CtfClient::new(provider, ContractClient::CHAIN)?
    .with_wallet_type(WalletType::Proxy);
ctf.split_position(...).await?;

Added example usage to examples/ctf.rs.

Risk

Existing behaviour isn't changed. CTF client uses EOA by default, which makes contract calls in exactly the same way as before.

I've been using this implementation myself to do all 3 types of write calls (split, merge and redeem) with a proxy wallet and had no issues. Beforehand I couldn't make those calls using the CTF client with a proxy wallet.


fixes #277


Note

Medium Risk
Adds a new transaction-sending path that routes CTF write calls through a ProxyFactory, which can change how on-chain writes are executed and may fail on chains without the proxy contract configured.

Overview
CTF write operations (split, merge, redeem) can now be executed from proxy wallets. The CTF client gains a WalletType (defaulting to EOA) and a with_wallet_type builder to switch behavior.

When WalletType::Proxy is selected, write calls are wrapped into a ProxyCall and sent via a newly added IProxyFactory contract instance (wired from wallet_contract_config); EOA behavior remains direct call.send().

The examples/ctf.rs example is updated to accept an optional wallet type argument (e.g. proxy) for --write mode and initialize the client accordingly.

Written by Cursor Bugbot for commit 4733c46. This will update automatically on new commits. Configure here.

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 7, 2026

Codecov Report

❌ Patch coverage is 25.45455% with 41 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.10%. Comparing base (da07892) to head (4733c46).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
src/ctf/client.rs 25.45% 41 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #278      +/-   ##
==========================================
- Coverage   85.54%   85.10%   -0.44%     
==========================================
  Files          32       32              
  Lines        5167     5210      +43     
==========================================
+ Hits         4420     4434      +14     
- Misses        747      776      +29     
Flag Coverage Δ
rust 85.10% <25.45%> (-0.44%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@jclmnop jclmnop force-pushed the feat-proxy-wallet-ctf branch from 5afd623 to 2d6410a Compare March 7, 2026 12:48
@jclmnop jclmnop force-pushed the feat-proxy-wallet-ctf branch 2 times, most recently from 7343e7d to e48a19b Compare March 7, 2026 13:02
Copy link
Copy Markdown

@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.

@jclmnop jclmnop force-pushed the feat-proxy-wallet-ctf branch from e48a19b to dd84c39 Compare March 7, 2026 13:12
@jclmnop jclmnop force-pushed the feat-proxy-wallet-ctf branch from dd84c39 to e50d306 Compare March 7, 2026 13:15
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.

[Feature Request][CTF] Enable calling CTF contract with proxy wallets

1 participant