feat: increase swap friction when price data is not available#41972
feat: increase swap friction when price data is not available#41972GeorgeGkas merged 6 commits intoswaps4228-token-warningsfrom
Conversation
|
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. |
✨ Files requiring CODEOWNER review ✨🧪 @MetaMask/qa (1 files, +20 -0)
🔄 @MetaMask/swaps-engineers (12 files, +420 -18)
|
Builds ready [21ad886]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [bf2733b]
⚡ Performance Benchmarks (Total: 🟢 6 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [db4a19c]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [9c58813] [reused from db4a19c]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [25a3cd0] [reused from db4a19c]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [09cb6ba] [reused from db4a19c]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
| severity: BannerAlertSeverity.Danger, | ||
| }, | ||
| }); | ||
| } |
There was a problem hiding this comment.
Stale quote triggers false "no price" alert alongside "no quotes"
Medium Severity
The price-data-unavailable alert condition checks unvalidatedQuote && !activeQuotePriceData, but unvalidatedQuote can be a stale quote from a previous fetch. When isNoQuotesAvailable is true (current fetch returned zero quotes) or isStockMarketClosed is true, a leftover unvalidatedQuote without priceData causes both the "No quotes available" / "Market closed" banner AND the "No price information" banner to appear simultaneously. The latter refers to a stale, non-actionable quote and is misleading. The condition likely needs to also guard against isNoQuotesAvailable and isStockMarketClosed to avoid showing a price-data alert for a quote the user can no longer submit.
Reviewed by Cursor Bugbot for commit 09cb6ba. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ 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 6151ed8. Configure here.
Builds ready [6151ed8]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [829b889]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
Builds ready [eb7fd44] [reused from 6151ed8]
⚡ Performance Benchmarks (Total: 🟢 7 pass · 🟡 8 warn · 🔴 0 fail)
Bundle size diffs [🚨 Warning! Bundle size has increased!]
|
|





Description
When a bridge or swap quote is fetched but price data is unavailable for one of the tokens, users previously had no indication of this. They could proceed with a transaction without knowing the displayed amounts were unverified, potentially leading to unexpected losses.
This PR introduces friction for this scenario by:
Migrating alert detection into
useBridgeAlerts— a new'price-data-unavailable'alert is emitted whenever a quote exists (unvalidatedQuote) butactiveQuotePriceDatais absent. UsingunvalidatedQuote(rather than the validatedactiveQuote) means the alert persists even after a quote expires, so users are never silently unprotected.Banner alert — the alert appears as a danger
BannerAlerton the prepare page above the quote card, giving users immediate visibility.Confirmation modal — the alert is flagged
isConfirmationAlert: true, so clicking the swap/bridge CTA intercepts submission with the existingBridgeAlertModal("No price information" title, default "Proceed" / "Cancel" buttons), requiring an explicit acknowledgement before the transaction is submitted.Removes the standalone
BridgeQuoteBannercomponent — this one-off component rendered a similar danger banner but was outside the shared alert system. The functionality is now fully handled byuseBridgeAlerts+ the existingBridgeAlertBannerList, eliminating the duplication.Repositions
BridgeAlertBannerList— moved above the quote details card so alert banners are visible before the user scrolls to the submit button.E2E fix —
submitQuoteAndDismissinquote-page.tsnow callsapproveModalIfPresent, which uses a CSS:not([disabled])selector to safely handle the new confirmation modal without interfering with existing test flows where a transaction was already in-flight.Changelog
CHANGELOG entry: Added a warning banner and confirmation step when price information is unavailable for a swap or bridge token, requiring users to explicitly acknowledge before submitting.
Related issues
Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4390
Manual testing steps
activeQuotePriceDatabeing nullunvalidatedQuoteexists but price data is absentScreenshots/Recordings
Before
No warning shown when price data is unavailable — user could submit without realising amounts are unverified.
After
Pre-merge author checklist
Pre-merge reviewer checklist
Note
Medium Risk
Changes the bridge/swap pre-submit alerting and confirmation flow, which can affect whether/when transactions are submitted. Risk is moderated by added/updated unit and e2e coverage.
Overview
Adds a new danger bridge alert when a quote exists but
priceDatais missing, showing a “No price information” banner and forcing an explicit Proceed/Cancel confirmation before submitting the swap/bridge.Introduces
getActiveQuotePriceDataselector plus new i18n strings, expands alert typings, tweaks banner container padding/placement, and updates unit snapshots/tests and e2e flow (approveModalIfPresent) to handle the new modal behavior.Reviewed by Cursor Bugbot for commit eb7fd44. Bugbot is set up for automated code reviews on this repo. Configure here.