Skip to content

fix: route approve and CTF operations through proxy wallet factory#62

Open
suhailkakar wants to merge 6 commits intomainfrom
fix-ctf-proxy-operation
Open

fix: route approve and CTF operations through proxy wallet factory#62
suhailkakar wants to merge 6 commits intomainfrom
fix-ctf-proxy-operation

Conversation

@suhailkakar
Copy link
Copy Markdown
Member

@suhailkakar suhailkakar commented Apr 5, 2026

Note

Medium Risk
Changes how on-chain transactions are constructed and sent for approve and ctf commands, including a new proxy-wallet execution path, which could impact transaction success or target address selection. Scope is limited to these commands and dependency/feature wiring.

Overview
Routes approve and state-changing ctf operations through the Polymarket proxy wallet factory when signature_type resolves to proxy.

This adds a shared commands::proxy helper that either wraps calldata in a factory proxy(...) call or sends a raw TransactionRequest, and updates approve set plus ctf split/merge/redeem/redeem-neg-risk to build ABI calldata via sol! + SolCall and submit via proxy::send_call.

approve check now defaults to checking allowances/approvals for the derived proxy wallet address in proxy mode, and the CLI wiring passes signature_type through to approve and ctf. Dependency config is adjusted to enable Alloy rpc-types support.

Reviewed by Cursor Bugbot for commit 41f965b. Bugbot is set up for automated code reviews on this repo. Configure here.

@suhailkakar
Copy link
Copy Markdown
Member Author

suhailkakar commented Apr 5, 2026

fixes #1 #4 #24 #46 #47

@suhailkakar suhailkakar changed the title fix: route CTF operations through proxy wallet factory fix: route approve and CTF operations through proxy wallet factory Apr 5, 2026
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.

Autofix Details

Bugbot Autofix prepared a fix for the issue found in the latest run.

  • ✅ Fixed: Redundant send_via_factory duplicates proxy path in send_call
    • Removed send_via_factory function and replaced its calls with send_call(use_proxy=true), eliminating code duplication and inefficient provider creation in the approval loop.

Create PR

Or push these changes by commenting:

@cursor push ee4bedd305
Preview (ee4bedd305)
diff --git a/src/commands/approve.rs b/src/commands/approve.rs
--- a/src/commands/approve.rs
+++ b/src/commands/approve.rs
@@ -170,7 +170,7 @@
                 value: U256::MAX,
             }
             .abi_encode();
-            let tx_hash = proxy::send_via_factory(private_key, USDC_ADDRESS, calldata)
+            let (tx_hash, _) = proxy::send_call(private_key, true, USDC_ADDRESS, calldata)
                 .await
                 .context(format!("Failed USDC approval for {}", target.name))?;
 
@@ -191,9 +191,10 @@
                 approved: true,
             }
             .abi_encode();
-            let tx_hash = proxy::send_via_factory(private_key, config.conditional_tokens, calldata)
-                .await
-                .context(format!("Failed CTF approval for {}", target.name))?;
+            let (tx_hash, _) =
+                proxy::send_call(private_key, true, config.conditional_tokens, calldata)
+                    .await
+                    .context(format!("Failed CTF approval for {}", target.name))?;
 
             match output {
                 OutputFormat::Table => print_tx_result(step, total, &label, tx_hash),

diff --git a/src/commands/mod.rs b/src/commands/mod.rs
--- a/src/commands/mod.rs
+++ b/src/commands/mod.rs
@@ -40,30 +40,6 @@
             .ok_or_else(|| anyhow::anyhow!("Proxy wallet derivation not supported on this chain"))
     }
 
-    pub async fn send_via_factory(
-        private_key: Option<&str>,
-        target: Address,
-        calldata: Vec<u8>,
-    ) -> Result<B256> {
-        let provider = auth::create_provider(private_key).await?;
-        let factory = IProxyWallet::new(PROXY_FACTORY, &provider);
-        let call = IProxyWallet::ProxyCall {
-            typeCode: 1,
-            to: target,
-            value: U256::ZERO,
-            data: calldata.into(),
-        };
-        let tx_hash = factory
-            .proxy(vec![call])
-            .send()
-            .await
-            .context("Failed to send proxy transaction")?
-            .watch()
-            .await
-            .context("Failed to confirm proxy transaction")?;
-        Ok(tx_hash)
-    }
-
     pub async fn send_call(
         private_key: Option<&str>,
         use_proxy: bool,

This Bugbot Autofix run was free. To enable autofix for future PRs, go to the Cursor dashboard.

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.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 0c63aca. Configure here.

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.

1 participant