Skip to content

fix(perps-controller): map Terminal v1 category onto client marketType - #9907

Open
geositta wants to merge 3 commits into
mainfrom
fix/perps-unitree-pre-ipo
Open

fix(perps-controller): map Terminal v1 category onto client marketType#9907
geositta wants to merge 3 commits into
mainfrom
fix/perps-unitree-pre-ipo

Conversation

@geositta

@geositta geositta commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Explanation

What is the current state of things and why does it need to change?

Mobile's Pre-IPO chip filters on marketType === "pre-ipo". Production Terminal v1 already sends Unitree, CXMT, and SKHY as category: "pre_ipo", but v1 #extractMetadata only copied marketType / categories and dropped category. Those markets left marketType unset and did not appear under Pre-IPO.

Cerebras (xyz:CBRS) and SpaceX (xyz:SPCX) are public. Terminal already classifies them as stocks, but HIP3_ASSET_MARKET_TYPES still tags them pre-ipo from an older client override, so they stay on the Pre-IPO chip when Terminal does not set marketType.

What is the solution your changes offer and how does it work?

#categoryToMarketType is the single Terminal → client alias table (pre_ipopre-ipo, stocksstock, plus passthrough of values already in MarketCategory). v2 #marketTypeFor and v1 #extractMetadata both use it. Explicit v1 marketType still wins.

When Terminal is on, Unitree / CXMT / SKHY get pre-ipo from category, and CBRS / SPCX get stock. HIP3_ASSET_MARKET_TYPES moves CBRS and SPCX to stock so the HyperLiquid-direct fallback matches. xyz:IPOP (Quantinuum) stays Pre-IPO.

Are there any changes whose purpose might not obvious to those unfamiliar with the domain?

This is not a typo in the mobile filter and not an old-app shim. Terminal and the client use different field names and spellings today (category: "pre_ipo" vs marketType: "pre-ipo"). The controller is the adapter; changing the chip to compare "pre_ipo" would still miss Unitree (marketType is unset) and would drop markets that already use "pre-ipo".

We do not map only pre_ipo and leave stocks alone. That was protecting the stale CBRS/SPCX Pre-IPO override.

If your primary goal was to update one package but you found you had to update another one along the way, why did you do so?

Only @metamask/perps-controller changed. No other package in this repo.

If you had to upgrade a dependency, why did you do so?

No dependency upgrades.

References

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Low Risk
Localized market classification and filter-bucket behavior in perps-controller; no auth, trading, or payment paths.

Overview
Fixes Pre-IPO and stock category filters when Mobile uses Terminal v1 metadata: markets like Unitree were sent as category: "pre_ipo" but never got marketType, so they did not match pre-ipo.

Terminal → client mapping: Adds shared #categoryToMarketType (pre_ipopre-ipo, stocksstock, plus valid MarketCategory passthrough). v1 #extractMetadata now reads category on the schema and uses this when marketType is missing; explicit marketType still wins. v2 #marketTypeFor delegates to the same helper.

Enrichment parity: When v1 Terminal metadata applies a marketType, MarketDataService clears isNewMarket so categorized HIP-3 markets are not also in the new filter (aligned with the v2 snapshot path).

Static fallback: Moves xyz:CBRS and xyz:SPCX from pre-ipo to stock in HIP3_ASSET_MARKET_TYPES when Terminal/HyperLiquid fallback is used; xyz:IPOP stays Pre-IPO.

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

@geositta
geositta marked this pull request as ready for review August 19, 2026 13:35
@geositta
geositta requested review from a team as code owners August 19, 2026 13:35
@geositta
geositta deployed to default-branch August 19, 2026 13:35 — with GitHub Actions Active
@geositta
geositta force-pushed the fix/perps-unitree-pre-ipo branch from ea05173 to 1c30c50 Compare August 19, 2026 13:45

@cursor cursor Bot left a comment

Copy link
Copy Markdown

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 1c30c50. Configure here.

Comment thread packages/perps-controller/src/services/TerminalMarketService.ts
@geositta
geositta force-pushed the fix/perps-unitree-pre-ipo branch from f96a3c9 to 6d1b7ca Compare August 20, 2026 05:51

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

We should be using v2 now and deprecate the v1 endpoint.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants