Repository navigation
feat(transaction-pay-controller): support Predict withdraw in the server strategy - #10702
Open
matthewwalsh0 wants to merge 9 commits into
Open
matthewwalsh0 wants to merge 9 commits into
matthewwalsh0 wants to merge 9 commits into
Conversation
matthewwalsh0
force-pushed
the
feat/transaction-pay-non-atomic-second-leg
branch
2 times, most recently
from
October 11, 2026 12:33
5429248 to
fd5bbe3
Compare
Base automatically changed from
feat/transaction-pay-non-atomic-second-leg
to
main
October 12, 2026 12:49
matthewwalsh0
force-pushed
the
feat/server-predict-withdraw
branch
from
October 12, 2026 14:05
be6b5f1 to
328268a
Compare
2 of 4 tasks
matthewwalsh0
force-pushed
the
feat/server-predict-withdraw
branch
from
October 13, 2026 08:54
74d3df6 to
f4c739d
Compare
matthewwalsh0
changed the base branch from
main
to
refactor/transaction-pay-polymarket-utils
October 13, 2026 08:54
matthewwalsh0
force-pushed
the
feat/server-predict-withdraw
branch
from
October 13, 2026 09:02
f4c739d to
66d1986
Compare
Merged
2 of 4 tasks
matthewwalsh0
force-pushed
the
feat/server-predict-withdraw
branch
from
October 13, 2026 11:47
66d1986 to
021f983
Compare
matthewwalsh0
changed the base branch from
refactor/transaction-pay-polymarket-utils
to
refactor/transaction-pay-post-quote
October 13, 2026 11:47
matthewwalsh0
force-pushed
the
refactor/transaction-pay-post-quote
branch
from
October 14, 2026 13:29
f35a6de to
ea9634a
Compare
matthewwalsh0
force-pushed
the
feat/server-predict-withdraw
branch
2 times, most recently
from
October 14, 2026 13:42
d5c0f89 to
adcc810
Compare
matthewwalsh0
force-pushed
the
refactor/transaction-pay-post-quote
branch
from
October 14, 2026 13:49
3ed4f55 to
f5b1abf
Compare
matthewwalsh0
force-pushed
the
feat/server-predict-withdraw
branch
from
October 14, 2026 13:52
adcc810 to
8e4b9bc
Compare
Naz-Ovh
pushed a commit
to 0x-fork/metamask-core
that referenced
this pull request
Oct 15, 2026
…lpers from the Relay strategy (MetaMask#10799) ## 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 - [x] I've updated the test suite for new or updated code as appropriate - [x] 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](https://github.com/MetaMask/core/tree/main/docs/processes/updating-changelogs.md) - [ ] I've introduced [breaking changes](https://github.com/MetaMask/core/tree/main/docs/processes/breaking-changes.md) in this PR and have prepared draft pull requests for clients and consumer packages to resolve them <!-- CURSOR_SUMMARY --> --- > [!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 MetaMask#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. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit a3a798b. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY -->
…polymarket deposit wallet withdraws
…y plain token transfer calldata
…quires a plain transfer step
…the quote gas module
matthewwalsh0
force-pushed
the
feat/server-predict-withdraw
branch
from
October 16, 2026 05:40
8e4b9bc to
e27abb2
Compare
matthewwalsh0
marked this pull request as ready for review
October 17, 2026 00:20
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 2 potential issues.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit e27abb2. Configure here.
This branch was successfully deployed
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.

Explanation
The server strategy declined Predict withdraws, so they could only be quoted and submitted through the Relay strategy.
refundTo, and gas estimation and gas fee token lookups use the Safe that holds the source token.useDepositAddress. On submit, the Polymarket relayer unwraps pUSD directly to the provider deposit address, then any leftover or refunded USDC.e is swept back to the deposit wallet. No source network fee is charged, as the relayer pays origin gas.useDepositAddress. The deposit step is identified as a plain ERC-20transferwith no extra calldata or native value, and deposit-address quotes without one are ignored.References
Checklist
Note
High Risk
Changes core server quote/submit orchestration for withdraws, refunds, multi-leg settlement, and Polymarket relayer paths where incorrect gas, recipient, or sweep timing could mis-route funds or double-execute calls.
Overview
Server strategy now handles Predict withdraw instead of leaving those flows to Relay. Quoting and submission paths were extended for Safe, Polymarket deposit wallet, and non-atomic payment overrides.
Safe / legacy Predict withdraw: post-quote requests pass
refundToto the server; source gas usesestimateSourceGas(including the original tx), with deposit routes estimated from the Safe and fee-token lookups on the Safe account.Polymarket deposit wallet: quotes use
useDepositAddress, USDC.e from the deposit wallet as sender/refund, and no gasless flag; only quotes with a plain ERC-20transferdeposit step are kept (deposit-step.ts). Submit replaces quote steps withsubmitPolymarketWithdrawto the deposit address, zeros user origin fees, sweeps leftover/refunded USDC.e after polling, andPolymarketDepositWalletis removed from server unsupported reasons.Non-atomic overrides (e.g. Money Account): settlement recipient comes from the override;
requiresSecondLegis true; override calls are not embedded in the quote batch but built in the second leg viagetCalls. Post-quote flows can re-quote the same provider to reserve gas paid in the source token.Submit also assigns leading gas limits to prepended post-quote txs, skips prepending override calls when
atomic === false, and returns terminal intent status from polling so deposit-wallet sweep can run before failures are surfaced.Reviewed by Cursor Bugbot for commit e27abb2. Bugbot is set up for automated code reviews on this repo. Configure here.