Event & Market Details Page
Relevant source files
The following files were used as context for generating this wiki page:
- src/app/[locale]/(platform)/event/[slug]/_components/EventContent.tsx
- src/lib/structured-data.ts
- src/lib/event-open-graph.ts
- src/lib/event-faq-server.ts
- src/app/[locale]/(platform)/event/[slug]/_utils/EventChartUtils.ts (Derived from tests/unit/EventChartUtils.test.ts)
- src/app/[locale]/(platform)/sports/_components/SportsEventAboutPanel.tsx
- src/lib/ai/market-context-template.ts
The Event & Market Details Page serves as the primary interface for users to interact with specific prediction events and their underlying markets. It aggregates real-time trading data, historical price charts, order books, and contextual information to facilitate informed trading decisions. The page is designed to handle both binary markets (Yes/No) and multi-outcome markets, providing specific UI components for each.
Key responsibilities of this module include rendering the event lifecycle (from scheduling to resolution), providing AI-generated market context, and ensuring high SEO visibility through structured data and Open Graph metadata.
Component Architecture
The page is structured around a central content area and a contextual sidebar. The layout adapts based on the market type and the existence of "Negative Risk" configurations.
Main Content Components
The EventContent component serves as the layout orchestrator, managing the grid and slot-based rendering of market details.
- EventHeader: Displays the event title and core metadata.
- EventChartSection: Renders price history. It is conditionally hidden in multi-market events unless "Negative Risk" is enabled.
- EventMarketsSection: Lists available outcomes and their current probabilities.
- EventMarketContext: An AI-powered component that generates narrative recaps based on structured market data.
- EventRules: Displays the legal and technical criteria for market resolution.
- ResolutionTimelinePanel: Shows the progress of market settlement, particularly for UMA-resolved markets.
Sources: [src/app/[locale]/(platform)/event/[slug]/_components/EventContent.tsx:68-109], [src/app/[locale]/(platform)/sports/_components/SportsEventAboutPanel.tsx:84-118]
Layout and Flow
The following diagram illustrates the data flow and component hierarchy within the Event Details page:
The EventMarketChannelProvider wraps the content to provide real-time updates across all sub-components. Sources: [src/app/[locale]/(platform)/event/[slug]/_components/EventContent.tsx:75-115]
Market Logic and Resolution
Markets are categorized as either active, resolved, or archived. The page logic determines which market to focus on based on its status and user selection.
Focused Market Resolution
When a page is loaded, the system resolves the "Initial Market" to display. It prioritizes active, unresolved markets. If a marketSlug is provided in the URL, that market takes precedence.
Sources: [src/app/[locale]/(platform)/event/[slug]/_components/EventContent.tsx:43-52]
Resolution Timeline
For markets utilizing decentralized oracles (like UMA), the ResolutionTimelinePanel displays the state of the resolution process.
| Field | Description |
|---|---|
is_resolved | Boolean indicating if the market has reached a final state. |
outcomeOverride | Used to display the winning outcome in the timeline. |
settledUrl | Link to the on-chain settlement transaction or oracle evidence. |
Sources: [src/app/[locale]/(platform)/event/[slug]/_components/EventContent.tsx:39-41], [src/app/[locale]/(platform)/sports/_components/SportsEventAboutPanel.tsx:43-69]
Price History and Charting
The system utilizes utility functions to handle price series, ensuring charts are correctly anchored and extended even when live data is sparse.
Chart Utilities
- buildHistoryWithLatestPointOverride: Extends the last known price to the current time or market resolution time to prevent "gaps" at the end of the chart.
- resolveChartRangeStartMs: Calculates the start timestamp based on user-selected filters (e.g., 1H, 6H, ALL), ensuring the chart doesn't display data prior to event creation.
- getSportsMoneylineMarketIds: Organizes sports markets into a specific Team-Draw-Team order for soccer or deduplicates binary moneyline outcomes.
Sources: [tests/unit/EventChartUtils.test.ts:9-85]
AI-Generated Market Context
The platform leverages AI to provide "high-quality prediction market recaps." This system uses a structured prompt template and specific variables derived from the market state.
Context Variables
The AI uses the following structured data points to generate narrative summaries:
| Variable | Description |
|---|---|
market-probability | Implied probability formatted as a percentage. |
market-price | Current YES share price in cents. |
market-volume-24h | 24-hour trading volume in USD. |
market-outcomes | Snapshot of all possible outcomes. |
Sources: [src/lib/ai/market-context-template.ts:7-21]
Prompt Logic
The AI is instructed to produce clean paragraphs (avoiding bullet points) covering market positioning, recent news catalysts, and risk factors for traders.
Sources: [src/lib/ai/market-context-template.ts:23-45]
SEO and Metadata Generation
Extensive logic exists to ensure event pages are correctly indexed and shareable on social platforms.
Structured Data (JSON-LD)
The buildEventStructuredData function generates Schema.org compliant data, including:
- Event: Includes name, status (Scheduled, Completed, or Cancelled), and virtual location.
- BreadcrumbList: Dynamically builds pathing (e.g., Home > Politics > Iran > Event Title).
- FAQPage: Automatically generates an FAQ section for search engines based on market-specific questions.
Sources: [src/lib/structured-data.ts:182-243], [src/lib/event-faq-server.ts:25-224]
Open Graph (OG) Images
Social media previews are versioned to ensure that price updates are reflected in shared links. The version string includes the updated_at timestamp, the focused market slug, and the YES price fixed to 4 decimal places.
export function buildEventOgImageVersion(event: Event, marketSlug?: string | null) {
const focusedMarket = resolveFocusedMarket(event, marketSlug)
const yesOutcome = focusedMarket?.outcomes.find((outcome) => outcome.outcome_index === OUTCOME_INDEX.YES)
const yesPrice = typeof yesOutcome?.buy_price === 'number' ? yesOutcome.buy_price : focusedMarket?.price
return [
event.updated_at || event.created_at,
focusedMarket?.slug ?? event.slug,
typeof yesPrice === 'number' ? yesPrice.toFixed(4) : 'na',
Number.isFinite(event.volume) ? event.volume.toFixed(2) : '0.00',
].join(':')
}
Sources: [src/lib/event-open-graph.ts:68-80]
Summary
The Event & Market Details Page is a highly dynamic module that balances real-time financial data with rich contextual information. By utilizing a modular component architecture and specialized utility functions for charting and SEO, the page provides a robust environment for prediction market participants while maintaining high technical performance and search engine visibility.