Skip to content

fix(perps): preserve Terminal categories on snapshot fallback - #35379

Closed
abretonc7s wants to merge 1 commit into
mainfrom
fix/perps-terminal-category-fallback-v13
Closed

abretonc7s wants to merge 1 commit into
mainfrom
fix/perps-terminal-category-fallback-v13

Conversation

@abretonc7s

@abretonc7s abretonc7s commented Aug 27, 2026 •

Copy link
Copy Markdown
Contributor

Description

@metamask/perps-controller@13.0.0 drops Terminal v1 category when marketType is absent. It also skips v1 metadata when the configured v2 snapshot fails. The fallback then keeps live provider prices but can lose Terminal's category mapping.

This temporary Yarn patch backports the controller fix while the next package release is prepared:

  • map pre_ipo to pre-ipo and stocks to stock;
  • fetch v1 metadata after a failed v2 snapshot while retaining provider prices;
  • clear stale isNewMarket when Terminal supplies a category;
  • classify CBRS and SPCX as stocks in the static fallback. IPOP remains Pre-IPO.

Validated on a Pixel 6 with a forced v2 failure. Unitree, CXMT, and SKHY resolved to Pre-IPO; CBRS and SPCX resolved to Stocks. All five retained prices and none used the v2 snapshot data source.

This supersedes Mobile #35313, whose patch targets controller v12. Remove this patch after a controller release contains Core #9987, which combines the category mapping and snapshot-fallback fix.

Changelog

CHANGELOG entry: Fixed Perps market categories when Terminal snapshot fallback is used

Related issues

Refs: MetaMask/core#9987

Manual testing steps

Feature: Perps categories survive Terminal snapshot fallback

  Scenario: Terminal v2 fails while provider prices remain available
    Given Perps is using Hyperliquid on mainnet
    And the Terminal v2 snapshot request fails
    When market data loads through Terminal v1 metadata and provider prices
    Then Unitree, CXMT, and SKHY are classified as Pre-IPO
    And CBRS and SPCX are classified as Stocks
    And all five markets have current prices
    And none of the five markets remains marked as new

Screenshots/Recordings

Before

N/A

After

N/A

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
Changes Perps market-data fallback and category labeling for real markets; wrong metadata could mis-filter or mis-label markets, though pricing still comes from the provider.

Overview
Adds a temporary Yarn patch on @metamask/perps-controller@13.0.0 (wired through package.json / yarn.lock) until an upstream release includes the Core fix.

The patch changes how Perps loads Terminal market metadata when the v2 global snapshot is tried but cannot supply prices: it now still calls the legacy Terminal markets API so categories and related fields stay aligned while live provider prices are used. It also derives marketType from Terminal’s category when marketType is missing, and clears stale isNewMarket when Terminal metadata applies a type.

Static HIP-3 fallbacks reclassify xyz:CBRS and xyz:SPCX from Pre-IPO to Stock (IPOP stays Pre-IPO).

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

@abretonc7s abretonc7s self-assigned this Aug 27, 2026
@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 Aug 27, 2026
@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.

@metamask-ci metamask-ci Bot added the team-perps Perps team label Aug 27, 2026
@abretonc7s
abretonc7s marked this pull request as ready for review August 27, 2026 13:31
@abretonc7s
abretonc7s requested a review from a team as a code owner August 27, 2026 13:31
@github-actions github-actions Bot added size-M risk:high AI analysis: high risk labels Aug 27, 2026
@sonarqubecloud

Copy link
Copy Markdown

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.57%. Comparing base (a0f4181) to head (484a064).
⚠️ Report is 8 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #35379      +/-   ##
==========================================
+ Coverage   85.56%   85.57%   +0.01%     
==========================================
  Files        6669     6673       +4     
  Lines      183853   184244     +391     
  Branches    45423    45556     +133     
==========================================
+ Hits       157308   157674     +366     
- Misses      16118    16129      +11     
- Partials    10427    10441      +14     

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

@abretonc7s

Copy link
Copy Markdown
Contributor Author

Closing because this reintroduced the deprecated Terminal v1 metadata path. The intended fallback remains Terminal v2 to Hyperliquid, with local controller mappings for degraded categories. We will replace this with a smaller local-mapping-only change.

@abretonc7s abretonc7s closed this Aug 27, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Aug 27, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

pr-not-ready-for-e2e Skip E2E and block merging. Remove this label once the PR is ready to run the E2E tests. risk:high AI analysis: high risk size-M team-perps Perps team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants