feat(perps): extend market categories#8892
Conversation
abretonc7s
left a comment
There was a problem hiding this comment.
Category filtering currently accepts valid inputs that return empty or incomplete results. Watchlist filtering needs implementation or removal from the accepted API, and explicit crypto categorization should be honored.
abretonc7s
left a comment
There was a problem hiding this comment.
One more API-surface issue: GetMarketsParams now exposes filters that getMarkets does not apply.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ 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 46c4f27. Configure here.
abretonc7s
left a comment
There was a problem hiding this comment.
One TypeScript API compatibility issue remains.
abretonc7s
left a comment
There was a problem hiding this comment.
Automated review — see comment above for full details.
Automated Review — PR #8892
Summary
Full review detailsValidation
No video evidence recorded. |
abretonc7s
left a comment
There was a problem hiding this comment.
Automated review — see comment above for full details.

Explanation
Implements TAT-3182 — expands market categories in
@metamask/perps-controllerwith a new enum, static array, and filtering/sorting support ongetMarketDataWithPrices.What changed
New types and constants
MarketCategoryenum (crypto,stock,pre-ipo,index,etf,commodity,forex) — replaces ad-hoc string literals inHIP3_ASSET_MARKET_TYPESMarketTypetype alias kept for backward compatibilityMARKET_CATEGORIESconstant (readonly MarketTypeFilter[]) — 7 ordered category pills, enforced viasatisfies; does not include'all'/'new'sentinels (those are separate UI controls)SortFieldandSortDirectionmoved totypes/index.ts(re-exported fromutils/sortMarkets) to avoid circular importsNew controller method
getMarketCategories()— returnsMARKET_CATEGORIESso clients can enumerate pills at runtime without hardcoding the listExtended params
GetMarketsParamsgains four optional fields:categories,sortBy,direction,limitPerpsProvider.getMarketDataWithPrices()accepts the same fields viaPick<GetMarketsParams, ...>Filtering / sorting / pagination (in
MarketDataService, notPerpsController)matchesCategory()— pure function mappingMarketTypeFilter | 'watchlist'to aPerpsMarketDatapredicateapplyMarketFilters()— applies category filter (OR logic) → sort → slice in orderMarketDataService.getMarketDataWithPrices()— new service method with tracing and error handling that fetches from the provider then applies filtersBreaking change
'equity'market type replaced by'stock','pre-ipo','index','etf'References
Checklist
Note
Medium Risk
Breaking
MarketTypechange (equity→ stock/pre-ipo/index/etf) requires consumer updates; market list behavior now depends on post-fetch filtering inMarketDataService, which can affect UI lists and preload if params differ from before.Overview
Extends perps market discovery with granular HIP-3 categories and server-side-style post-processing on priced market lists.
MarketCategory/MARKET_CATEGORIES/getMarketCategories()give clients a stable ordered list of seven UI category pills (crypto,stocks,pre-ipo,indices,etfs,commodities,forex), excludingall/newsentinels.Breaking:
MarketTypeno longer uses'equity'; assets are classified as'stock','pre-ipo','index', or'etf'(and related types).HIP3_ASSET_MARKET_TYPESis expanded and remapped accordingly (e.g. indices/ETFs split out from former equity entries,URNM→ ETF).getMarketDataWithPricesnow acceptsGetMarketDataWithPricesParams(categories,sortBy,direction,limit,excludeSymbols,standalone) and routes throughMarketDataServicewithmatchesCategory/applyMarketFilters(OR category match → exclude symbols → sort → limit) instead of calling the provider directly.SortField/SortDirectionmove to package types and are re-exported from the root.Messenger types add
PerpsController:getMarketCategories; tests cover filtering, sorting, limits, and config classification.Reviewed by Cursor Bugbot for commit d708462. Bugbot is set up for automated code reviews on this repo. Configure here.