Skip to content

refactor(transaction-pay-controller): decouple Polymarket withdraw helpers from the Relay strategy - #10799

Merged
matthewwalsh0 merged 2 commits into
mainfrom
refactor/transaction-pay-polymarket-utils
Oct 13, 2026
Merged

matthewwalsh0 merged 2 commits into
mainfrom
refactor/transaction-pay-polymarket-utils

Conversation

@matthewwalsh0

@matthewwalsh0 matthewwalsh0 commented Oct 13, 2026 •

Copy link
Copy Markdown
Member

Explanation

The Polymarket withdraw helpers live under the Relay strategy and take Relay quotes and statuses, but the server strategy also needs them to support Predict withdraws. This is a refactor with no change in behaviour.

  • Moves strategy/relay/polymarket/ to utils/polymarket/.
  • The helpers no longer depend on Relay types:
    • Withdraw, simulation and sweep helpers take the deposit step calldata, source amount and a refund flag instead of a Relay quote or status.
    • getPolymarketDepositWalletOverrides returns the deposit wallet and source token, and the Relay strategy applies them to its request body.
    • The Safe address lookup takes a deposit-step flag, and the gas fee token account lookup has its own helper.
  • Relay deposit step lookups move to strategy/relay/deposit-step.ts.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Refactor with updated tests and call-site wiring; no intentional behavior change to payment or withdraw flows.

Overview
Decouples Polymarket Predict withdraw logic from Relay-specific types so the same helpers can be reused outside the Relay strategy (e.g. server strategy work in #10702). Behavior is intended to stay the same.

Polymarket code moves from strategy/relay/polymarket/ to utils/polymarket/. Withdraw, simulation, and sweep APIs now take plain inputs—deposit-step calldata, source amount, and an isRefund flag—instead of RelayQuote or Relay status strings. Quote-time deposit-wallet wiring is split: getPolymarketDepositWalletOverrides returns the wallet and USDC.e source token while relay-quotes mutates the Relay request body. Predict withdraw gas behavior is unchanged but callers pass a deposit-step flag into getPredictWithdrawSafeAddress and use new getPredictWithdrawFeeTokenAccount for fee-token lookup.

Relay-only deposit-step detection is centralized in new deposit-step.ts (hasRelayDepositStep, getRelayDepositData), with unit tests; Relay submit/validation pull deposit calldata through those helpers before calling Polymarket utils.

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

@matthewwalsh0 matthewwalsh0 changed the title refactor(transaction-pay-controller): move Polymarket withdraw helpers out of the Relay strategy refactor(transaction-pay-controller): decouple Polymarket withdraw helpers from the Relay strategy Oct 13, 2026
@matthewwalsh0

Copy link
Copy Markdown
Member Author

@metamaskbot publish-preview

@github-actions

Copy link
Copy Markdown
Contributor

Preview builds have been published. Learn how to use preview builds in other projects.

Expand for full list of packages and versions.
@metamask-previews/account-tree-controller@11.0.1-preview-a3a798b3a
@metamask-previews/accounts-controller@40.0.0-preview-a3a798b3a
@metamask-previews/address-book-controller@8.0.0-preview-a3a798b3a
@metamask-previews/advanced-chart-core@1.0.0-preview-a3a798b3a
@metamask-previews/ai-controllers@2.0.0-preview-a3a798b3a
@metamask-previews/analytics-controller@4.0.0-preview-a3a798b3a
@metamask-previews/analytics-data-regulation-controller@0.0.0-preview-a3a798b3a
@metamask-previews/announcement-controller@9.0.0-preview-a3a798b3a
@metamask-previews/app-metadata-controller@3.0.0-preview-a3a798b3a
@metamask-previews/approval-controller@10.0.0-preview-a3a798b3a
@metamask-previews/assets-controller@19.0.0-preview-a3a798b3a
@metamask-previews/assets-controllers@112.1.2-preview-a3a798b3a
@metamask-previews/authenticated-user-storage@4.1.0-preview-a3a798b3a
@metamask-previews/base-controller@10.0.0-preview-a3a798b3a
@metamask-previews/base-data-service@2.1.0-preview-a3a798b3a
@metamask-previews/bitcoin-regtest-up@2.0.0-preview-a3a798b3a
@metamask-previews/bridge-controller@82.0.3-preview-a3a798b3a
@metamask-previews/bridge-status-controller@76.3.5-preview-a3a798b3a
@metamask-previews/build-utils@4.0.0-preview-a3a798b3a
@metamask-previews/chain-agnostic-permission@2.0.0-preview-a3a798b3a
@metamask-previews/chomp-api-service@6.0.1-preview-a3a798b3a
@metamask-previews/claims-controller@1.0.3-preview-a3a798b3a
@metamask-previews/client-controller@2.0.0-preview-a3a798b3a
@metamask-previews/client-utils@3.0.4-preview-a3a798b3a
@metamask-previews/compliance-controller@3.0.0-preview-a3a798b3a
@metamask-previews/composable-controller@13.0.0-preview-a3a798b3a
@metamask-previews/config-registry-controller@5.0.0-preview-a3a798b3a
@metamask-previews/connectivity-controller@1.0.0-preview-a3a798b3a
@metamask-previews/controller-utils@13.0.0-preview-a3a798b3a
@metamask-previews/core-backend@12.1.0-preview-a3a798b3a
@metamask-previews/cryptography@1.1.2-preview-a3a798b3a
@metamask-previews/delegation-controller@4.0.0-preview-a3a798b3a
@metamask-previews/earn-controller@13.0.2-preview-a3a798b3a
@metamask-previews/eip-5792-middleware@4.0.1-preview-a3a798b3a
@metamask-previews/eip-7702-internal-rpc-middleware@1.0.0-preview-a3a798b3a
@metamask-previews/eip1193-permission-middleware@3.0.0-preview-a3a798b3a
@metamask-previews/eth-block-tracker@16.0.0-preview-a3a798b3a
@metamask-previews/eth-json-rpc-middleware@25.0.0-preview-a3a798b3a
@metamask-previews/eth-json-rpc-provider@7.0.0-preview-a3a798b3a
@metamask-previews/foundryup@2.0.0-preview-a3a798b3a
@metamask-previews/gas-fee-controller@27.0.0-preview-a3a798b3a
@metamask-previews/gator-permissions-controller@6.0.1-preview-a3a798b3a
@metamask-previews/geolocation-controller@2.0.0-preview-a3a798b3a
@metamask-previews/java-tron-up@2.0.0-preview-a3a798b3a
@metamask-previews/json-rpc-engine@11.0.0-preview-a3a798b3a
@metamask-previews/json-rpc-middleware-stream@9.0.0-preview-a3a798b3a
@metamask-previews/keyring-controller@28.1.0-preview-a3a798b3a
@metamask-previews/kyc-controller@0.8.0-preview-a3a798b3a
@metamask-previews/local-node-utils@2.0.0-preview-a3a798b3a
@metamask-previews/logging-controller@10.0.0-preview-a3a798b3a
@metamask-previews/message-manager@15.0.0-preview-a3a798b3a
@metamask-previews/messenger@3.0.0-preview-a3a798b3a
@metamask-previews/messenger-cli@1.0.0-preview-a3a798b3a
@metamask-previews/money-account-api-data-service@2.1.0-preview-a3a798b3a
@metamask-previews/money-account-balance-service@3.1.2-preview-a3a798b3a
@metamask-previews/money-account-controller@2.0.0-preview-a3a798b3a
@metamask-previews/money-account-upgrade-controller@5.1.0-preview-a3a798b3a
@metamask-previews/money-account-utils@2.1.0-preview-a3a798b3a
@metamask-previews/multichain-account-service@14.1.0-preview-a3a798b3a
@metamask-previews/multichain-api-middleware@5.0.0-preview-a3a798b3a
@metamask-previews/multichain-network-controller@4.0.0-preview-a3a798b3a
@metamask-previews/multichain-transactions-controller@8.0.0-preview-a3a798b3a
@metamask-previews/name-controller@10.0.0-preview-a3a798b3a
@metamask-previews/network-connection-banner-controller@1.0.0-preview-a3a798b3a
@metamask-previews/network-controller@37.0.1-preview-a3a798b3a
@metamask-previews/network-enablement-controller@7.0.2-preview-a3a798b3a
@metamask-previews/notification-services-controller@29.0.3-preview-a3a798b3a
@metamask-previews/passkey-controller@4.1.0-preview-a3a798b3a
@metamask-previews/permission-controller@14.0.0-preview-a3a798b3a
@metamask-previews/permission-log-controller@6.0.0-preview-a3a798b3a
@metamask-previews/perps-controller@20.0.0-preview-a3a798b3a
@metamask-previews/phishing-controller@18.2.0-preview-a3a798b3a
@metamask-previews/platform-api-docs@0.2.1-preview-a3a798b3a
@metamask-previews/polling-controller@17.0.0-preview-a3a798b3a
@metamask-previews/preferences-controller@24.0.0-preview-a3a798b3a
@metamask-previews/profile-controller@1.0.1-preview-a3a798b3a
@metamask-previews/profile-metrics-controller@5.1.3-preview-a3a798b3a
@metamask-previews/profile-sync-controller@34.0.3-preview-a3a798b3a
@metamask-previews/ramps-controller@27.0.1-preview-a3a798b3a
@metamask-previews/rate-limit-controller@8.0.0-preview-a3a798b3a
@metamask-previews/react-data-query@2.0.0-preview-a3a798b3a
@metamask-previews/remote-feature-flag-controller@7.0.0-preview-a3a798b3a
@metamask-previews/sample-controllers@6.0.0-preview-a3a798b3a
@metamask-previews/seedless-onboarding-controller@12.0.0-preview-a3a798b3a
@metamask-previews/selected-network-controller@27.0.0-preview-a3a798b3a
@metamask-previews/sentinel-api-service@2.1.0-preview-a3a798b3a
@metamask-previews/shield-controller@7.0.4-preview-a3a798b3a
@metamask-previews/signature-controller@40.0.0-preview-a3a798b3a
@metamask-previews/smart-transactions-controller@27.1.0-preview-a3a798b3a
@metamask-previews/snap-account-service@4.0.0-preview-a3a798b3a
@metamask-previews/social-controllers@3.7.0-preview-a3a798b3a
@metamask-previews/solana-test-validator-up@2.0.0-preview-a3a798b3a
@metamask-previews/stellar-quickstart-up@0.0.0-preview-a3a798b3a
@metamask-previews/storage-service@2.0.0-preview-a3a798b3a
@metamask-previews/subscription-controller@13.0.0-preview-a3a798b3a
@metamask-previews/transaction-controller@72.2.0-preview-a3a798b3a
@metamask-previews/transaction-pay-controller@30.1.0-preview-a3a798b3a
@metamask-previews/user-operation-controller@42.0.1-preview-a3a798b3a
@metamask-previews/utils@12.0.0-preview-a3a798b3a
@metamask-previews/wallet@17.0.0-preview-a3a798b3a
@metamask-previews/wallet-cli@0.0.0-preview-a3a798b3a

@matthewwalsh0
matthewwalsh0 added this pull request to the merge queue Oct 13, 2026
Merged via the queue into main with commit 0848250 Oct 13, 2026
350 checks passed
@matthewwalsh0
matthewwalsh0 deleted the refactor/transaction-pay-polymarket-utils branch October 13, 2026 16:07

This branch was successfully deployed

1 active deployment
default-branch — a3a798b3 Deployed Oct 13, 2026 by matthewwalsh0 via Determine whether this PR is a release PR #5419
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants