use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StatusResponse {
pub node_connected: bool,
pub uptime_seconds: u64,
pub stream_length: u64,
pub events_stream_length: u64,
pub pending_txs: u64,
pub ws_subscribers: u64,
pub firehose_connections: u32,
pub redis_memory: String,
pub state: StateSummary,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct StateSummary {
pub market_count: u64,
pub wallet_count: u64,
pub metadata_count: u64,
pub events_buffered: u64,
pub events_processed: u64,
pub latest_block: u64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ApiKeyResponse {
pub api_key: String,
pub name: String,
pub rate_limit_per_minute: u32,
pub message: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MarketsResponse {
pub count: u64,
pub total: u64,
pub markets: Vec<MarketSummary>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct MarketSummary {
#[serde(default)]
pub token_id: Option<String>,
#[serde(default)]
pub token_ids: Option<Vec<String>>,
pub last_price: Option<f64>,
#[serde(default)]
pub volume_24h: f64,
#[serde(default)]
pub trade_count_24h: u64,
#[serde(default)]
pub last_trade_at: Option<i64>,
pub question: Option<String>,
pub slug: Option<String>,
pub outcomes: Option<Vec<String>>,
pub condition_id: Option<String>,
#[serde(default)]
pub neg_risk: Option<bool>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct MarketsListResponse {
pub count: u64,
pub total: u64,
pub cursor: Option<u64>,
pub markets: Vec<MarketSummary>,
}
#[derive(Debug, Clone, Default, Serialize)]
pub struct ListMarketsParams {
#[serde(skip_serializing_if = "Option::is_none")]
pub count: Option<u64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub sort: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub category: Option<String>,
#[serde(skip_serializing_if = "Option::is_none")]
pub min_volume: Option<f64>,
#[serde(skip_serializing_if = "Option::is_none")]
pub active_only: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub cursor: Option<u64>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct SearchResponse {
pub query: String,
pub count: u64,
pub results: Vec<MarketSummary>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct CandlesResponse {
pub candles: Vec<Candle>,
pub count: u64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct Candle {
pub timestamp: i64,
pub open: f64,
pub high: f64,
pub low: f64,
pub close: f64,
pub volume: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Settlement {
#[serde(default)]
pub id: Option<String>,
#[serde(default)]
pub status: String,
#[serde(default)]
pub taker_side: String,
#[serde(default)]
pub taker_size: String,
#[serde(default)]
pub taker_price: String,
#[serde(default)]
pub taker_wallet: Option<String>,
#[serde(default)]
pub taker_token: Option<String>,
#[serde(default)]
pub market_title: String,
#[serde(default)]
pub market_slug: Option<String>,
#[serde(default)]
pub market_image: Option<String>,
#[serde(default)]
pub event_title: Option<String>,
#[serde(default)]
pub outcome: Option<String>,
#[serde(default)]
pub timestamp: Option<String>,
#[serde(default)]
pub detected_at: Option<String>,
#[serde(default)]
pub block_number: Option<String>,
#[serde(default)]
pub tx_hash: Option<String>,
#[serde(flatten)]
pub extra: serde_json::Value,
}
#[derive(Debug, Clone, Deserialize)]
pub struct SettlementsResponse {
pub count: u64,
pub settlements: Vec<Settlement>,
#[serde(default)]
pub wallet: Option<String>,
#[serde(default)]
pub token_id: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct WalletResponse {
pub wallet: String,
#[serde(flatten)]
pub extra: serde_json::Value,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JsonRpcRequest {
pub jsonrpc: String,
pub method: String,
pub params: serde_json::Value,
pub id: serde_json::Value,
}
#[derive(Debug, Clone, Deserialize)]
pub struct JsonRpcResponse {
pub jsonrpc: String,
pub id: Option<serde_json::Value>,
pub result: Option<serde_json::Value>,
pub error: Option<JsonRpcError>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct JsonRpcError {
pub code: i32,
pub message: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct WalletPositionsResponse {
pub wallet: Option<String>,
pub count: u64,
pub positions: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OnchainPosition {
pub token_id: String,
pub size: f64,
pub avg_price: f64,
pub realized_pnl: f64,
pub total_bought: f64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct WalletOnchainPositionsResponse {
pub wallet: String,
pub source: String,
pub count: u64,
pub open_count: u64,
pub closed_count: u64,
pub total_realized_pnl: f64,
pub positions_with_pnl: u64,
pub positions: Vec<OnchainPosition>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct WalletTradesResponse {
pub wallet: Option<String>,
pub count: u64,
pub trades: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct MarketTradesResponse {
pub condition_id: Option<String>,
pub count: u64,
pub trades: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OrderbookRestResponse {
pub bids: Vec<OrderbookRestLevel>,
pub asks: Vec<OrderbookRestLevel>,
pub asset_id: String,
pub market: String,
pub hash: String,
pub last_trade_price: String,
pub min_order_size: String,
pub tick_size: String,
pub neg_risk: bool,
pub timestamp: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct OrderbookRestLevel {
pub price: String,
pub size: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct MidpointResponse {
pub mid: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct SpreadResponse {
pub spread: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct LeaderboardTrader {
pub rank: u32,
pub wallet: String,
pub name: String,
pub pnl: f64,
pub volume: f64,
#[serde(rename = "profileImage")]
pub profile_image: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct LeaderboardResponse {
pub traders: Vec<LeaderboardTrader>,
pub period: String,
pub sort: String,
#[serde(default)]
pub count: u64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct TrendingResponse {
pub carousel: Vec<serde_json::Value>,
pub breaking: Vec<serde_json::Value>,
#[serde(rename = "hotTopics")]
pub hot_topics: Vec<serde_json::Value>,
pub featured: Vec<serde_json::Value>,
pub movers: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ActivityTrade {
pub wallet: String,
pub side: String,
#[serde(rename = "tokenId")]
pub token_id: String,
#[serde(rename = "conditionId")]
pub condition_id: String,
pub size: f64,
pub price: f64,
pub timestamp: i64,
pub title: String,
pub slug: String,
#[serde(rename = "eventSlug")]
pub event_slug: String,
pub outcome: String,
pub name: String,
#[serde(rename = "txHash")]
pub tx_hash: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct ActivityResponse {
pub trades: Vec<ActivityTrade>,
pub count: u64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct MoverMarket {
pub id: String,
pub slug: String,
pub question: String,
pub image: Option<String>,
#[serde(rename = "outcomePrices")]
pub outcome_prices: Vec<String>,
#[serde(rename = "oneDayPriceChange")]
pub one_day_price_change: f64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct MoversResponse {
pub markets: Vec<MoverMarket>,
pub count: u64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct TraderProfile {
pub wallet: String,
pub name: String,
pub pseudonym: Option<String>,
#[serde(rename = "profileSlug")]
pub profile_slug: String,
#[serde(rename = "joinDate")]
pub join_date: String,
pub trades: u64,
#[serde(rename = "marketsTraded")]
pub markets_traded: u64,
#[serde(rename = "largestWin")]
pub largest_win: f64,
pub views: u64,
#[serde(rename = "totalVolume")]
pub total_volume: f64,
#[serde(rename = "totalPnl")]
pub total_pnl: f64,
#[serde(rename = "realizedPnl")]
pub realized_pnl: f64,
#[serde(rename = "unrealizedPnl")]
pub unrealized_pnl: f64,
#[serde(rename = "positionValue")]
pub position_value: f64,
#[serde(rename = "profileImage")]
pub profile_image: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct PnlPoint {
pub timestamp: i64,
pub pnl: f64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct TraderPnlResponse {
pub wallet: String,
pub period: String,
pub series: Vec<PnlPoint>,
pub count: u64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct EventMarket {
pub question: String,
#[serde(rename = "conditionId")]
pub condition_id: String,
pub outcomes: Vec<String>,
#[serde(rename = "outcomePrices")]
pub outcome_prices: Vec<String>,
pub volume: f64,
pub liquidity: f64,
pub active: bool,
pub closed: bool,
#[serde(rename = "groupItemTitle")]
pub group_item_title: Option<String>,
#[serde(rename = "tokenId")]
pub token_id: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct EventDetailResponse {
pub id: String,
pub slug: String,
pub title: String,
pub description: String,
pub image: Option<String>,
#[serde(default)]
pub icon: Option<String>,
pub active: bool,
pub closed: bool,
pub volume: f64,
#[serde(rename = "volume24hr", default)]
pub volume_24hr: f64,
pub liquidity: f64,
#[serde(rename = "openInterest", default)]
pub open_interest: Option<f64>,
#[serde(rename = "startDate")]
pub start_date: String,
#[serde(rename = "endDate", default)]
pub end_date: Option<String>,
pub markets: Vec<EventMarket>,
#[serde(rename = "similarMarkets", default)]
pub similar_markets: u64,
#[serde(default)]
pub annotations: u64,
}
#[derive(Debug, Clone, Deserialize)]
pub struct EventSearchResult {
pub id: String,
pub slug: String,
pub title: String,
pub image: Option<String>,
pub active: bool,
pub markets: Vec<serde_json::Value>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct EventSearchResponse {
pub query: String,
pub events: Vec<EventSearchResult>,
pub count: u64,
}