Skip to content

feat: migrate to QuoteResponseV2 - #33621

Open
micaelae wants to merge 55 commits into
mainfrom
swaps-4546-quote-response-v2
Open

feat: migrate to QuoteResponseV2#33621
micaelae wants to merge 55 commits into
mainfrom
swaps-4546-quote-response-v2

Conversation

@micaelae

@micaelae micaelae commented Jul 21, 2026

Copy link
Copy Markdown
Member

Description

This PR migrates QuoteResponseV1 usages in the batch-sell, swaps and quickBuy experiences to QuoteResponse (v2)

Changes

  • bumps bridge and bridge-status controllers
  • update test mocks and fixtures to V2 QuoteResponse format
  • removes QuoteMetadata references
  • replace displayed cost metadata with priceImpact
  • replace QuoteMetadata amount references with normalizedAmount
  • balance validations now use total network fee (network+relayer) instead of just the gas fees

Changelog

CHANGELOG entry: feat: migrate to QuoteResponse V2 (phase 1)

Related issues

Fixes: https://consensyssoftware.atlassian.net/browse/SWAPS-4607

Manual testing steps

  1. Test quick-buy experience and compare metadata to prod
  2. Test swap/bridge experience and compare metadata to prod
  3. Cost should be lower in BridgeQuotesModal
  4. Network fee should be slightly higher in quote card (previous PR changed this from effective to total gas)
  5. Test batch-sell experience and compare metadata to prod
  6. Network fee should be slightly higher (previous PR changed this from effective to total gas)
Feature: my feature name

  Scenario: user [verb for user action]
    Given [describe expected initial app state]

    When user [verb for user action]
    Then [describe expected outcome]

Screenshots/Recordings

Before

After

Pre-merge author checklist

Performance checks (if applicable)

  • I've tested on Android
    • Ideally on a mid-range device; emulator is acceptable
  • I've tested with a power user scenario
    • Use these power-user SRPs to import wallets with many accounts and tokens
  • I've instrumented key operations with Sentry traces for production performance metrics

For performance guidelines and tooling, see the Performance Guide.

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

High Risk
Large, user-facing change to quote parsing, fee display, gas sufficiency, and confirm/post-trade amounts across swap, bridge, and batch-sell; incorrect field mapping could misstate balances or block submissions.

Overview
Bridge, swap, quick-buy, and batch-sell code now consume QuoteResponse V2 from the updated bridge controllers instead of V1 quotes plus separate QuoteMetadata.

Data shape: Amounts and assets read from quote.src / quote.dest (e.g. amount, normalizedAmount, minAmountNormalized) and top-level chainId. Price impact uses quote.priceData.priceImpact.amount (and fiat from the quote). MetaMask fees use feeData.metabridge as an array; dest.asset replaces flat destAsset. Mocks build V2 quotes via toQuoteResponseV2 and mergeQuoteMetadata.

Fees and balances: Network and gas checks aggregate feeData.network and feeData.relayer with sumAmounts (replacing gasFee.total / totalNetworkFee on metadata). Gasless quote rows use feeData.txFee for included costs. Quote selector totals and batch-sell rollups use the same V2 paths. useBridgeConfirm and rewards estimation pass V2 src/dest amounts and fee assets.

Matching and submission: Source/dest token matching compares CAIP assetId / formatAddressToCaipReference. Batch-sell submission drops the old bridge-status type cast. Tests and fixtures are updated across Bridge views, modals, and hooks for the new shapes.

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

@metamask-ci metamask-ci Bot added the team-swaps-and-bridge Swaps and Bridge team label Jul 21, 2026
@micaelae
micaelae force-pushed the swaps-4546-quote-response-v2 branch from 682fe0f to 3485679 Compare July 21, 2026 20:18
@micaelae
micaelae force-pushed the swaps4546-quote-metadata-usages branch from ec7e5ba to 7438c82 Compare July 21, 2026 20:31
@micaelae
micaelae force-pushed the swaps-4546-quote-response-v2 branch from 3485679 to cc9559b Compare July 22, 2026 16:47
@micaelae
micaelae force-pushed the swaps-4546-quote-response-v2 branch from cc9559b to 600499b Compare July 24, 2026 00:49
Base automatically changed from swaps4546-quote-metadata-usages to main July 29, 2026 16:22
@metamask-ci

metamask-ci Bot commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

PR template — items to address before "Ready for review"

Warnings — informational, address before merging:

  • Manual testing steps still contain template content (the Gherkin example title or a [...] placeholder). Replace with real steps, or write N/A — <reason>.
  • Screenshots/Recordings section is empty. Add an image/video for user-facing changes, logs/console output for non-user-facing changes, or write N/A if no evidence is applicable.
  • Pre-merge author checklist has unchecked items (e.g. "I've followed MetaMask Contributor Docs and MetaMask Mobile Coding Standards."). Every box must be consciously checked — see docs/readme/ready-for-review.md.

See docs/readme/ready-for-review.md for the full Definition of Ready for Review.

@socket-security

socket-security Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Updatednpm/​@​metamask/​bridge-status-controller@​74.6.0 ⏵ 75.0.099 +110079 +1100 +1100
Updatednpm/​@​metamask/​bridge-controller@​78.0.1 ⏵ 79.0.199 +110079 +1100 +1100

View full report

@micaelae micaelae changed the title feat: migrate to QuoteResponseV2 feat: migrate to QuoteResponseV2 cp-8.7.0 Aug 7, 2026

@cursor cursor Bot left a comment

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.

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 7f22c1e. Configure here.

@SteP-n-s SteP-n-s changed the title feat: migrate to QuoteResponseV2 cp-8.7.0 feat: migrate to QuoteResponseV2 Aug 7, 2026
@micaelae
micaelae dismissed stale reviews from infiniteflower, davibroc, and joaosantos15 via a99cfda August 7, 2026 16:43
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.86957% with 13 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.12%. Comparing base (cbe5e23) to head (60b7d80).

Files with missing lines Patch % Lines
...s/UI/Bridge/components/QuoteSelectorView/index.tsx 20.00% 0 Missing and 4 partials ⚠️
...nts/UI/Bridge/hooks/useBatchSellQuoteData/index.ts 80.00% 1 Missing and 2 partials ⚠️
.../components/QuickBuy/QuickBuySelectQuoteScreen.tsx 0.00% 1 Missing and 2 partials ⚠️
...omponents/UI/Bridge/hooks/useRewards/useRewards.ts 66.66% 0 Missing and 2 partials ⚠️
...components/QuickBuy/hooks/useQuickBuyController.ts 88.88% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #33621   +/-   ##
=======================================
  Coverage   85.12%   85.12%           
=======================================
  Files        6350     6350           
  Lines      173080   173057   -23     
  Branches    42804    42783   -21     
=======================================
- Hits       147333   147314   -19     
+ Misses      15708    15705    -3     
+ Partials    10039    10038    -1     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Performance Test Results

ℹ️ Performance test results are currently non-blocking and will not block this PR.

2 tests failed · 20 tests · 1 device

📱 Devices tested (1)

Android: Google Pixel 8 Pro (v14.0)

❌ Failed Tests (2)

🔬 App profiling vs main is included under each failed scenario that has a prior baseline.

@metamask-onboarding-team

Onboarding Import SRP with +50 accounts, SRP 3

Platform Device Reason Recording
Android Google Pixel 8 Pro (v14.0) Quality gates exceeded 📹 Watch

Seedless Onboarding: Telegram Login New User

Platform Device Reason Recording
Android Google Pixel 8 Pro (v14.0) Quality gates exceeded 📹 Watch

🔬 App profiling check · Current run 31452794467 · Baseline (last run on main (scenario also failing)) run 30897750395 @ 67486d2

⚠️ No green baseline on main — comparing against the latest usable profiling.

Summary: ⚠️ 6 metrics over +10%: CPU max (+3.65 (+19%)), Memory avg (+168.24 (+38.1%)), Memory max (+259.19 (+43.8%)), Slow frames (+3.91 (+70.3%)), Issues (+1 (+100%)), Critical issues (+1 (+100%))

ℹ️ API calls unavailable: Network logs API error: Bad Request

Full metric table (+10% variance rules)

Disclaimer — allowed variance: a +10% margin over the baseline is permitted.

  • If Current <= Baseline + 10%, treated as acceptable noise.
  • If Current > Baseline + 10%, Current and variance % are highlighted with ⚠️.
Metric Baseline Current Δ
CPU avg 13.9% 5.63% -8.27 (-59.5%)
CPU max 19.26% 22.91% +3.65 (+19%) ⚠️
Memory avg 441.69 MB 609.93 MB +168.24 (+38.1%) ⚠️
Memory max 592.47 MB 851.66 MB +259.19 (+43.8%) ⚠️
Slow frames 5.56% 9.47% +3.91 (+70.3%) ⚠️
Frozen frames 0% 0% 0 (0%)
ANRs 0 0 0 (0%)
Issues 1 2 +1 (+100%) ⚠️
Critical issues 1 2 +1 (+100%) ⚠️
App size 328.67 MB 329.17 MB +0.5 (+0.2%)
✅ Passed Tests (18)
Test Platform Device Duration Team Recording
Asset View, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 3.43s @assets-dev-team 📹 Watch
Cross-chain swap flow - ETH to SOL - 50+ accounts, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 5.72s @swap-bridge-dev-team 📹 Watch
Aggregated Balance Loading Time, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 8.30s @assets-dev-team 📹 Watch
Swap flow - ETH to LINK, SRP 1 + SRP 2 + SRP 3 Android Google Pixel 8 Pro (v14.0) 2.32s @swap-bridge-dev-team 📹 Watch
Import SRP with +50 accounts, SRP 1, SRP 2, SRP 3 Android Google Pixel 8 Pro (v14.0) 5.72s @Accounts-team 📹 Watch
Cold Start: Measure ColdStart To Login Screen Android Google Pixel 8 Pro (v14.0) 4.99s @metamask-mobile-platform 📹 Watch
Measure Warm Start: Warm Start to Login Screen Android Google Pixel 8 Pro (v14.0) 0.54s @metamask-mobile-platform 📹 Watch
Measure Warm Start: Login To Wallet Screen Android Google Pixel 8 Pro (v14.0) 1.53s @metamask-mobile-platform 📹 Watch
Perps add funds Android Google Pixel 8 Pro (v14.0) 9.34s @mm-perps-engineering-team 📹 Watch
Predict Available Balance - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 1.15s @team-predict 📹 Watch
Predict Deposit - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 11.30s @team-predict 📹 Watch
Predict Market Details - Complete Flow Performance Android Google Pixel 8 Pro (v14.0) 4.24s @team-predict 📹 Watch
Measure Cold Start To Onboarding Screen Android Google Pixel 8 Pro (v14.0) 4.02s @metamask-mobile-platform 📹 Watch
Fresh SRP wallet creation performance Android Google Pixel 8 Pro (v14.0) 11.85s @metamask-onboarding-team 📹 Watch
Account creation after fresh install Android Google Pixel 8 Pro (v14.0) 3.44s @metamask-onboarding-team 📹 Watch
Perps open position and close it Android Google Pixel 8 Pro (v14.0) 17.17s @mm-perps-engineering-team 📹 Watch
Seedless Onboarding: Apple Login New User Android Google Pixel 8 Pro (v14.0) 14.37s @metamask-onboarding-team 📹 Watch
Seedless Onboarding: Google Login New User Android Google Pixel 8 Pro (v14.0) 10.16s @metamask-onboarding-team 📹 Watch

Branch: swaps-4546-quote-response-v2 · Build: E2E · Commit: bd3bf82 · View full run

davibroc
davibroc previously approved these changes Aug 11, 2026
joaosantos15
joaosantos15 previously approved these changes Aug 11, 2026
infiniteflower
infiniteflower previously approved these changes Aug 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps, SmokeMMConnect
  • Selected Performance tags: None (no tests recommended)
  • Risk Level: high
  • AI Confidence: 100%
click to see 🤖 AI reasoning details

E2E Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/bridge-controller, @metamask/bridge-status-controller. Running all tests.

Performance Test Selection:
The changes are focused on bridge/swap UI logic and API format adaptation (QuoteResponseV2 migration). While the bridge-controller and bridge-status-controller packages were upgraded, the changes are about data structure adaptation rather than performance-sensitive rendering paths. No performance spec files were changed, and the bridge/swap flow doesn't map to any of the available performance test tags (@PerformanceSwaps is not in the available tags list). The available performance tags cover account list, onboarding, login, swaps (not available), launch, asset loading, predict, and perps - none of which are directly impacted by these bridge quote format changes.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk:high AI analysis: high risk size-XL team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants