Skip to content

Add Across Predict withdraw quote support#8760

Merged
pedronfigueiredo merged 1 commit into
mainfrom
pnf/predict-withdraw-across-quotes
May 13, 2026
Merged

Add Across Predict withdraw quote support#8760
pedronfigueiredo merged 1 commit into
mainfrom
pnf/predict-withdraw-across-quotes

Conversation

@pedronfigueiredo
Copy link
Copy Markdown
Contributor

@pedronfigueiredo pedronfigueiredo commented May 11, 2026

Summary

This is PR 2 of 4 in the core stack for Predict withdraws over Across.

  • Adds Across quote construction for post-quote Predict withdraws.
  • Uses exact-input quotes without destination actions for the post-quote withdraw flow.
  • Preserves provider fees, target totals, and original transaction gas when normalizing quotes.
  • Re-quotes post-quote withdraws after reserving source token for source-chain gas paid with the source token.

Stack

  1. Add Across Predict withdraw plumbing #8759: plumbing to identify Predict Across withdraws
  2. This PR: quote support
  3. Add Across Predict withdraw submit support #8761: submit support
  4. Fix Across Predict withdraw gas payment edges #8762: gas payment edge cases

Validation

  • yarn workspace @metamask/transaction-pay-controller run jest --no-coverage src/strategy/across/across-quotes.test.ts src/strategy/across/AcrossStrategy.test.ts
  • Full stack validation was run on the final stacked branch:
    • yarn changelog:validate
    • yarn workspace @metamask/transaction-pay-controller run test
    • yarn workspace @metamask/transaction-controller run test

Note

Medium Risk
Medium risk because it changes Across quote construction and gas/fee calculations for post-quote Predict withdraw flows, including special-casing EIP-7702 authorization-list handling and multi-phase re-quoting logic that could affect pricing and execution safety.

Overview
Adds Across quote support for post-quote Predict withdraws, switching these requests to exactInput quoting with no destination actions and passing refundAddress through to the Across /swap/approval request.

Updates gas/fee normalization to include the original withdrawal transaction’s gas in sourceNetwork/gasLimits for post-quote quotes, and extends the existing two-phase “reserve source token for gas-fee-token” re-quote flow to also apply to post-quote Predict withdraws (now failing hard on unsafe/invalid phase-2 outcomes instead of falling back).

Relaxes Across strategy quote support checks to allow first-time EIP-7702 requiresAuthorizationList only for post-quote Predict withdraw quotes that have no embedded Across actions, and updates types/tests accordingly (including persisting actions in the quote’s original.request).

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

@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from a202a20 to f4feefb Compare May 11, 2026 11:28
@pedronfigueiredo pedronfigueiredo self-assigned this May 11, 2026
@pedronfigueiredo pedronfigueiredo marked this pull request as ready for review May 11, 2026 13:33
@pedronfigueiredo pedronfigueiredo requested review from a team as code owners May 11, 2026 13:33
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-plumbing branch from a4ae73b to 6077863 Compare May 11, 2026 13:51
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from f4feefb to 86b0f66 Compare May 11, 2026 13:54
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-plumbing branch from 6077863 to fc6f92e Compare May 12, 2026 09:56
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from 86b0f66 to 9fda0ef Compare May 12, 2026 09:58
Base automatically changed from pnf/predict-withdraw-across-plumbing to main May 12, 2026 10:16
pull Bot pushed a commit to dmrazzy/core that referenced this pull request May 12, 2026
## Summary

This is PR 1 of 4 in the core stack for Predict withdraws over Across.

- Adds `TransactionType.predictAcrossWithdraw`.
- Treats `isPostQuote` requests as actionable for Across support checks.
- Allows source-chain authorization lists only for post-quote Predict
withdraw detection, where the original withdraw is not encoded as an
Across destination action.
- Generalizes transaction-pay refund documentation from Relay-only
language to quote-provider language.

## Stack

1. This PR: plumbing to identify Predict Across withdraws
2. MetaMask#8760: quote support
3. MetaMask#8761: submit support
4. MetaMask#8762: gas payment edge cases

## Validation

- `yarn workspace @metamask/transaction-pay-controller run jest
--no-coverage src/strategy/across/AcrossStrategy.test.ts`
- Full stack validation was run on the final stacked branch:
  - `yarn changelog:validate`
  - `yarn workspace @metamask/transaction-pay-controller run test`
  - `yarn workspace @metamask/transaction-controller run test`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes Across quote eligibility logic to treat `isPostQuote` requests
as actionable and to allow EIP-7702 `authorizationList` only for a
specific Predict-withdraw post-quote path; misclassification could
incorrectly enable/disable Across quoting for some transactions.
> 
> **Overview**
> Introduces a new `TransactionType.predictAcrossWithdraw` to tag
Predict withdraws that will use Across.
> 
> Updates `AcrossStrategy.supports` to treat `isPostQuote` quote
requests as actionable and only accept them when the original
transaction is a Predict withdraw, plus adds
`hasUnsupportedTransactionAuthorizationList` to block EIP-7702
`authorizationList` usage except for the Predict-withdraw post-quote
detection case. Tests were extended to cover post-quote Predict withdraw
handling.
> 
> Minor docs/logic tweaks: `isAcrossQuoteRequest` now includes
`isPostQuote`, and `refundTo` comments were generalized from
Relay-specific wording to quote-provider wording.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
fc6f92e. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from 9fda0ef to d4b3bee Compare May 12, 2026 13:24
@pedronfigueiredo pedronfigueiredo force-pushed the pnf/predict-withdraw-across-quotes branch from d4b3bee to a65c549 Compare May 12, 2026 16:26
@pedronfigueiredo pedronfigueiredo added this pull request to the merge queue May 13, 2026
Merged via the queue into main with commit 71f9c2b May 13, 2026
366 checks passed
@pedronfigueiredo pedronfigueiredo deleted the pnf/predict-withdraw-across-quotes branch May 13, 2026 09:46
matthewwalsh0 added a commit that referenced this pull request May 13, 2026
… post-rebase

Re-adding the Polymarket deposit-wallet `Unreleased` entry that was
dropped during the rebase onto a base that now includes an Across
`Unreleased` addition (#8760) and the 22.3.1 release. Without this,
the merge-queue changelog diff check fails because the line we added
in this PR is missing from the post-merge "Unreleased" section.
@OGPoyraz OGPoyraz mentioned this pull request May 13, 2026
4 tasks
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>
matthewwalsh0 added a commit that referenced this pull request May 13, 2026
… post-rebase

Re-adding the Polymarket deposit-wallet `Unreleased` entry that was
dropped during the rebase onto a base that now includes an Across
`Unreleased` addition (#8760) and the 22.3.1 release. Without this,
the merge-queue changelog diff check fails because the line we added
in this PR is missing from the post-merge "Unreleased" section.
pull Bot pushed a commit to dmrazzy/core that referenced this pull request May 14, 2026
## Summary

This is PR 3 of 4 in the core stack for Predict withdraws over Across.

- Prepends the original Predict withdraw transaction when submitting
post-quote Across flows.
- Uses `TransactionType.predictAcrossWithdraw` for the Across deposit
leg.
- Forces 7702 batch submission when the parent withdraw transaction
already has an authorization list.
- Estimates final 7702 submit gas when the submit-time batch shape
differs from the quote-time batch shape.
- Moves original transaction gas parsing into a shared Across helper
used by quote and submit paths.

## Stack

1. MetaMask#8759: plumbing to identify Predict Across withdraws
2. MetaMask#8760: quote support
3. This PR: submit support
4. MetaMask#8762: gas payment edge cases

## Validation

- `yarn workspace @metamask/transaction-pay-controller run jest
--no-coverage src/strategy/across/across-submit.test.ts
src/strategy/across/across-quotes.test.ts
src/strategy/across/AcrossStrategy.test.ts`
- Full stack validation was run on the final stacked branch:
  - `yarn changelog:validate`
  - `yarn workspace @metamask/transaction-pay-controller run test`
  - `yarn workspace @metamask/transaction-controller run test`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Modifies Across submission logic for post-quote flows, including 7702
batch handling and gas estimation, which can impact how transactions are
constructed and sent on-chain.
> 
> **Overview**
> Adds Across *submit-time* support for post-quote Predict withdraws by
optionally prepending the original user transaction to the submitted
payload and mapping the bridge leg to
`TransactionType.predictAcrossWithdraw`.
> 
> Updates 7702 handling to force batch submission when needed (quoted
combined gas limit, parent `authorizationList`, or gas-fee-token
post-quote Predict withdraw), and can estimate a final `gasLimit7702`
via `TransactionController:estimateGasBatch` with feature-flag gas
buffer when the quoted batch shape doesn’t match the actual submit
shape.
> 
> Passes `gasFeeToken` plus `excludeNativeTokenForFee` through to single
and batch submits, expands tests around these scenarios, and moves
original-transaction gas parsing into a shared helper
(`getOriginalTransactionGas`) reused by both quote and submit paths.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
df05cc8. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
pull Bot pushed a commit to dmrazzy/core that referenced this pull request May 15, 2026
## Summary

This is PR 4 of 4 in the core stack for Predict withdraws over Across.

- Fixes TransactionController gas-fee-token publishing when native token
usage is explicitly excluded.
- Handles Across gas-station edge cases for post-quote Predict
withdraws, including source-token gas pricing fallback when the gas
station cannot price the token directly.
- Caps prefunded post-quote Predict withdraw gas estimates at the
configured Across fallback when batch simulation inflates the estimate.
- Keeps transaction-pay-controller coverage at 100% and exercises the
transaction-controller gas-fee-token path.

## Stack

1. MetaMask#8759: plumbing to identify Predict Across withdraws
2. MetaMask#8760: quote support
3. MetaMask#8761: submit support
4. This PR: gas payment edge cases

## Validation

- `yarn workspace @metamask/transaction-pay-controller run jest
--no-coverage src/strategy/across/across-quotes.test.ts
src/strategy/across/across-submit.test.ts
src/strategy/across/AcrossStrategy.test.ts`
- `yarn workspace @metamask/transaction-controller run jest
--no-coverage src/utils/gas-fee-tokens.test.ts`
- `yarn changelog:validate`
- `yarn workspace @metamask/transaction-pay-controller run test`
- `yarn workspace @metamask/transaction-controller run test`

<!-- CURSOR_SUMMARY -->
---

> [!NOTE]
> **Medium Risk**
> Changes transaction publishing and Across quote fee estimation logic
around gas-fee tokens and EIP-7702, which can affect whether
transactions are priced and signed correctly in edge cases.
> 
> **Overview**
> Fixes gas-fee-token handling when publishing transactions that
explicitly set `excludeNativeTokenForFee`, ensuring the pre-publish
check skips native-balance logic and forces `isExternalSign`/nonce
clearing when a gas fee token is selected.
> 
> Improves Across post-quote Predict-withdraw fee calculation by (1)
capping inflated prefunded EIP-7702 batch gas estimates to the
configured Across fallback, (2) falling back to fiat-derived
source-token gas pricing when the gas station can’t price the source
token, and (3) preferring source-token gas pricing for post-quote
Predict withdraws (while keeping native-gas pricing when the account
can’t use 7702). Tests were expanded to cover these new paths and edge
cases.
> 
> <sup>Reviewed by [Cursor Bugbot](https://cursor.com/bugbot) for commit
2d30cef. Bugbot is set up for automated
code reviews on this repo. Configure
[here](https://www.cursor.com/dashboard/bugbot).</sup>
<!-- /CURSOR_SUMMARY -->
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.

2 participants