Skip to content

chore(perps): upgrade @metamask/perps-controller to v7.0.0#30861

Merged
gambinish merged 11 commits into
mainfrom
chore/upgrade-perps-controller-v7
Jun 3, 2026
Merged

chore(perps): upgrade @metamask/perps-controller to v7.0.0#30861
gambinish merged 11 commits into
mainfrom
chore/upgrade-perps-controller-v7

Conversation

@michalconsensys

@michalconsensys michalconsensys commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Description

Upgrades @metamask/perps-controller from v6.3.0 to v7.0.0 and adapts to the breaking change where the 'equity' MarketType has been replaced with granular values: 'stock', 'pre-ipo', 'index', and 'etf'.

Why: The upstream controller published a major version bump (#8892) that splits the former catch-all 'equity' type into specific sub-types for stocks, pre-IPO markets, indices, and ETFs. This gives more precise data-model categorization and enables dedicated UI category pills for each sub-type.

What changed:

  • Bumped @metamask/perps-controller to ^7.0.0
  • Updated all marketType === 'equity' checks to use the new granular types
  • Added new UI filter categories (pre-ipo, indices, etfs) in market list and category badges
  • Updated badge styles for the new market types (replacing the single equity style)
  • Updated isEquityAsset() helper to check against all stock-like types
  • Added i18n locale strings for new category pills and badges
  • Updated all affected unit and view tests

Changelog

CHANGELOG entry: null

Related issues

Fixes: N/A — upstream dependency upgrade

Manual testing steps

Feature: Perps market type categorization

  Scenario: User views stock markets in the market list
    Given the user opens the Perps market list view
    When the user taps the "Stocks" category pill
    Then only markets with marketType 'stock' are displayed

  Scenario: User views new category pills
    Given the user opens the Perps market list view
    And there are markets of type pre-ipo, index, or etf
    When the category badges render
    Then separate pills for "Pre-IPO", "Indices", and "ETFs" appear

  Scenario: Market hours banner shows for stock-like assets
    Given the user opens a market detail for a stock, pre-ipo, index, or etf asset
    When the market hours banner evaluates the market type
    Then the banner displays correctly (same as before for equity assets)

Screenshots/Recordings

N/A — no visual design changes; existing styles are mapped to new type keys.

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
Touches market categorization across list, home, trending feeds, and badges; misclassification could hide or mislabel markets, but changes are mostly mechanical with broad test updates.

Overview
Upgrades @metamask/perps-controller to v7 and aligns the app with the breaking change that removes the single equity market type in favor of stock, pre-ipo, index, and etf.

Stock-like assets are grouped via isEquityAsset() (backed by MarketCategory and STOCK_LIKE_MARKET_TYPES), so market hours banners, home/list filtering, and Trending Stocks pills still treat all four types like the old equity bucket. marketCounts.equity becomes stocks, commodity/forex checks use MarketCategory, and PerpsBadge / i18n drop equity for stock plus new badge strings for pre-IPO, index, and ETF. Tests and UrlAutocomplete types are updated accordingly; locale adds tab labels for Pre-IPO, Indices, and ETFs ahead of dedicated list filters.

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

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

@github-actions github-actions Bot added 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 Jun 1, 2026
@socket-security

socket-security Bot commented Jun 1, 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/​perps-controller@​6.3.0 ⏵ 7.0.06810083 +197 +1100

View full report

@github-actions github-actions Bot added the size-M label Jun 1, 2026
@michalconsensys michalconsensys marked this pull request as ready for review June 1, 2026 15:14
@michalconsensys michalconsensys requested a review from a team as a code owner June 1, 2026 15:14
@michalconsensys michalconsensys added the team-perps Perps team label Jun 1, 2026
@github-actions github-actions Bot added the risk:high AI analysis: high risk label Jun 1, 2026
Comment thread app/components/UI/Perps/Views/PerpsMarketListView/PerpsMarketListView.tsx Outdated
Comment on lines +187 to +190
m.marketType === 'stock' ||
m.marketType === 'pre-ipo' ||
m.marketType === 'index' ||
m.marketType === 'etf',

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.

use enums from core

Comment on lines +215 to +219
m.marketType === 'stock' ||
m.marketType === 'pre-ipo' ||
m.marketType === 'index' ||
m.marketType === 'etf' ||
m.marketType === 'commodity',

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.

same here

Comment on lines +333 to +336
m.marketType === 'stock' ||
m.marketType === 'pre-ipo' ||
m.marketType === 'index' ||
m.marketType === 'etf',

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.

same here

Comment on lines +352 to +357
(m) =>
m.marketType === 'stock' ||
m.marketType === 'pre-ipo' ||
m.marketType === 'index' ||
m.marketType === 'etf' ||
m.marketType === 'commodity',

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.

same here

Comment on lines +291 to +298
} else if (market.marketType === 'stock') {
counts.stocks++;
} else if (market.marketType === 'pre-ipo') {
counts.preIpo++;
} else if (market.marketType === 'index') {
counts.indices++;
} else if (market.marketType === 'etf') {
counts.etfs++;

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.

same here

Comment on lines +96 to +102
| 'crypto'
| 'stock'
| 'pre-ipo'
| 'index'
| 'etf'
| 'commodity'
| 'forex';

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.

type to be used from core

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
Comment on lines +30 to +38
type BadgeType =
| 'experimental'
| 'stock'
| 'pre-ipo'
| 'index'
| 'etf'
| 'commodity'
| 'crypto'
| 'forex';

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Is this a type that can also be extracted from core?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Noticing that this is in a test file. Weird that we need to declare a type specifically for a test

Replace manually defined market type union with MarketType imported
from @metamask/perps-controller, per reviewer feedback.
Comment thread app/components/UI/Perps/hooks/usePerpsHomeData.ts Outdated
Replace ~8 inline four-way disjunctions (Stock || PreIpo || Index || Etf)
with the existing isEquityAsset() helper from marketHours.ts. This ensures
a single source of truth so future stock-like categories only need updating
in STOCK_LIKE_MARKET_TYPES.
Comment thread app/components/UI/Perps/Views/PerpsMarketListView/PerpsMarketListView.tsx Outdated
gambinish
gambinish previously approved these changes Jun 1, 2026
…om source

- Replace raw string literals for pre-ipo/indices/etfs analytics values
  with named constants following the established snake_case convention.
- Import BadgeType from PerpsBadge.types in view test instead of
  re-declaring it inline.
gambinish
gambinish previously approved these changes Jun 1, 2026
Comment thread app/components/UI/Perps/hooks/usePerpsMarketListView.test.ts Outdated
Group the temporary PRE_IPO, INDICES, ETFS analytics constants into a
LOCAL_BUTTON_CLICKED object mirroring PERPS_EVENT_VALUE.BUTTON_CLICKED
shape for consistency and easier future migration.
Comment thread app/components/Views/TrendingView/tabs/MacroTab.tsx
gambinish
gambinish previously approved these changes Jun 1, 2026
@michalconsensys

Copy link
Copy Markdown
Contributor Author

Do not merge, need to test

m.marketType === 'equity' ||
m.marketType === 'commodity' ||
m.marketType === 'forex',
isEquityAsset(m.marketType) ||

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 shouldn’t call this equity anymore right?

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.

Technically yeah, I wanted to make it a bit easier to review, hereby it's still called equity in this helper. Can change it in the next PR

@gambinish gambinish added the DO-NOT-MERGE Pull requests that should not be merged label Jun 1, 2026
Remove pre-ipo, indices, and etfs from default category badges since
they share the stocks tab. Use isEquityAsset helper for the stocks
filter to match all stock-like market types consistently.
@michalconsensys

Copy link
Copy Markdown
Contributor Author

Made some updates, as the intent of this PR is not to make any UI changes

@michalconsensys michalconsensys removed DO-NOT-MERGE Pull requests that should not be merged pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. labels Jun 2, 2026
Comment thread app/components/UI/Perps/hooks/usePerpsMarketListView.ts
@codecov-commenter

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 44.89796% with 27 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.70%. Comparing base (044726b) to head (0e191ab).
⚠️ Report is 9 commits behind head on main.

Files with missing lines Patch % Lines
...omponents/UI/Perps/hooks/usePerpsMarketListView.ts 37.50% 8 Missing and 7 partials ⚠️
.../Views/PerpsMarketListView/PerpsMarketListView.tsx 20.00% 0 Missing and 4 partials ⚠️
...pp/components/Views/TrendingView/tabs/MacroTab.tsx 0.00% 3 Missing ⚠️
app/components/Views/TrendingView/tabs/RwasTab.tsx 0.00% 3 Missing ⚠️
...nts/Views/TrendingView/feeds/perps/usePerpsFeed.ts 0.00% 0 Missing and 2 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #30861      +/-   ##
==========================================
- Coverage   82.72%   82.70%   -0.02%     
==========================================
  Files        5566     5573       +7     
  Lines      143286   143466     +180     
  Branches    33099    33165      +66     
==========================================
+ Hits       118529   118653     +124     
- Misses      16870    16901      +31     
- Partials     7887     7912      +25     

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

@michalconsensys michalconsensys added the skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. label Jun 2, 2026
geositta
geositta previously approved these changes Jun 2, 2026

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

One clarification for the v7 migration: since the dedicated UI treatment for pre-ipo, indices, and etfs is planned for a later PR, should this branch keep those categories hidden from availableCategories even when v7 data contains them? Right now the categories are only visible when counts are nonzero, so the current data still looks unchanged, but the code path would expose those pills as soon as those market types appear.

…cated UI

These categories would be exposed as soon as v7 data includes markets of
those types. Since the dedicated UI treatment is planned for a follow-up PR,
keep them hidden from availableCategories for now.
@michalconsensys michalconsensys added DO-NOT-MERGE Pull requests that should not be merged and removed DO-NOT-MERGE Pull requests that should not be merged labels Jun 2, 2026
…ilters

These market types are folded into the existing "Stocks" category via
isEquityAsset. Removes dedicated badge styles, filter branches, analytics
mappings, and test coverage for pre-ipo/index/etf as standalone categories.

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

There are 2 total unresolved issues (including 1 from previous review).

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 538e96f. Configure here.

Comment thread app/components/UI/Perps/hooks/usePerpsMarketListView.test.ts Outdated
…est assertions

The marketCounts object no longer includes these fields after the category
cleanup, so the test expectations need to match.
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

🔍 Smart E2E Test Selection

  • Selected E2E tags: SmokeAccounts, SmokeConfirmations, SmokeIdentity, SmokeNetworkAbstractions, SmokeNetworkExpansion, SmokeSwap, SmokeStake, SmokeWalletPlatform, SmokeMoney, SmokePerps, SmokeMultiChainAPI, SmokePredictions, SmokeSeedlessOnboarding, SmokeBrowser, SmokeSnaps
  • Selected Performance tags: @PerformanceAccountList, @PerformanceOnboarding, @PerformanceLogin, @PerformanceSwaps, @PerformanceLaunch, @PerformanceAssetLoading, @PerformancePredict, @PerformancePreps
  • 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/perps-controller. Running all tests.

Performance Test Selection:
Hard rule (controller-version-update): @MetaMask controller package version updated in package.json: @metamask/perps-controller. Running all tests.

View GitHub Actions results

@abretonc7s abretonc7s self-requested a review June 3, 2026 12:51
@gambinish gambinish added this pull request to the merge queue Jun 3, 2026
Merged via the queue into main with commit b7be5cb Jun 3, 2026
224 of 233 checks passed
@gambinish gambinish deleted the chore/upgrade-perps-controller-v7 branch June 3, 2026 17:08
@github-actions github-actions Bot locked and limited conversation to collaborators Jun 3, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

risk:high AI analysis: high risk size-M skip-sonar-cloud Only used for bypassing sonar cloud when failures are not relevant to the changes. team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants