Skip to content

feat: batch sell loading and stablecoin selection#29879

Merged
infiniteflower merged 14 commits into
mainfrom
swaps-4439-batchSell-quotes
May 15, 2026
Merged

feat: batch sell loading and stablecoin selection#29879
infiniteflower merged 14 commits into
mainfrom
swaps-4439-batchSell-quotes

Conversation

@infiniteflower

@infiniteflower infiniteflower commented May 7, 2026

Copy link
Copy Markdown
Contributor

Description

Adds the Batch Sell review-screen loading and control states for Unified Swaps behind the MM_BATCH_SELL_ENABLED gate. This focuses the pre-quote review experience on skeleton placeholders, percent allocation controls, and destination stablecoin selection.

The review screen now shows quote-dependent skeleton loaders for total received and per-token amounts, exposes discrete percent sliders that snap to supported allocation points, and lets users choose a destination stablecoin through a routed picker modal with fiat balance rows when available.

Changelog

CHANGELOG entry: Added Batch Sell review loading states, percent sliders, and destination stablecoin selection

Related issues

Refs: SWAPS-4439

Manual testing steps

Feature: Batch Sell review loading states and controls

  Scenario: user reviews selected Batch Sell tokens before quotes are available
    Given MM_BATCH_SELL_ENABLED is true
    And swaps are active
    And the wallet has eligible non-stablecoin tokens with balances on a supported Batch Sell network

    When user opens the wallet actions sheet
    And user taps Batch Sell
    Then the Batch Sell token selection screen is displayed
    And eligible networks are shown as filter pills
    And stablecoins are excluded from the sell token list

    When user selects up to five tokens from the same network
    Then the Continue button reflects the number of selected tokens

    When user taps Continue
    Then the Batch Sell Review screen is displayed
    And skeleton loaders are displayed for quote-dependent total received and token amount values
    And each selected token appears with a percentage slider defaulted to 100%
    And the destination stablecoin pill is displayed

  Scenario: user changes the Batch Sell destination stablecoin
    Given user is on the Batch Sell Review screen
    And destination stablecoins are configured for the selected source network

    When user taps the destination stablecoin pill
    Then the stablecoin selector modal is displayed
    And each stablecoin row shows its fiat balance when available

    When user selects another stablecoin
    Then the selector closes
    And the selected stablecoin is used on the review screen

  Scenario: user adjusts Batch Sell token percentages
    Given user is on the Batch Sell Review screen

    When user drags or taps a token percentage slider
    Then the slider snaps to one of 0%, 25%, 50%, 75%, or 100%

Screenshots/Recordings

Before

N/A

After

Screen.Recording.2026-05-12.at.12.08.07.PM.mov

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

Medium Risk
Adds new navigation routes and Redux state for Batch Sell destination token selection, plus new gesture-driven slider UI; risk is moderate due to new flow wiring and asset-id normalization that could affect token filtering/selection across chains.

Overview
Introduces a new Batch Sell review screen with skeleton loading UI, per-token percentage allocation controls (snapping to 0/25/50/75/100 via a new gesture-based BatchSellPercentageSlider), and a destination stablecoin pill that opens a new bottom-sheet selector modal.

Updates Batch Sell token selection to reset Batch Sell handoff state on entry, exclude destination stablecoins using normalized CAIP-19 asset IDs, and navigate multi-token flows to the new Routes.BRIDGE.BATCH_SELL_REVIEW route (while single-token flows still open the high-rate alert).

Extends the bridge Redux slice with batchSellDestToken, adds selectors for destination stablecoins (now returned as local BridgeToken metadata with checksum-insensitive matching), expands BridgeTokenMetadata coverage, and adds formatTokenBalance/asset-id normalization utilities with accompanying tests.

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

@metamaskbotv2 metamaskbotv2 Bot added the team-swaps-and-bridge Swaps and Bridge team label May 7, 2026
@github-actions

github-actions Bot commented May 7, 2026

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.

@infiniteflower infiniteflower force-pushed the swaps-4437-multiswap-token-select branch from d5df801 to e2f836c Compare May 8, 2026 14:46
@infiniteflower infiniteflower force-pushed the swaps-4439-batchSell-quotes branch from a5990ec to cc7a1ab Compare May 8, 2026 15:07
@infiniteflower infiniteflower mentioned this pull request May 8, 2026
10 tasks
@infiniteflower infiniteflower changed the title chore: (1st commit) setup skeleton for batch sell review feat: batch sell loading and stablecoin selection May 8, 2026
@infiniteflower infiniteflower force-pushed the swaps-4437-multiswap-token-select branch from e2f836c to db33140 Compare May 12, 2026 13:40
@infiniteflower infiniteflower force-pushed the swaps-4439-batchSell-quotes branch from 7e9ad0c to d05d956 Compare May 12, 2026 13:47
@infiniteflower

infiniteflower commented May 12, 2026

Copy link
Copy Markdown
Contributor Author

Duplication is intentional as they are constants. Skipping the quality check

@infiniteflower infiniteflower added skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels May 12, 2026
@infiniteflower infiniteflower force-pushed the swaps-4437-multiswap-token-select branch from e5ba722 to b5fb119 Compare May 12, 2026 16:48
@infiniteflower infiniteflower force-pushed the swaps-4439-batchSell-quotes branch from d05d956 to 219c754 Compare May 12, 2026 16:48
Base automatically changed from swaps-4437-multiswap-token-select to main May 13, 2026 07:49
@infiniteflower infiniteflower force-pushed the swaps-4439-batchSell-quotes branch from 1364451 to 10cc80f Compare May 13, 2026 14:21
@infiniteflower infiniteflower marked this pull request as ready for review May 13, 2026 14:23
@infiniteflower infiniteflower requested review from a team as code owners May 13, 2026 14:23

@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 10cc80f. Configure here.

Comment thread app/components/UI/Bridge/Views/BatchSellTokenSelect/BatchSellTokenSelect.tsx Outdated
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 83.24324% with 31 lines in your changes missing coverage. Please review.
✅ Project coverage is 81.74%. Comparing base (3751d9a) to head (10cc80f).
⚠️ Report is 121 commits behind head on main.

Files with missing lines Patch % Lines
...iews/BatchSellReview/BatchSellPercentageSlider.tsx 68.29% 12 Missing and 1 partial ⚠️
...s/BatchSellDestinationTokenSelectorModal/index.tsx 85.71% 0 Missing and 5 partials ⚠️
app/components/UI/Bridge/utils/tokenUtils.ts 50.00% 3 Missing and 2 partials ⚠️
app/core/redux/slices/bridge/index.ts 85.71% 1 Missing and 2 partials ⚠️
...I/Bridge/Views/BatchSellReview/BatchSellReview.tsx 94.28% 2 Missing ⚠️
.../Views/BatchSellReview/BatchSellReviewTokenRow.tsx 81.81% 0 Missing and 2 partials ⚠️
...iews/BatchSellTokenSelect/BatchSellTokenSelect.tsx 93.75% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #29879      +/-   ##
==========================================
+ Coverage   81.54%   81.74%   +0.20%     
==========================================
  Files        5343     5393      +50     
  Lines      142128   143632    +1504     
  Branches    32411    32790     +379     
==========================================
+ Hits       115899   117414    +1515     
+ Misses      18299    18194     -105     
- Partials     7930     8024      +94     

☔ View full report in Codecov by Sentry.
📢 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.

@infiniteflower infiniteflower removed the pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. label May 13, 2026
@infiniteflower infiniteflower enabled auto-merge May 13, 2026 19:00
@github-actions

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

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

E2E Test Selection:
The PR introduces a new BatchSell review flow within the Bridge/Swap feature:

  1. New BatchSellReview screen: A new navigation screen for reviewing batch sell operations, with a percentage slider for each token and a destination token selector.

  2. New BatchSellDestinationTokenSelectorModal: A bottom sheet modal for selecting the destination stablecoin (USDC/USDT) for batch sell operations.

  3. Redux bridge slice changes: New state field batchSellDestToken, new selectors selectBatchSellDestToken and selectBatchSellDestStablecoins, and new action setBatchSellDestToken. The return type of selectBatchSellDestStablecoinsByChain changed from Record<CaipChainId, CaipAssetType[]> to Partial<Record<CaipChainId, BridgeToken[]>> which could affect existing consumers.

  4. Navigation flow change: BatchSellTokenSelect now navigates to BATCH_SELL_REVIEW instead of QUOTE_SELECTOR_VIEW when multiple tokens are selected.

  5. New token metadata: Added USDT (Ethereum), USDC (Base, Arbitrum, Polygon) to BridgeTokenMetadata.

  6. Utility functions: New normalizeEvmAssetId and getBridgeTokenAssetId functions in tokenUtils.ts.

SmokeSwap is the primary tag as all changes are within the Bridge/Swap feature area. The bridge Redux slice changes and navigation flow modifications could affect existing swap/bridge E2E tests.

SmokeConfirmations is required per SmokeSwap tag description: "When selecting SmokeSwap, also select SmokeConfirmations (transaction confirmations are part of the flow)."

No other tags are warranted as changes are isolated to the Bridge/Swap feature area with no impact on accounts, identity, network management, snaps, browser, or other features.

Performance Test Selection:
The changes are focused on new UI components for the BatchSell review flow within Bridge/Swap. While there are new components and Redux state changes, these are additive features in a specific sub-flow (BatchSell) that is not yet fully functional (HAS_QUOTES is hardcoded to false). The changes don't affect core rendering performance paths like account lists, app startup, login, or asset loading. No performance tests are warranted.

View GitHub Actions results

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
3.8% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

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

platform codeowner files LGTM

@infiniteflower infiniteflower added this pull request to the merge queue May 15, 2026
Merged via the queue into main with commit 58ca663 May 15, 2026
296 of 318 checks passed
@infiniteflower infiniteflower deleted the swaps-4439-batchSell-quotes branch May 15, 2026 16:44
@github-actions github-actions Bot locked and limited conversation to collaborators May 15, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.79.0 Issue or pull request that will be included in release 7.79.0 label May 15, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.79.0 Issue or pull request that will be included in release 7.79.0 size-XL skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-swaps-and-bridge Swaps and Bridge team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants