use crate::shared::{OrderBookId, PubkeyStr};
use chrono::{DateTime, Utc};
use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct OrderbookTickerEntry {
pub orderbook_id: OrderBookId,
pub market_pubkey: PubkeyStr,
#[serde(default)]
pub outcome_index: Option<i16>,
#[serde(default)]
pub outcome_name: Option<String>,
#[serde(default)]
pub outcome_name_long: Option<String>,
pub base_deposit_asset: PubkeyStr,
pub quote_deposit_asset: PubkeyStr,
#[serde(default)]
pub best_bid: Option<Decimal>,
#[serde(default)]
pub best_ask: Option<Decimal>,
#[serde(default)]
pub midpoint: Option<Decimal>,
#[serde(default)]
pub computed_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct OrderbookTickersResponse {
pub tickers: Vec<OrderbookTickerEntry>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct PlatformMetrics {
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub unique_traders_24h: i32,
pub unique_traders_7d: i32,
pub unique_traders_30d: i32,
pub active_markets: i64,
pub active_orderbooks: i64,
pub deposit_token_volumes: Vec<DepositTokenVolumeMetrics>,
#[serde(default)]
pub updated_at: Option<DateTime<Utc>>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct MarketVolumeMetrics {
pub market_pubkey: PubkeyStr,
#[serde(default)]
pub slug: Option<String>,
#[serde(default)]
pub market_name: Option<String>,
#[serde(default)]
pub category: Option<String>,
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub unique_traders_24h: i32,
pub unique_traders_7d: i32,
pub unique_traders_30d: i32,
pub category_volume_share_24h_pct: Decimal,
pub platform_volume_share_24h_pct: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct MarketsMetrics {
pub markets: Vec<MarketVolumeMetrics>,
pub total: usize,
}
impl Default for MarketsMetrics {
fn default() -> Self {
Self {
markets: Vec::new(),
total: 0,
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct OutcomeVolumeMetrics {
pub outcome_index: Option<i16>,
#[serde(default)]
pub outcome_name: Option<String>,
#[serde(default)]
pub outcome_name_long: Option<String>,
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub unique_traders_24h: i32,
pub unique_traders_7d: i32,
pub unique_traders_30d: i32,
pub volume_share_24h_pct: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct MarketOrderbookVolumeMetrics {
pub orderbook_id: OrderBookId,
pub outcome_index: Option<i16>,
#[serde(default)]
pub outcome_name: Option<String>,
#[serde(default)]
pub outcome_name_long: Option<String>,
pub base_deposit_asset: PubkeyStr,
#[serde(default)]
pub base_deposit_symbol: Option<String>,
pub quote_deposit_asset: PubkeyStr,
#[serde(default)]
pub quote_deposit_symbol: Option<String>,
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub volume_24h_base: Decimal,
pub volume_7d_base: Decimal,
pub volume_30d_base: Decimal,
pub volume_total_base: Decimal,
pub volume_24h_quote: Decimal,
pub volume_7d_quote: Decimal,
pub volume_30d_quote: Decimal,
pub volume_total_quote: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_bid_volume_24h_base: Decimal,
pub taker_bid_volume_7d_base: Decimal,
pub taker_bid_volume_30d_base: Decimal,
pub taker_bid_volume_total_base: Decimal,
pub taker_bid_volume_24h_quote: Decimal,
pub taker_bid_volume_7d_quote: Decimal,
pub taker_bid_volume_30d_quote: Decimal,
pub taker_bid_volume_total_quote: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_ask_volume_24h_base: Decimal,
pub taker_ask_volume_7d_base: Decimal,
pub taker_ask_volume_30d_base: Decimal,
pub taker_ask_volume_total_base: Decimal,
pub taker_ask_volume_24h_quote: Decimal,
pub taker_ask_volume_7d_quote: Decimal,
pub taker_ask_volume_30d_quote: Decimal,
pub taker_ask_volume_total_quote: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub volume_share_24h_pct: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct MarketDetailMetrics {
pub market_pubkey: PubkeyStr,
#[serde(default)]
pub slug: Option<String>,
#[serde(default)]
pub market_name: Option<String>,
#[serde(default)]
pub category: Option<String>,
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub unique_traders_24h: i32,
pub unique_traders_7d: i32,
pub unique_traders_30d: i32,
pub category_volume_share_24h_pct: Decimal,
pub platform_volume_share_24h_pct: Decimal,
pub outcome_volumes: Vec<OutcomeVolumeMetrics>,
pub orderbook_volumes: Vec<MarketOrderbookVolumeMetrics>,
pub deposit_token_volumes: Vec<DepositTokenVolumeMetrics>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct OrderbookVolumeMetrics {
pub orderbook_id: OrderBookId,
pub market_pubkey: PubkeyStr,
pub outcome_index: Option<i16>,
#[serde(default)]
pub outcome_name: Option<String>,
#[serde(default)]
pub outcome_name_long: Option<String>,
pub base_deposit_asset: PubkeyStr,
#[serde(default)]
pub base_deposit_symbol: Option<String>,
pub quote_deposit_asset: PubkeyStr,
#[serde(default)]
pub quote_deposit_symbol: Option<String>,
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub volume_24h_base: Decimal,
pub volume_7d_base: Decimal,
pub volume_30d_base: Decimal,
pub volume_total_base: Decimal,
pub volume_24h_quote: Decimal,
pub volume_7d_quote: Decimal,
pub volume_30d_quote: Decimal,
pub volume_total_quote: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_bid_volume_24h_base: Decimal,
pub taker_bid_volume_7d_base: Decimal,
pub taker_bid_volume_30d_base: Decimal,
pub taker_bid_volume_total_base: Decimal,
pub taker_bid_volume_24h_quote: Decimal,
pub taker_bid_volume_7d_quote: Decimal,
pub taker_bid_volume_30d_quote: Decimal,
pub taker_bid_volume_total_quote: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_ask_volume_24h_base: Decimal,
pub taker_ask_volume_7d_base: Decimal,
pub taker_ask_volume_30d_base: Decimal,
pub taker_ask_volume_total_base: Decimal,
pub taker_ask_volume_24h_quote: Decimal,
pub taker_ask_volume_7d_quote: Decimal,
pub taker_ask_volume_30d_quote: Decimal,
pub taker_ask_volume_total_quote: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub unique_traders_24h: i32,
pub unique_traders_7d: i32,
pub unique_traders_30d: i32,
pub market_volume_share_24h_pct: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct CategoryVolumeMetrics {
pub category: String,
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub unique_traders_24h: i32,
pub unique_traders_7d: i32,
pub unique_traders_30d: i32,
pub platform_volume_share_24h_pct: Decimal,
pub deposit_token_volumes: Vec<DepositTokenVolumeMetrics>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct CategoriesMetrics {
pub categories: Vec<CategoryVolumeMetrics>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DepositTokenVolumeMetrics {
pub deposit_asset: PubkeyStr,
#[serde(default)]
pub symbol: Option<String>,
pub volume_24h_usd: Decimal,
pub volume_7d_usd: Decimal,
pub volume_30d_usd: Decimal,
pub volume_total_usd: Decimal,
pub taker_bid_volume_24h_usd: Decimal,
pub taker_bid_volume_7d_usd: Decimal,
pub taker_bid_volume_30d_usd: Decimal,
pub taker_bid_volume_total_usd: Decimal,
pub taker_ask_volume_24h_usd: Decimal,
pub taker_ask_volume_7d_usd: Decimal,
pub taker_ask_volume_30d_usd: Decimal,
pub taker_ask_volume_total_usd: Decimal,
pub taker_bid_ask_imbalance_24h_pct: Decimal,
pub taker_bid_ask_imbalance_7d_pct: Decimal,
pub taker_bid_ask_imbalance_30d_pct: Decimal,
pub taker_bid_ask_imbalance_total_pct: Decimal,
pub volume_share_24h_pct: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct DepositTokensMetrics {
pub deposit_tokens: Vec<DepositTokenVolumeMetrics>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct LeaderboardEntry {
pub rank: i32,
pub market_pubkey: PubkeyStr,
#[serde(default)]
pub slug: Option<String>,
#[serde(default)]
pub market_name: Option<String>,
#[serde(default)]
pub category: Option<String>,
pub volume_24h_usd: Decimal,
pub category_volume_share_24h_pct: Decimal,
pub platform_volume_share_24h_pct: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct Leaderboard {
pub entries: Vec<LeaderboardEntry>,
pub period: String,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct HistoryPoint {
pub bucket_start: i64,
pub volume_usd: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
pub struct MetricsHistory {
pub scope: String,
pub scope_key: String,
pub resolution: String,
pub points: Vec<HistoryPoint>,
}
#[derive(Debug, Clone, Default, Serialize, PartialEq)]
pub struct MarketsMetricsQuery {}
#[derive(Debug, Clone, Default, Serialize, PartialEq)]
pub struct MarketMetricsQuery {}
#[derive(Debug, Clone, Default, Serialize, PartialEq)]
pub struct OrderbookMetricsQuery {}
#[derive(Debug, Clone, Default, Serialize, PartialEq)]
pub struct CategoryMetricsQuery {}
#[derive(Debug, Clone, Serialize, PartialEq)]
pub struct MetricsHistoryQuery {
pub resolution: String,
#[serde(skip_serializing_if = "Option::is_none")]
pub from: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub to: Option<i64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub limit: Option<usize>,
}
impl Default for MetricsHistoryQuery {
fn default() -> Self {
Self {
resolution: "1h".to_string(),
from: None,
to: None,
limit: None,
}
}
}
#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
pub struct UserMetrics {
pub wallet_address: PubkeyStr,
pub total_outcomes_traded: i64,
pub total_volume_usd: Decimal,
pub total_referrals_used: i64,
}