fix: use derive_safe_wallet instead of derive_proxy_wallet for default proxy derivation#22
Open
pck101001 wants to merge 1 commit intoPolymarket:mainfrom
Open
fix: use derive_safe_wallet instead of derive_proxy_wallet for default proxy derivation#22pck101001 wants to merge 1 commit intoPolymarket:mainfrom
pck101001 wants to merge 1 commit intoPolymarket:mainfrom
Conversation
…t proxy derivation The CLI used derive_proxy_wallet (EIP-1167 minimal proxy) to derive the proxy wallet address, but Polymarket deploys Gnosis Safe wallets for browser wallet users. This caused the derived address to not match the actual proxy wallet returned by the profiles API. Changes: - Default signature_type from "proxy" to "gnosis-safe" - Replace all derive_proxy_wallet calls with derive_safe_wallet in wallet.rs and setup.rs - Decouple parse_signature_type from DEFAULT_SIGNATURE_TYPE constant to avoid incorrect mapping after the default change Users can still use --signature-type proxy for Magic Link accounts. Fixes Polymarket#14
There was a problem hiding this comment.
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.
| let proxy_addr = signer | ||
| .as_ref() | ||
| .and_then(|s| derive_proxy_wallet(s.address(), POLYGON)) | ||
| .and_then(|s| derive_safe_wallet(s.address(), POLYGON)) |
There was a problem hiding this comment.
Proxy mode derivation is ignored
Medium Severity
derive_safe_wallet is now used unconditionally in wallet and setup, so derived proxy output no longer follows the configured signature_type. When users intentionally use proxy (Magic Link), proxy_address and deposit guidance can point to the wrong derived wallet despite --signature-type proxy being set.
Additional Locations (2)
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.


Summary
derive_proxy_wallet(EIP-1167) withderive_safe_wallet(Gnosis Safe) as the default proxy wallet derivationDEFAULT_SIGNATURE_TYPEfrom"proxy"to"gnosis-safe"--signature-type proxyfor Magic Link accountsProblem
The CLI derives the proxy wallet address using
derive_proxy_wallet()(EIP-1167 minimal proxy, factory0xaB45...), but Polymarket deploys Gnosis Safe wallets (factory0xaacF...) for browser wallet users. The two derivation methods use different salt encoding, factory addresses, and init code hashes, producing completely different addresses for the same EOA.This causes:
wallet showdisplaying the wrong proxy addressclob balancereturning 0 (querying wrong address)approve setapproving the wrong addresssetupwizard directing users to deposit to the wrong addressChanges
src/config.rsDEFAULT_SIGNATURE_TYPE:"proxy"→"gnosis-safe"src/commands/wallet.rsderive_proxy_wallet→derive_safe_wallet; default--signature-type→"gnosis-safe"src/commands/setup.rsderive_proxy_wallet→derive_safe_walletsrc/auth.rsparse_signature_typefromDEFAULT_SIGNATURE_TYPEconstant to prevent incorrect mappingVerification
Test plan
cargo test— all 143 tests pass (94 unit + 49 integration)polymarket wallet showdisplays the correct Gnosis Safe proxy addresspolymarket clob balancereturns the actual balance--signature-type proxystill works for Magic Link accountsFixes #14
Note
Medium Risk
Medium risk because it changes the default signature type and proxy-address derivation used for deposits/approvals and balance lookups, which could alter user-visible addresses for existing setups if they relied on the prior default.
Overview
Updates the CLI to derive and display proxy wallet addresses using
derive_safe_wallet(Gnosis Safe) instead ofderive_proxy_wallet, including in the setup wizard andwalletcommands.Changes the default signature type from
proxytognosis-safe(CLI defaults andDEFAULT_SIGNATURE_TYPE), and adjusts signature-type parsing to map the literal"proxy"string rather than tying behavior to the default constant.Written by Cursor Bugbot for commit 0c55155. This will update automatically on new commits. Configure here.