Skip to content

fix: perps withdraw metrics, UI, and fee display improvements#28588

Merged
dan437 merged 6 commits intomainfrom
perps-withdraw-updates
Apr 9, 2026
Merged

fix: perps withdraw metrics, UI, and fee display improvements#28588
dan437 merged 6 commits intomainfrom
perps-withdraw-updates

Conversation

@dan437
Copy link
Copy Markdown
Contributor

@dan437 dan437 commented Apr 9, 2026

Description

Fixes several things with the Perps Withdraw to any token flow:

  • mm_pay_quote_requested metric always false: The metric relied on hasSourceAmount which is never true for post-quote flows. Now uses isPostQuote as an alternative gate.
  • mm_pay_time_to_complete_s missing: Falls back to the parent's submittedTime when no child transactions exist (gasless HyperLiquid withdrawals).
  • Insufficient funds alert for excessive fees: On the confirmation screen, shows insufficient funds when total fees exceed the withdraw amount (gated on quotes being available).
  • Unrealistic fallback fee displayed: Hides fee, time, and receive rows when no relay quotes exist, since the controller's raw gas fallback produces unrealistic values.
  • Alert message positioning: Moved "This payment route isn't available" above the Receive token selector.
  • Blue activity title: Overrides headerTintColor to text.default so the transaction details title is no longer blue.

Changelog

CHANGELOG entry: Fixed perps withdraw metrics tracking, hide rows when no quotes are available, and fixed blue title in transaction details

Related issues

Fixes: CONF-1159

Manual testing steps

Feature: Perps Withdraw

Scenario: user withdraws to BNB

  • Given user has a perps balance
  • When user initiates a perps withdraw to BNB
  • Then transaction fee and receive amount display correctly
  • Then mm_pay_quote_requested is true in the finalized event
  • Then mm_pay_time_to_complete_s is present in the finalized event

Scenario: user enters tiny amount

  • Given user is on the perps withdraw confirmation screen
  • When user selects MUSD on Ethereum as receive token and enters $0.05 with withdraw
  • Then fee and receive rows are hidden
  • Then "No quotes" button is shown
  • Then alert message appears above the Receive selector

Scenario: user views completed withdrawal in activity

  • Given user has a completed perps withdrawal
  • When user opens the transaction details
  • Then the "Withdrawal" title is default text color, not blue

Screenshots/Recordings

Before

After

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
Touches confirmation-screen fee/receive rendering and blocking alert logic for withdraws, plus metrics emission paths, which could affect user-visible values and analytics if quote/totals availability is misdetected.

Overview
Fixes Perps Withdraw confirmation UX by only showing fee/time/receive totals when relay quotes are loading or available, avoiding misleading fallback fee values; it also moves the inline AlertMessage above the receive/account selector.

Tightens quote-dependent calculations by returning empty values for BridgeFeeRow and ReceiveRow when there are no quotes, and adds a confirmation-only insufficient-funds check that blocks when total fees would consume the entire withdraw amount.

Improves MetaMask Pay metrics: mm_pay_quote_requested now triggers for post-quote flows (via useTransactionPayIsPostQuote), and mm_pay_time_to_complete_s falls back to the parent transaction submittedTime when no child submitted times exist. Also fixes the activity details header color by overriding headerTintColor to colors.text.default (with updated tests).

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

@dan437 dan437 requested a review from a team as a code owner April 9, 2026 09:05
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 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 9, 2026
@github-actions github-actions bot added size-M risk-medium Moderate testing recommended · Possible bug introduction risk labels Apr 9, 2026
dan437 added 6 commits April 9, 2026 11:31
Override headerTintColor to colors.text.default in the transaction
details screen so the title no longer inherits the blue primary tint
from the shared navbar helper.

Fixes CONF-1159
The metric was always false because hasSourceAmount is never true
for post-quote flows — the native token source amount only matches
a skipIfBalance required token. Use isPostQuote as an alternative
gate since post-quote transactions always request a relay quote.
When no child transactions exist (e.g. gasless HyperLiquid
withdrawals where the batch has no requiredTransactionIds),
fall back to the parent's own submittedTime so the metric
is still reported on finalized pay transactions.
On the confirmation screen, check if total fees are greater than or
equal to the withdraw amount and show an insufficient funds alert.
Gated on quotes being available so controller fallback fees don't
trigger false positives. Skipped during input since totals may be
stale while the user is typing.
When no relay quotes exist the controller falls back to raw gas
estimation, producing nonsensical multi-million dollar fees. Hide
the fee, time, and receive rows at the parent level when loading
is complete but no quotes were returned. Move alert message above
the Receive token selector per the redesign.
Signed-off-by: dan437 <80175477+dan437@users.noreply.github.com>
@dan437 dan437 force-pushed the perps-withdraw-updates branch from d35df47 to e33f629 Compare April 9, 2026 09:32
@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 9, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR contains targeted bug fixes and logic improvements across several confirmation-related components:

  1. SmokePerps (primary): useInsufficientPerpsBalanceAlert.ts has significant logic changes - now checks if fees exceed the withdraw amount on the confirmation screen. metamask-pay.ts fixes time-to-complete metrics for perps transactions (falls back to parent submittedTime). custom-amount-info.tsx wraps bridge/receive rows in hasQuoteResults guard which affects perps deposit/withdraw flows. Per tag description, SmokePerps requires SmokeWalletPlatform and SmokeConfirmations.

  2. SmokeWalletPlatform (required by SmokePerps): Required as a dependent tag per SmokePerps description. Also relevant because transaction-details.tsx changes the header tint color in the activity/transaction details screen, which is part of transaction history display.

  3. SmokeConfirmations (required by SmokePerps + SmokeTrade): Required as dependent tag. The custom-amount-info.tsx changes affect the confirmation UI for perps and bridge flows. bridge-fee-row.tsx and receive-row.tsx changes affect bridge confirmation display. useTransactionCustomAmount.ts changes affect quote metrics triggering in confirmations.

  4. SmokeTrade (bridge/swap): bridge-fee-row.tsx and receive-row.tsx are directly used in bridge/swap confirmation flows. The hasQuotes guard changes prevent stale fee/receive data from showing during bridge operations. Per SmokeTrade description, SmokeConfirmations is also required.

The changes are bug fixes rather than architectural changes, reducing risk. No changes to core Engine controllers, navigation, or shared infrastructure that would affect unrelated test areas.

Performance Test Selection:
The changes are bug fixes to UI logic (quote guards, alert conditions, metrics fallbacks) and do not introduce new rendering paths, list components, or data loading patterns that would impact performance. No changes to account/network list components, app startup, or critical performance-sensitive flows.

View GitHub Actions results

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.

Reviewed by Cursor Bugbot for commit e33f629. Configure here.

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 9, 2026

E2E Fixture Validation — Schema is up to date
16 value mismatches detected (expected — fixture represents an existing user).
View details

@dan437 dan437 enabled auto-merge April 9, 2026 10:02
@dan437 dan437 added this pull request to the merge queue Apr 9, 2026
Merged via the queue into main with commit 3b09c24 Apr 9, 2026
103 checks passed
@dan437 dan437 deleted the perps-withdraw-updates branch April 9, 2026 10:25
@github-actions github-actions bot locked and limited conversation to collaborators Apr 9, 2026
@metamaskbot metamaskbot added the release-7.74.0 Issue or pull request that will be included in release 7.74.0 label Apr 9, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.74.0 Issue or pull request that will be included in release 7.74.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.

3 participants