Overview
TheMarketBar component displays real-time market information including the current price, 24-hour statistics (volume, high, low), and market pair details. It integrates with the trading context to show live price updates.
Props
The market identifier for the trading pair (e.g., “SOL_USDC”)
Displayed Information
Market Pair Section
Market Identifier Display
Market Identifier Display
- Token icons: Overlapping SOL and USDC logos
- Market name: “SOL/USDC” text label
- Fixed width: 308px container with rounded border
- Styling: Container background with border and hover effect
Price Section
Live Price Display
Live Price Display
The component shows:
- Current price: Live price from
TradesContext - Status indicator: Green dot showing market is active
- Price change: 24h percentage change with color coding
24-Hour Statistics
The component displays three key metrics:Total trading volume in USD over the last 24 hoursFormat:
$XX,XXX with locale-specific number formattingHighest price reached in the last 24 hoursFormat:
$XXX.XXLowest price reached in the last 24 hoursFormat:
$XXX.XXContext Integration
The component usesTradesContext for state management:
- ticker
- price
- stats
Contains 24h market statistics:
Data Loading
Initial Fetch
On component mount or market change:The effect depends on ticker values, so it updates whenever ticker data changes.
Color Coding
Price Change Indicator
The component uses semantic colors for price changes:- Positive:
text-positive-green(price increased) - Negative:
text-negative-red(price decreased)
Status Indicator
A green dot indicates the market is active:Responsive Behavior
- Mobile (< 768px)
- Desktop (≥ 768px)
- Market name hidden (
hidden md:block) - Statistics section hidden
- Only icons and price visible
Usage Example
Must be wrapped in
TradesProvider to access market data context.Layout Structure
Styling Features
Container Styling
- Background:
bg-container-bg - Borders:
border-container-border - Hover:
hover:bg-container-bg-hover - Rounded corners:
rounded-xlon containers
Scrolling
- Desktop: Thin scrollbar (
thin-scroll) - Mobile: Hidden scrollbar (
hidden-scroll) - Behavior: Horizontal scroll for overflow stats
Source Code Reference
See implementation in:apps/web/src/components/MarketBar.tsx:1-109
Stats Rendering Logic
Stats Rendering Logic