Skip to content

feat(perps-controller): add hardcoded market collections registry#9106

Open
michalconsensys wants to merge 5 commits into
mainfrom
perps-market-collections
Open

feat(perps-controller): add hardcoded market collections registry#9106
michalconsensys wants to merge 5 commits into
mainfrom
perps-market-collections

Conversation

@michalconsensys

@michalconsensys michalconsensys commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Explanation

The perps controller needs a canonical, hardcoded registry of all supported perpetual markets along with their collection/category tags so that consumers (mobile, extension) can display collection-based filters and look up market metadata without hitting any API.

This PR adds:

  • PerpsMarketCollectionTag enum: 27-value string enum covering thematic groupings (L1, DeFi, Memecoin, Bitcoin Ecosystem, etc.).
  • PerpsMarketDefinition type: Each market has a ticker and a collections array of tags.
  • Constants: PERPS_MARKET_DEFINITIONS (175 market entries) and PERPS_MARKET_COLLECTION_TAGS (ordered tag list for UI filter pills).
  • Utility functions: getMarketDefinitionByTicker (O(1) Map-backed lookup) and getMarketDefinitionsByCollection (filter by tag).
  • Controller methods: getMarketCollections(), getMarketDefinitions(), getMarketDefinitionByTicker(ticker), getMarketDefinitionsByCollection(collection) -- all registered as messenger actions.
  • Tests: 17 tests covering the constants, utility functions, and edge cases (case sensitivity, data integrity, tag coverage).

Markets with no collection tags were excluded from the registry (8 markets: NXPC, XPL, AVNT, 2Z, CC, FOGO, SKR, CHIP).

References

N/A

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
Additive read-only metadata and new controller getters; no changes to order, position, or provider trading paths.

Overview
Adds a hardcoded market collections registry so perps clients can drive collection filter pills and ticker metadata without an API.

New PerpsMarketCollectionTag (27 thematic tags) and PerpsMarketDefinition (ticker + collections) back PERPS_MARKET_DEFINITIONS (175 markets) and PERPS_MARKET_COLLECTION_TAGS, with getMarketDefinitionByTicker (Map lookup) and getMarketDefinitionsByCollection. PerpsController exposes the same via messenger actions: getMarketCollections, getMarketDefinitions, getMarketDefinitionByTicker, and getMarketDefinitionsByCollection. Constants and types are re-exported from the package; changelog and unit tests cover registry integrity and lookup behavior.

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

Add a canonical registry of 183 perps markets with ticker, max leverage,
and collection tags (e.g. L1, DeFi, Memecoin). Expose accessor methods
on PerpsController and pure utility functions for lookup and filtering.
…everage and empty markets

- Convert PerpsMarketCollectionTag from string literal union to string enum
- Remove maxLeverage from PerpsMarketDefinition (already available via provider)
- Remove 8 markets with no collection tags (NXPC, XPL, AVNT, 2Z, CC, FOGO, SKR, CHIP)
@michalconsensys michalconsensys marked this pull request as ready for review June 12, 2026 08:40
@michalconsensys michalconsensys requested review from a team as code owners June 12, 2026 08:40
…errors

Rename short identifiers (T -> Tag, m -> market) and remove
conditional expect in tests to satisfy id-length and
jest/no-conditional-expect lint rules.
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.

1 participant