feat(perps-controller): add hardcoded market collections registry#9106
Open
michalconsensys wants to merge 5 commits into
Open
feat(perps-controller): add hardcoded market collections registry#9106michalconsensys wants to merge 5 commits into
michalconsensys wants to merge 5 commits into
Conversation
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)
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
PerpsMarketCollectionTagenum: 27-value string enum covering thematic groupings (L1, DeFi, Memecoin, Bitcoin Ecosystem, etc.).PerpsMarketDefinitiontype: Each market has atickerand acollectionsarray of tags.PERPS_MARKET_DEFINITIONS(175 market entries) andPERPS_MARKET_COLLECTION_TAGS(ordered tag list for UI filter pills).getMarketDefinitionByTicker(O(1) Map-backed lookup) andgetMarketDefinitionsByCollection(filter by tag).getMarketCollections(),getMarketDefinitions(),getMarketDefinitionByTicker(ticker),getMarketDefinitionsByCollection(collection)-- all registered as messenger actions.Markets with no collection tags were excluded from the registry (8 markets: NXPC, XPL, AVNT, 2Z, CC, FOGO, SKR, CHIP).
References
N/A
Checklist
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) andPerpsMarketDefinition(ticker+collections) backPERPS_MARKET_DEFINITIONS(175 markets) andPERPS_MARKET_COLLECTION_TAGS, withgetMarketDefinitionByTicker(Map lookup) andgetMarketDefinitionsByCollection.PerpsControllerexposes the same via messenger actions:getMarketCollections,getMarketDefinitions,getMarketDefinitionByTicker, andgetMarketDefinitionsByCollection. 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.