Skip to content

feat: Swaps quotes selector#26640

Merged
GeorgeGkas merged 17 commits into
mainfrom
swaps-quotes-selector
Mar 6, 2026
Merged

feat: Swaps quotes selector#26640
GeorgeGkas merged 17 commits into
mainfrom
swaps-quotes-selector

Conversation

@GeorgeGkas
Copy link
Copy Markdown
Contributor

@GeorgeGkas GeorgeGkas commented Feb 26, 2026

Description

Add select quotes functionality in swaps.

Changelog

CHANGELOG entry: add select quotes functionality

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-3642, https://consensyssoftware.atlassian.net/browse/SWAPS-4149, https://consensyssoftware.atlassian.net/browse/SWAPS-4203

Manual testing steps

Ensure AC pass

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 quote-selection and fee-formatting logic and introduces a new navigation flow, which could affect which quote is executed and what costs are displayed if edge cases (expired/refreshing quotes, missing requestId) are mishandled.

Overview
Adds a new Quote Selector screen that lists sorted swap/bridge quotes by estimated total cost and lets users pick a specific quote; the rate row in QuoteDetailsCard now navigates to this selector via new rate-info-button/rate-arrow-button actions.

Introduces selectedQuoteRequestId to the bridge Redux slice and threads it through selectBridgeQuotes and useBridgeQuoteData so a manually chosen quote becomes the activeQuote (with auto-reset when the selection is no longer valid/available).

Refactors fiat/amount display by adding useDisplayCurrencyValue and switching TokenInputArea to use it (and the renamed useFormattedBalanceWithThreshold), and updates formatNetworkFee to correctly handle gasless quotes via includedTxFees with a gasFee.effective fallback. Includes new route wiring (Routes.BRIDGE.QUOTE_SELECTOR_VIEW), i18n strings, and extensive new/updated unit tests covering the selector UI, analytics (useTrackAllQuotesSortedEvent), and various BridgeView behaviors (Blockaid banner, approval disclaimer, input constraints, sponsored-network handling).

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

@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 26, 2026
Comment thread app/components/UI/Bridge/components/QuoteSelectorView/QuoteRow.tsx Outdated
Copy link
Copy Markdown
Contributor Author

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

on useInsufficentBalance line 72 // TODO: use totalNetworkFee

on useHasSufficientGas on line 54 // TODO: use totalNetworkFee

Comment thread app/components/UI/Bridge/components/QuoteSelectorView/QuoteRow.tsx Outdated
@GeorgeGkas GeorgeGkas marked this pull request as ready for review March 6, 2026 12:28
@GeorgeGkas GeorgeGkas requested a review from a team as a code owner March 6, 2026 12:28
@GeorgeGkas GeorgeGkas changed the title WIP Swaps quotes selector feat: Swaps quotes selector Mar 6, 2026
Comment thread app/components/UI/Bridge/components/QuoteSelectorView/index.tsx
Comment thread app/components/UI/Bridge/components/QuoteSelectorView/index.tsx
Comment thread app/components/UI/Bridge/hooks/useBridgeQuoteData/index.ts
Comment on lines +85 to +87
? (quote.includedTxFees?.usd ?? '0')
: (quote.totalNetworkFee?.usd ??
quote.gasFee?.effective?.usd ??
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.

These should use .valueInCurrency instead of .usd, otherwise we get unit mismatch.

Example:

  • Assume user currency is EUR.
  • sentAmount.usd = 100, sentAmount.valueInCurrency = 92
  • networkFee.usd = 5, networkFee.valueInCurrency = 4.6
  • Current code formats 100 + 5 = 105 as EUR => shows about €105
  • Correct EUR total should be €96.6

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

NICE CATCH!

@GeorgeGkas GeorgeGkas requested a review from bfullam March 6, 2026 16:25
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/hooks/useBridgeQuoteData/index.ts
Copy link
Copy Markdown
Contributor

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

Great stuff! 🚀

@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: @PerformanceSwaps
  • Risk Level: medium
  • AI Confidence: 85%
click to see 🤖 AI reasoning details

E2E Test Selection:
This PR adds a Quote Selector View feature to the Bridge functionality, allowing users to manually select alternative quotes instead of using only the recommended/best quote. The changes include:

  1. New Redux State: Added selectedQuoteRequestId to the bridge slice to track user-selected quotes
  2. New Components: QuoteSelectorView, QuoteList, QuoteRow for displaying and selecting quotes
  3. New Hooks: useTrackAllQuotesSortedEvent (analytics), useDisplayCurrencyValue (extracted from TokenInputArea)
  4. Modified Components: QuoteDetailsCard now navigates to quote selector, TokenInputArea refactored to use new hooks
  5. New Route: QUOTE_SELECTOR_VIEW added to Bridge routes
  6. Utility Updates: formatNetworkFee now handles gasless quotes properly

SmokeTrade is selected because it tests DeFi trading features including cross-chain bridging, which is exactly what this PR modifies. The bridge-action-smoke.spec.ts test directly tests bridge functionality.

SmokeConfirmations is selected because per the tag description: "When selecting SmokeTrade for swap or bridge flows, also select SmokeConfirmations" since transaction confirmations are part of the bridge flow.

The changes are scoped to the Bridge UI feature and don't affect:

  • Account management (SmokeAccounts)
  • Network management (SmokeNetworkAbstractions)
  • Identity/sync (SmokeIdentity)
  • Snaps (FlaskBuildTests)
  • Perps, Predictions, Ramps, Card features
  • Multi-chain API or network expansion

Risk is medium because while the changes are significant (new view, Redux state, hooks), they are well-contained within the Bridge feature and include comprehensive unit tests.

Performance Test Selection:
The PR adds a new Quote Selector View with list rendering (QuoteList, QuoteRow components) and modifies the swap/bridge flow UI. The @PerformanceSwaps tag covers swap flow performance including quote fetching, token selection, and swap execution times. Since this PR adds a new view for selecting quotes and modifies how quotes are displayed and selected, it could impact the performance of the swap/bridge flow. The changes to Redux state management (selectedQuoteRequestId) and the new hooks (useDisplayCurrencyValue, useTrackAllQuotesSortedEvent) could also affect rendering performance.

View GitHub Actions results

@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud Bot commented Mar 6, 2026

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 6, 2026

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

@GeorgeGkas GeorgeGkas added this pull request to the merge queue Mar 6, 2026
Merged via the queue into main with commit 010ee1b Mar 6, 2026
93 of 94 checks passed
@GeorgeGkas GeorgeGkas deleted the swaps-quotes-selector branch March 6, 2026 19:24
@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.

3 participants