fix(transaction-pay-controller, transaction-controller): support Predict same-chain withdraw on swap-only Relay routes#8735
Merged
Conversation
matthewwalsh0
previously requested changes
May 8, 2026
53d29bd to
3157ea4
Compare
c7b3e5f to
d321241
Compare
…ess Predict same-chain withdraw on swap-only Relay routes
d321241 to
8c1c30a
Compare
I've resolved the comment and tested it. We want to merge it shortly to avoid changelog conflicts that keep happening.
matthewwalsh0
approved these changes
May 12, 2026
pull Bot
pushed a commit
to Reality2byte/core
that referenced
this pull request
May 13, 2026
## Explanation Release `980.0.0` with minor version bumps for: - **`@metamask/transaction-controller`** `65.3.0` → `65.4.0` - **`@metamask/transaction-pay-controller`** `22.3.1` → `22.4.0` ### `@metamask/transaction-controller@65.4.0` #### Added - Add optional `fiat` object (with `orderId` and `provider` properties) to `MetamaskPayMetadata` type for persisting fiat on-ramp order data on transactions - Add `predictAcrossWithdraw` to the `TransactionType` enum #### Changed - `estimateGasBatch` now falls back to the sum of per-tx `gas` values in the EIP-7702 path when node simulation fails, instead of returning the block-gas-limit fallback - Bump `@metamask/network-controller` from `^31.0.0` to `^32.0.0` - Bump `@metamask/accounts-controller` from `^38.1.0` to `^38.1.1` - Bump `@metamask/controller-utils` from `^12.0.0` to `^12.1.0` ### `@metamask/transaction-pay-controller@22.4.0` #### Added - Add Across quote support for post-quote Predict withdraw flows #### Changed - Derive fiat order source amount from on-chain transaction data (`order.txHash`) with fallback to `order.cryptoAmount` - Persist fiat order ID and provider code on `transaction.metamaskPay` before polling, so activity views can query order status after controller state cleanup - Bump `@metamask/assets-controller` from `^7.1.1` to `^7.1.2` - Bump `@metamask/assets-controllers` from `^108.0.0` to `^108.1.0` #### Fixed - For postquote payments payment token for MM Pay transaction should not be reset when accountOverride is changed ### Dependency updates 14 packages had their `@metamask/transaction-controller` dependency range updated from `^65.3.0` to `^65.4.0` with corresponding changelog entries under `[Unreleased]`: - `@metamask/assets-controller` - `@metamask/assets-controllers` - `@metamask/bridge-controller` - `@metamask/bridge-status-controller` - `@metamask/earn-controller` - `@metamask/eip-5792-middleware` - `@metamask/gator-permissions-controller` - `@metamask/network-enablement-controller` - `@metamask/perps-controller` - `@metamask/phishing-controller` - `@metamask/profile-metrics-controller` - `@metamask/shield-controller` - `@metamask/subscription-controller` - `@metamask/user-operation-controller` ## References - [MetaMask#8694](MetaMask#8694) — Add fiat on-ramp order data persistence on transactions - [MetaMask#8759](MetaMask#8759) — Add `predictAcrossWithdraw` transaction type - [MetaMask#8735](MetaMask#8735) — EIP-7702 gas estimation fallback improvements - [MetaMask#8760](MetaMask#8760) — Across quote support for post-quote Predict withdraw - [MetaMask#8787](MetaMask#8787) — Fix payment token reset on accountOverride change ## 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 - [x] 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] > **Medium Risk** > Mainly a release/version bump, but it pulls in updated `@metamask/transaction-controller` behavior (gas estimation fallback, new metadata/type fields) across many dependent controllers, which could affect transaction handling paths. > > **Overview** > Bumps the monorepo release to `980.0.0`, publishes `@metamask/transaction-controller@65.4.0`, and publishes `@metamask/transaction-pay-controller@22.4.0` (with corresponding changelog link updates). > > Propagates the `@metamask/transaction-controller` dependency range from `^65.3.0` to `^65.4.0` across multiple packages (e.g. assets/bridge/network-enablement/perps/phishing/shield/subscription/user-operation controllers) and records the bumps in each package’s `[Unreleased]` changelog entries, with `yarn.lock` updates to match. > > <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit 699b516. Bugbot is set up for automated code reviews on this repo. Configure [here](https://www.cursor.com/dashboard/bugbot).</sup> <!-- /CURSOR_SUMMARY --> --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
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
Since the Polymarket pUSD migration on April 28 2026, Predict same-chain withdraws on Polygon (e.g. pUSD → USDC) sometimes fail with
transaction gas limit too high (cap: 33554432, tx: 42121000).Two interacting bugs:
transaction-pay-controller—calculateSourceNetworkCostalways usesfromOverride = Safe proxyfor Predict withdraws. That works for deposit-style Relay routes but breaks for the swap-aggregator routes that same-chain destinations now use post-migration: DEX aggregators reject contract callers (anti-MEVmsg.sender == tx.originchecks etc.), so the swap step reverts in simulation.transaction-controller—estimateGasBatch's 7702 path always callsestimateGas, even when every batch entry already has agasvalue. The non-7702 path has had anallTransactionsHaveGasshort-circuit since #7405; the 7702 path was missed. When TPC tries the EOAfrom, the swap sub-call reverts (EOA has no source token until the prependedSafe.execTransactionsub-call runs mid-batch), the whole 7702 batch falls back to ~block-gas-limit × buffer ≈ 42M, and Polygon's per-txgascaprejects it.Fix
relay-quotes.ts: gatefromOverride = Safe proxyon the route having adepositstep. Same-chain swap routes use the relay params' EOAfrominstead. Gas-fee-token lookup keeps using the Safe proxy (gated onisPredictWithdraw && refundTo) so the gasless flow still works for users with 0 POL.constants.ts: addPOLYGON_PUSD_ADDRESSand include it inSTABLECOINS[Polygon]for correct stablecoin display.gas.ts: mirror the existing non-7702 short-circuit in the 7702 branch — when every transaction has a providedgas, sum them and skip simulation.Verified end-to-end on mobile (yalc-linked): Polygon pUSD → USDC withdraw produces a sane fee both with POL and gasless (paid in pUSD). BNB cross-chain unchanged.
References
N/A
Checklist
Note
Medium Risk
Changes gas estimation behavior for EIP-7702 batches and alters Relay quote simulation
fromselection for Predict withdraws; mistakes could impact fee estimation and transaction success for these flows.Overview
Fixes Predict same-chain withdraws on swap-only Relay routes by gating the Safe-proxy
fromoverride to only routes that include adepositstep, while still using the Safe proxy for gas-fee-token eligibility checks.Updates
estimateGasBatch’s EIP-7702 path to fallback to summed caller-provided per-txgaslimits when node simulation fails (instead of block-gas-limit fallback), via a newgetProvidedBatchGasLimitshelper and added test coverage.Adds
POLYGON_PUSD_ADDRESSand includes it in PolygonSTABLECOINSfor stablecoin display/fiat-rate handling, with new constants tests.Reviewed by Cursor Bugbot for commit 8c1c30a. Bugbot is set up for automated code reviews on this repo. Configure here.