Skip to content

feat(perps): wire Perps Withdraw button to feature-flagged confirmation flow#28265

Merged
dan437 merged 4 commits intomainfrom
perps-withdraw-new-ui-flow
Apr 2, 2026
Merged

feat(perps): wire Perps Withdraw button to feature-flagged confirmation flow#28265
dan437 merged 4 commits intomainfrom
perps-withdraw-new-ui-flow

Conversation

@dan437
Copy link
Copy Markdown
Contributor

@dan437 dan437 commented Apr 1, 2026

Description

Adds the full Perps Withdraw "to any token" feature, allowing users to withdraw Perps funds to any supported token via MetaMask Pay and the Relay bridge, instead of only withdrawing native USDC through HyperLiquid's 5-minute bridge.

Changelog

CHANGELOG entry: Added feature-flagged "withdraw to any token" flow for Perps, allowing users to withdraw Perps funds to any supported token via MetaMask Pay

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/CONF-1121

Manual testing steps

Feature: Perps Withdraw to any token

  Scenario: user withdraws via the new confirmation flow (flag enabled)
    Given the user has a Perps balance
    And the confirmations_pay_post_quote remote flag has overrides.perpsWithdraw.enabled = true
    When user taps "Withdraw" on the Perps home page
    Then the full-screen CustomAmount confirmation UI is shown
    And the available Perps balance is displayed
    And the user can select a receive token via the "Receive as" picker
    And confirming the withdrawal triggers the MetaMask Pay flow

  Scenario: user withdraws via the legacy flow (flag disabled)
    Given the user has a Perps balance
    And the confirmations_pay_post_quote remote flag has overrides.perpsWithdraw.enabled = false or is missing
    When user taps "Withdraw" on the Perps home page
    Then the legacy PerpsWithdrawView is shown

  Scenario: developer triggers Perps withdraw from Developer Options
    Given the user has Developer Options enabled in Settings
    When user navigates to Settings > Developer Options > Perps Withdraw and taps "Withdraw"
    Then the full-screen CustomAmount confirmation UI is shown regardless of feature flag state

  Scenario: perpsWithdraw transaction appears in activity
    Given a perpsWithdraw transaction has been submitted
    When the user views the activity tab
    Then the transaction is listed as "Perps withdraw"
    And tapping it shows the transaction details with title "Withdrawal"

Screenshots/Recordings

Before

N/A

After

N/A

Pre-merge author checklist

Pre-merge reviewer checklist

  • I've manually tested the PR (e.g. pull and build branch, run the app, test code being changed).
  • I confirm that this PR addresses all acceptance criteria described in the ticket it closes and includes the necessary testing evidence such as recordings and or screenshots.

Note

Medium Risk
Changes withdraw initiation and transaction-batch creation (including network selection) in a user-funds flow, which can affect confirmations and activity history if the flag/config is wrong.

Overview
Updates Perps withdraw to be feature-flagged: when selectPayQuoteConfig(..., 'perpsWithdraw').enabled is true, the Withdraw button now starts a new confirmation-based flow instead of navigating to the legacy withdraw screen.

Introduces usePerpsWithdrawConfirmation, which navigates to the CustomAmount confirmation UI on the Perps stack and creates a dummy Arbitrum ERC-20 transfer batch typed as TransactionType.perpsWithdraw to drive the MetaMask Pay experience; Developer Options “Perps Withdraw” is rewired to this hook. Tests are updated/added to cover the flag branching, success/error handling, and the new transaction-batch behavior.

Written by Cursor Bugbot for commit a80e4b7. This will update automatically on new commits. Configure here.

@dan437 dan437 requested review from a team as code owners April 1, 2026 13:14
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes.

@metamaskbot metamaskbot added the team-confirmations Push issues to confirmations team label Apr 1, 2026
@github-actions github-actions bot added size-M risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 1, 2026
@dan437 dan437 force-pushed the perps-withdraw-new-ui-flow branch from ab2403a to 05a7571 Compare April 1, 2026 13:50
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 1, 2026
@dan437 dan437 force-pushed the perps-withdraw-new-ui-flow branch from 05a7571 to 41bc7f9 Compare April 1, 2026 15:08
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 1, 2026
Copy link
Copy Markdown

@cursor cursor bot left a comment

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 and found 1 potential issue.

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.

@michalconsensys
Copy link
Copy Markdown
Contributor

After initiating the withdraw process, I'd expect this banner to show up also with the withdraw notifications. That does not seem to be the case in this branch

simulator_screenshot_705A671C-10DA-4AA9-B61C-C54AD13F6101

@dan437
Copy link
Copy Markdown
Contributor Author

dan437 commented Apr 1, 2026

After initiating the withdraw process, I'd expect this banner to show up also with the withdraw notifications. That does not seem to be the case in this branch

simulator_screenshot_705A671C-10DA-4AA9-B61C-C54AD13F6101

Thanks for the catch! We have just discussed this internally and if perp withdraws are way faster now then we don't need to banner, just the toast notifications, for which there is a different PR.

@dan437 dan437 enabled auto-merge April 1, 2026 17:22
@dan437 dan437 force-pushed the perps-withdraw-new-ui-flow branch from 41bc7f9 to a61a712 Compare April 1, 2026 20:21
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 1, 2026
Copy link
Copy Markdown
Contributor

@michalconsensys michalconsensys left a comment

Choose a reason for hiding this comment

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

Looks good, just for reference the toast notifications will be added in this PR #28271

@dan437 dan437 added this pull request to the merge queue Apr 2, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Apr 2, 2026
@dan437 dan437 added this pull request to the merge queue Apr 2, 2026
@dan437 dan437 removed this pull request from the merge queue due to a manual request Apr 2, 2026
@dan437 dan437 force-pushed the perps-withdraw-new-ui-flow branch from a61a712 to add9390 Compare April 2, 2026 09:39
@dan437 dan437 enabled auto-merge April 2, 2026 09:39
@github-actions github-actions bot removed the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 2, 2026
@github-actions github-actions bot added the risk-medium Moderate testing recommended · Possible bug introduction risk label Apr 2, 2026
dan437 added 4 commits April 2, 2026 12:18
…on flow

Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
@dan437 dan437 force-pushed the perps-withdraw-new-ui-flow branch from add9390 to a80e4b7 Compare April 2, 2026 10:18
@github-actions github-actions bot added risk-medium Moderate testing recommended · Possible bug introduction risk and removed risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 2, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeConfirmations, SmokeWalletPlatform
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR introduces a new Perps withdraw confirmation flow:

  1. usePerpsWithdrawConfirmation.ts (NEW): A new hook that creates a perpsWithdraw transaction batch on Arbitrum and navigates to the confirmation UI with a CustomAmount loader. This is a new code path that directly touches the confirmations system.

  2. usePerpsHomeActions.ts (MODIFIED): The handleWithdraw function now checks a feature flag (perpsWithdrawConfig.enabled). When enabled, it calls withdrawWithConfirmation() instead of navigating to the legacy withdraw screen. This is a behavioral change to the Perps withdraw flow.

  3. confirmations-developer-options.tsx (MODIFIED): Refactored to use the new shared usePerpsWithdrawConfirmation hook (code deduplication from inline useAddPerpsTransactionBatch). This is a developer-only component but validates the hook works correctly.

Tag selection rationale:

  • SmokePerps: Directly affected - the withdraw flow is changed with a new confirmation-based path behind a feature flag. The Add Funds/withdraw flows are core to Perps testing.
  • SmokeConfirmations: The new withdraw flow navigates to the confirmation UI with a CustomAmount loader and creates a perpsWithdraw transaction type. The confirmation system is directly involved in the new flow.
  • SmokeWalletPlatform: Per tag description, Perps is a section inside the Trending tab. Changes to Perps flows (including withdraw) affect Trending. Also required when selecting SmokePerps per the tag dependency rules.

SmokeTrade was considered but not selected as the changes are specifically to the Perps withdraw confirmation flow, not the broader trade/swap/bridge flows. The SmokePerps + SmokeConfirmations + SmokeWalletPlatform combination provides adequate coverage.

Performance Test Selection:
The changes are functional/behavioral (new hook, feature flag gating for withdraw flow) rather than rendering or data loading performance changes. No list rendering, animation, or startup changes are present. Performance tests are not warranted.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 2, 2026

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 46
Missing keys 0
Type mismatches 0
Value mismatches 12 (informational)

The committed fixture schema is out of date. To update, comment:

@metamaskbot update-mobile-fixture

View full details | Download diff report

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 2, 2026

@dan437 dan437 added this pull request to the merge queue Apr 2, 2026
Merged via the queue into main with commit bbbab7a Apr 2, 2026
97 of 122 checks passed
@dan437 dan437 deleted the perps-withdraw-new-ui-flow branch April 2, 2026 11:00
@github-actions github-actions bot locked and limited conversation to collaborators Apr 2, 2026
@metamaskbot metamaskbot added the release-7.73.0 Issue or pull request that will be included in release 7.73.0 label Apr 2, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.73.0 Issue or pull request that will be included in release 7.73.0 risk-medium Moderate testing recommended · Possible bug introduction risk size-M team-confirmations Push issues to confirmations team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants