Skip to content

feat: improve price impact row and warnings#26390

Merged
GeorgeGkas merged 17 commits into
mainfrom
codex/review-swaps4020-details
Mar 6, 2026
Merged

feat: improve price impact row and warnings#26390
GeorgeGkas merged 17 commits into
mainfrom
codex/review-swaps4020-details

Conversation

@bfullam
Copy link
Copy Markdown
Contributor

@bfullam bfullam commented Feb 21, 2026

Description

Previously, the price impact value color was driven by a warning boolean and effectively rendered as default or red. This change updates the value color by threshold so the UI communicates risk levels more clearly:

  • Price impact >= 5% shows warning color (yellow)
  • Price impact >= 25% shows error color (red)
  • Otherwise it remains the default alternative text color

Changelog

CHANGELOG entry: Updated swap price impact text coloring.

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4020 https://consensyssoftware.atlassian.net/browse/SWAPS-4024

Manual testing steps

Ensure acceptance criteria pass.

Screenshots/Recordings

Before

Price impact value color only switched between default and red.

After

Price impact value color now maps to thresholds:

  • default: < 5%
  • yellow: >= 5%
  • red: >= 25%

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 the Bridge confirmation flow to conditionally gate execution behind a new price-impact modal and adds navigation resets on quote expiry, which can affect swap completion and modal routing. Risk is mitigated by extensive new unit tests but touches user-critical transaction submission UX.

Overview
Adds a new PriceImpactModal (with header/description/footer) and wires it into Bridge modal routes, including new i18n copy for info, warning, and high price impact states.

Updates QuoteDetailsCard to always show a Price impact row with an info button that opens the modal, and switches price-impact coloring/iconography to threshold-based view data (warning at >=5%, error at >=25%) plus safer formatting for missing/invalid/negative values.

Refactors swap submission by introducing useBridgeConfirm and updating SwapsConfirmButton to accept/forward an explicit analytics location; if price impact meets the error threshold it now navigates to the modal (Execution type) instead of submitting immediately. Adds useModalCloseOnQuoteExpiry and applies it across Bridge modals to reset the modal stack to QuoteExpiredModal when quotes expire.

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

@bfullam bfullam requested a review from a team as a code owner February 21, 2026 18:44
@github-actions
Copy link
Copy Markdown
Contributor

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-swaps-and-bridge Swaps and Bridge team label Feb 21, 2026
@bfullam bfullam changed the title feat: yellow warning price impact feat: color bridge price impact yellow above 5% and red above 25% Feb 21, 2026
Comment thread app/components/UI/Bridge/components/QuoteDetailsCard/QuoteDetailsCard.test.tsx Outdated
Copy link
Copy Markdown
Contributor

@GeorgeGkas GeorgeGkas left a comment

Choose a reason for hiding this comment

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

This is part of a bigger epic will be included two releases from now. Please do not merge yet.

@GeorgeGkas GeorgeGkas marked this pull request as draft March 2, 2026 08:40
@GeorgeGkas GeorgeGkas changed the title feat: color bridge price impact yellow above 5% and red above 25% feat: WIP improve price impact row and warnings Mar 2, 2026
@github-actions github-actions Bot added size-M and removed size-S labels Mar 2, 2026
@github-actions github-actions Bot added size-XL and removed size-M labels Mar 4, 2026
@GeorgeGkas GeorgeGkas self-requested a review March 5, 2026 08:30
@GeorgeGkas GeorgeGkas marked this pull request as ready for review March 5, 2026 17:00
Comment thread app/components/UI/Bridge/components/SwapsConfirmButton/index.tsx Outdated
Comment thread locales/languages/en.json
@GeorgeGkas GeorgeGkas changed the title feat: WIP improve price impact row and warnings feat: improve price impact row and warnings Mar 5, 2026
Copy link
Copy Markdown
Contributor

@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.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.

Comment thread app/components/UI/Bridge/utils/formatPriceImpact.ts
GeorgeGkas
GeorgeGkas previously approved these changes Mar 6, 2026
@GeorgeGkas GeorgeGkas enabled auto-merge March 6, 2026 08:18
Copy link
Copy Markdown
Contributor Author

@bfullam bfullam left a comment

Choose a reason for hiding this comment

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

Some minor AC checks. Otherwise, looks great!

Comment thread app/components/UI/Bridge/components/QuoteDetailsCard/QuoteDetailsCard.tsx Outdated
Comment thread app/components/UI/Bridge/utils/getPriceImpactViewData.ts
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

🔍 Smart E2E Test Selection

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

E2E Test Selection:
This PR introduces a new Price Impact Modal feature for the Bridge functionality. The changes include:

  1. New PriceImpactModal component - A modal that displays price impact warnings/errors when users attempt to bridge tokens with high price impact (>5% warning, >25% error threshold)

  2. Modified SwapsConfirmButton - Now checks price impact before confirming a bridge transaction. If price impact exceeds 25%, it shows the PriceImpactModal instead of proceeding directly

  3. Modified QuoteDetailsCard - Updated to display price impact with visual indicators (icons and colors) based on severity

  4. New hooks - useBridgeConfirm (extracted confirmation logic) and useModalCloseOnQuoteExpiry (handles modal closing when quotes expire)

  5. AppConstants.ts changes - Added price impact thresholds (5% warning, 25% error)

  6. Route changes - Added new PRICE_IMPACT_MODAL route

The changes are focused on the Bridge/Swap flow which is covered by SmokeTrade. Since bridge transactions require confirmations and the PR modifies the confirmation flow (adding a price impact check that can block transactions), SmokeConfirmations should also be selected as per the tag description guidance.

The risk is medium because:

  • The changes modify an existing user flow (bridge confirmation)
  • New modal can block transactions if price impact is too high
  • The changes are well-scoped to the Bridge feature
  • Unit tests are included for all new components

Performance Test Selection:
The changes are focused on adding a new modal and modifying the bridge confirmation flow. The changes do not impact: (1) UI rendering performance - the new modal is a simple bottom sheet with minimal content, (2) Data loading - no changes to how quotes or data are fetched, (3) App startup or initialization, (4) List rendering or account/network selectors. The changes are primarily business logic for price impact validation and a new modal UI, which should not have measurable performance impact.

View GitHub Actions results

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

⚠️ E2E Fixture Validation — Structural changes detected

Category Count
New keys 68
Missing keys 11
Type mismatches 0
Value mismatches 7 (informational)

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

@metamaskbot update-mobile-fixture

View full details | Download diff report

}: PriceImpactDescriptionProps) {
const isWarning = Boolean(priceImpact);

const body = useMemo(() => {
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.

We should avoid using memoizing callbacks for logic that's not expensive. For example, this one can simply become:

let body = strings('bridge.price_impact_info_description');

if (type === PriceImpactModalType.Execution) {
  body = strings('bridge.price_impact_execution_description', {
    priceImpact: priceImpact ?? '0',
  });
} else if (isWarning) {
  body =  strings('bridge.price_impact_warning_description', {
    priceImpact: priceImpact ?? '0',
  });
}

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 6, 2026

@GeorgeGkas GeorgeGkas added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit a472bd4 Mar 6, 2026
92 of 93 checks passed
@GeorgeGkas GeorgeGkas deleted the codex/review-swaps4020-details branch March 6, 2026 11:25
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 6, 2026
@metamaskbot metamaskbot added the release-7.70.0 Issue or pull request that will be included in release 7.70.0 label Mar 6, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.70.0 Issue or pull request that will be included in release 7.70.0 size-XL team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants