Skip to content

feat: withdraw before swap - #11181

Open
micaelae wants to merge 2 commits into
swaps5253-deposit-after-swapfrom
swaps5257-withdraw-before-swap
Open

micaelae wants to merge 2 commits into
swaps5253-deposit-after-swapfrom
swaps5257-withdraw-before-swap

Conversation

@micaelae

@micaelae micaelae commented Oct 29, 2026 •

Copy link
Copy Markdown
Member

Explanation

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

Medium Risk
Touches money-account vault withdrawals, batched transaction submission, and follow-up swap quote refresh—failure modes can block funds movement or use stale quotes, though heavily covered by new tests.

Overview
Adds money-account withdraw as a first-class unified swap/bridge path: a new submitWithdrawHandler builds vault withdraw + transfer batches (MM Pay approval, optional gas sponsorship on Monad), records withdrawTxMeta on history, and can skip a follow-up swap when the destination is the vault underlying token.

BridgeStatusController routes moneyAccountWithdraw / nested withdraw txs through withdrawUpdateHandler, matches history by withdraw batch id, and on confirmation chains into the existing swap/bridge submit path—using resolveValidQuotes to refresh stale swap quotes via BridgeController:fetchQuotes and getQuoteRefreshRate (now exported from bridge-controller and used for polling intervals). Guards reduce duplicate next-step execution and treat “swap already started” as a silent skip.

Supporting updates include withdrawTxMeta on types/history merge, MM Pay isPostQuote for withdraws, and broad withdraw-focused tests.

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

@micaelae
micaelae requested a review from a team as a code owner October 29, 2026 00:04
@micaelae
micaelae added this pull request to stack #11182 October 29, 2026 00:05

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch from b8991f0 to e3dcbe9 Compare October 29, 2026 21:38
@micaelae
micaelae requested a review from a team as a code owner October 29, 2026 21:38
@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch 11 times, most recently from b666cb9 to 22c2ba1 Compare November 9, 2026 22:09
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from f0351df to 5f12462 Compare November 9, 2026 22:11

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch from 22c2ba1 to 13bef43 Compare November 9, 2026 23:45
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from 5f12462 to db05697 Compare November 10, 2026 00:18

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch 2 times, most recently from 09a7d62 to bb21fb1 Compare November 10, 2026 00:55
@micaelae
micaelae removed this pull request from stack #11182 November 10, 2026 00:55
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from db05697 to 96fa7a9 Compare November 10, 2026 00:57
@micaelae
micaelae added this pull request to stack #11404 November 10, 2026 00:57
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch 2 times, most recently from 48869aa to a327498 Compare November 10, 2026 17:43

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@micaelae
micaelae requested a review from a team as a code owner November 12, 2026 18:05
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from d2acc75 to ec4b08d Compare November 12, 2026 23:47

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch from 7ceef20 to bebaf0e Compare November 13, 2026 00:01
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch 2 times, most recently from 71e38c9 to 33bb8f7 Compare November 13, 2026 00:02
@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch from bebaf0e to c6e0de7 Compare November 13, 2026 18:37
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from 33bb8f7 to 2f27c02 Compare November 13, 2026 18:37
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🛑 Files requiring codeowner review

To merge this PR, you'll need to get approvals from the following owners.

@MetaMask/swaps-engineers (21 files)
  • packages/bridge-controller/CHANGELOG.md
  • packages/bridge-controller/src/bridge-controller.ts
  • packages/bridge-controller/src/index.ts
  • packages/bridge-controller/src/utils/feature-flags.ts
  • packages/bridge-status-controller/src/__fixtures__/test-utils.ts
  • packages/bridge-status-controller/src/bridge-status-controller.ts
  • packages/bridge-status-controller/src/bridge-status-controller.withdraw.test.ts
  • packages/bridge-status-controller/src/strategy/index.ts
  • packages/bridge-status-controller/src/strategy/types.ts
  • packages/bridge-status-controller/src/strategy/withdraw-strategy.ts
  • packages/bridge-status-controller/src/types.ts
  • packages/bridge-status-controller/src/utils/approval.test.ts
  • packages/bridge-status-controller/src/utils/bridge.test.ts
  • packages/bridge-status-controller/src/utils/bridge.ts
  • packages/bridge-status-controller/src/utils/history.test.ts
  • packages/bridge-status-controller/src/utils/history.ts
  • packages/bridge-status-controller/src/utils/subscriptions.test.ts
  • packages/bridge-status-controller/src/utils/subscriptions.ts
  • packages/bridge-status-controller/src/utils/transaction-pay.test.ts
  • packages/bridge-status-controller/src/utils/transaction-pay.ts
  • packages/bridge-status-controller/src/utils/transaction.ts

ℹ️ Files co-owned by @MetaMask/core-platform (expand for more)

[!NOTE]
For convenience in maintaining this repo, @MetaMask/core-platform co-owns
the following files. It is not required to seek approval from
@MetaMask/core-platform to change these files. This section is purely
informational.

  • packages/bridge-controller/CHANGELOG.md

@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from 2f27c02 to b67a42e Compare November 16, 2026 21:05
@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch 2 times, most recently from 64aed53 to 49149aa Compare November 16, 2026 21:47
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch 2 times, most recently from 268c98b to 8054b4a Compare November 17, 2026 00:34

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

srcChainId: quote.srcChainId,
destChainId: quote.destChainId,
srcTokenAmount: quote.srcTokenAmount,
slippage: slippagePercentage || quote.slippage,

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Zero slippage dropped on quote refresh

Low Severity

resolveValidQuotes builds the refresh request with slippagePercentage || quote.slippage. A user-selected slippage of 0 is treated as missing, so the follow-up swap can refresh with a different slippage than the one that was confirmed.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 8054b4a. Configure here.

@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch from 7a99d50 to de66319 Compare November 17, 2026 18:37
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from 8054b4a to 4b4a949 Compare November 17, 2026 18:39
@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch 3 times, most recently from 9a295e5 to df7a919 Compare November 18, 2026 01:15
@micaelae
micaelae removed this pull request from stack #11404 November 18, 2026 01:16
@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch from df7a919 to 3c8eec3 Compare November 18, 2026 17:34
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from 4b4a949 to 85256fd Compare November 18, 2026 17:38

@cursor cursor Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale Bugbot comment from a previous run.

@micaelae
micaelae force-pushed the swaps5253-deposit-after-swap branch 2 times, most recently from 03cbb02 to 0bb218b Compare November 18, 2026 18:38
@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from 85256fd to ed99e15 Compare November 18, 2026 18:39

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

There are 3 total unresolved issues (including 2 from previous reviews).

Fix All in Cursor

❌ 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 ed99e15. Configure here.

@micaelae
micaelae force-pushed the swaps5257-withdraw-before-swap branch from ed99e15 to c54a23b Compare November 19, 2026 01:27

This branch has not been deployed

No deployments
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.

1 participant