Skip to content

feat: perps top movers#30897

Merged
gambinish merged 22 commits into
mainfrom
feat/perps-top-movers
Jun 4, 2026
Merged

feat: perps top movers#30897
gambinish merged 22 commits into
mainfrom
feat/perps-top-movers

Conversation

@gambinish

@gambinish gambinish commented Jun 1, 2026

Copy link
Copy Markdown
Member

Description

Implements the Top Movers section on the Perps home screen, surfacing the 8 biggest price-change markets in a 2×4 pill grid with a Gainers/Losers toggle. Tapping the section header navigates to the Market List pre-sorted by price change in the direction matching the active toggle.

Subscribes to Websocket data for live updates.

Also fixes some ordering issues that didn't match figma.

Changelog

CHANGELOG entry: Adds top movers section to perps home

Related issues

Fixes: Adds Top Movers in Perps Home

Manual testing steps

  • Enable the feature flag (MM_PERPS_TOP_MOVERS_ENABLED=true)
  • Perps home screen shows "Top movers" section with 8 pills in a 2-row grid
  • Gainers tab is selected by default; pills show markets sorted by highest price change
  • Toggling to Losers reloads the pills sorted by lowest price change
  • Tapping a market pill navigates to that market's trading screen
  • Tapping "Top movers >" header with Gainers active opens Market List sorted by price change descending
  • Tapping "Top movers >" header with Losers active opens Market List sorted by price change ascending
  • Section is hidden when the feature flag is off
  • Section hides itself when no market data is available (e.g. controller error)
  • Data and ordering updates live via websocket subscription
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

Screen.Recording.2026-06-03.at.12.37.31.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
New WebSocket-backed sorting and a navigation path change when users open the full market list; impact is limited by a remote flag defaulting to off, but routing regressions from wallet-embedded Perps home are worth verifying.

Overview
Adds a Top movers block on Perps home (behind perpsTopMoversEnabled): Gainers / Losers toggle, up to eight markets in a 2×4 pill carousel, live ranking from market data plus throttled WebSocket price updates via usePerpsTopMovers. Header opens the market list sorted by price change in the active direction; analytics source and optional transactionActiveAbTests flow through pills and navigation.

Perps home layout moves What's happening above the watchlist (still flag-gated) and inserts Top movers after watchlist. navigateToMarketList now targets Routes.PERPS.ROOTMARKET_LIST so "view all" works from wallet-embedded home and the Perps stack. Copy, test IDs, remote flag registry, and unit tests cover the section, hook, and navigation change.

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

michalconsensys and others added 8 commits June 1, 2026 15:35
Adapt to breaking change: 'equity' MarketType replaced with granular
values 'stock', 'pre-ipo', 'index', and 'etf'. Update all filters,
counts, badge styles, category pills, locale strings, and tests.
Address PR review feedback:
- Add 'pre-ipo', 'indices', 'etfs' to categoryMap in handleCategorySelect
  so analytics events fire for the new category filters
- Replace raw market type string literals with MarketCategory enum from
  @metamask/perps-controller across all source files
Replace manually defined market type union with MarketType imported
from @metamask/perps-controller, per reviewer feedback.
@github-actions

github-actions Bot commented Jun 1, 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.

@gambinish gambinish changed the title Feat/perps top movers feat: perps top movers Jun 1, 2026
@gambinish gambinish changed the base branch from main to chore/upgrade-perps-controller-v7 June 1, 2026 19:58
export const selectPerpsTopMoversEnabledFlag = createSelector(
selectRemoteFeatureFlags,
(remoteFeatureFlags) => {
const localFlag = process.env.MM_PERPS_TOP_MOVERS_ENABLED === 'true';

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 dont need a local feature flag

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Comment thread app/components/UI/Perps/Views/PerpsHomeView/PerpsHomeView.tsx Outdated

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

Missing tests

Base automatically changed from chore/upgrade-perps-controller-v7 to main June 3, 2026 17:08
@github-actions github-actions Bot added the size-L label Jun 3, 2026
@gambinish gambinish requested a review from aganglada June 3, 2026 19:40
@gambinish gambinish marked this pull request as ready for review June 3, 2026 19:42
@gambinish gambinish requested a review from a team as a code owner June 3, 2026 19:42
@gambinish gambinish added the team-perps Perps team label Jun 3, 2026
@github-actions github-actions Bot added the risk:medium AI analysis: medium risk label Jun 3, 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 eff2531. Configure here.

Comment thread app/components/UI/Perps/hooks/usePerpsTopMovers.ts

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

The implementation and tests look good; the one gap I found is A/B attribution propagation from the top movers section, which is worth fixing IMO.

@gambinish gambinish requested a review from geositta June 3, 2026 23:19
@gambinish gambinish requested a review from a team as a code owner June 4, 2026 15:04
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokePerps, SmokeWalletPlatform, SmokeConfirmations
  • Selected Performance tags: @PerformancePreps
  • Risk Level: medium
  • AI Confidence: 88%
click to see 🤖 AI reasoning details

E2E Test Selection:
The PR introduces a new "Top Movers" (Gainers/Losers) section to the Perps home screen, backed by a new feature flag perpsTopMoversEnabled (disabled by default in production). Key changes:

  1. New PerpsTopMoversSection component: A new UI section with Gainers/Losers toggle pills and a live-updating market list using WebSocket prices via usePerpsTopMovers hook.
  2. usePerpsTopMovers hook: New hook that merges live WebSocket price ticks with market data, sorted by 24h price change, throttled at 3 seconds.
  3. PerpsHomeView layout change: Section reordering (What's Happening moved before Watchlist, Top Movers added after Watchlist) - this affects the existing Perps home screen layout regardless of the feature flag.
  4. usePerpsNavigation fix: Navigation to market list now uses Routes.PERPS.ROOT as parent - this is an unconditional change that affects all navigation from Perps home to market list, potentially impacting existing Perps E2E flows.
  5. PerpsMarketListView: Added new category mappings (pre-ipo, indices, etfs).
  6. Feature flag registry: New perpsTopMoversEnabled flag registered.
  7. New test IDs: Added for Top Movers section elements.
  8. Localization: New strings added.

SmokePerps: Directly affected - Perps home view layout changed, new section added, navigation behavior changed (usePerpsNavigation fix). Existing perps tests (add-funds, position, limit-long-fill) navigate through PerpsHomeView and use navigateToMarketList.

SmokeWalletPlatform: Required per SmokePerps tag description - "Perps is also a section inside the Trending tab (SmokeWalletPlatform); changes to Perps views affect Trending."

SmokeConfirmations: Required per SmokePerps tag description - "When selecting SmokePerps, also select SmokeConfirmations (Add Funds deposits are on-chain transactions)."

Performance Test Selection:
The new usePerpsTopMovers hook introduces real-time WebSocket price subscriptions for all market symbols, merged with market data every 3 seconds. This adds continuous background computation (sorting, merging, memoization) to the Perps home screen. The @PerformancePreps tag covers perps market loading, position management, add funds flow, and order execution - directly relevant to the new live-updating Top Movers section that could impact Perps home screen rendering performance.

View GitHub Actions results

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

Thanks for addressing issues, flagged a problematic className if you could look for a better background alternative, or if not could we could ask design team to support us on?

accessibilityState={{ selected: isSelected }}
style={tw.style(
'flex-1 rounded-xl items-center',
isSelected ? 'bg-icon-default' : 'bg-muted',

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.

@gambinish icon-default is a foreground/text design token, is there a background className we could use instead, or flag this with design team so they can create one?

@gambinish gambinish enabled auto-merge June 4, 2026 15:33
@gambinish gambinish added this pull request to the merge queue Jun 4, 2026
Merged via the queue into main with commit a903c12 Jun 4, 2026
197 of 199 checks passed
@gambinish gambinish deleted the feat/perps-top-movers branch June 4, 2026 16:01
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 4, 2026
@metamaskbotv2 metamaskbotv2 Bot added the release-7.81.0 Issue or pull request that will be included in release 7.81.0 label Jun 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

release-7.81.0 Issue or pull request that will be included in release 7.81.0 risk:medium AI analysis: medium risk size-L team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants