UI Types
Drift Common provides specialized type definitions for working with markets in UI applications. These types provide type-safe market identification, caching, and symbol management.MarketId
A type-safe identifier for Drift markets that handles both perpetual and spot markets.Import
Creating Market IDs
Perpetual Markets
Spot Markets
From Market Key
Properties
Usage Examples
Checking Market Type
Using Market Keys
Comparing Markets
Generating Market Keys
Caching
MarketId instances are automatically cached to ensure referential equality:UIMarket
An extended market type that combines MarketId with market configuration and provides UI-specific symbol formatting.Import
Creating UI Markets
Properties
Symbol Types
UIMarket provides four different symbol representations:Symbol Type Examples
Usage Examples
Displaying Market Information
Working with Precision
Filtering Markets
Accessing Market Config
Setting Custom Markets
For testing or custom environments, you can set custom market configurations:MarketKey
An opaque type representing a unique market identifier string.Usage
Symbol Types
MarketSymbol
Raw symbol from market configuration.MarketDisplaySymbol
User-facing market label.BaseAssetSymbol
Underlying asset identifier (used for icons, etc.).BaseAssetDisplaySymbol
What the user is holding/trading.Best Practices
Use MarketId for Identification
Use UIMarket for Display
Cache Market Instances
Use Proper Symbol Types
Related
- Serializable Types - Types for data serialization
- Config Types - Configuration type definitions
- Constants - Market and pool constants