use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct UserValue {
pub user: String,
pub value: f64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct OpenInterest {
pub market: String,
pub value: f64,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum PositionSortBy {
Current,
Initial,
Tokens,
CashPnl,
PercentPnl,
Title,
Resolving,
Price,
AvgPrice,
}
impl std::fmt::Display for PositionSortBy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Current => write!(f, "CURRENT"),
Self::Initial => write!(f, "INITIAL"),
Self::Tokens => write!(f, "TOKENS"),
Self::CashPnl => write!(f, "CASHPNL"),
Self::PercentPnl => write!(f, "PERCENTPNL"),
Self::Title => write!(f, "TITLE"),
Self::Resolving => write!(f, "RESOLVING"),
Self::Price => write!(f, "PRICE"),
Self::AvgPrice => write!(f, "AVGPRICE"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "UPPERCASE")]
pub enum SortDirection {
Asc,
#[default]
Desc,
}
impl std::fmt::Display for SortDirection {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Asc => write!(f, "ASC"),
Self::Desc => write!(f, "DESC"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ClosedPositionSortBy {
#[default]
RealizedPnl,
Title,
Price,
AvgPrice,
Timestamp,
}
impl std::fmt::Display for ClosedPositionSortBy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::RealizedPnl => write!(f, "REALIZEDPNL"),
Self::Title => write!(f, "TITLE"),
Self::Price => write!(f, "PRICE"),
Self::AvgPrice => write!(f, "AVGPRICE"),
Self::Timestamp => write!(f, "TIMESTAMP"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all(deserialize = "camelCase"))]
pub struct ClosedPosition {
pub proxy_wallet: String,
pub asset: String,
pub condition_id: String,
pub avg_price: f64,
pub total_bought: f64,
pub realized_pnl: f64,
pub cur_price: f64,
pub timestamp: i64,
pub title: String,
pub slug: String,
pub icon: Option<String>,
pub event_slug: Option<String>,
pub outcome: String,
pub outcome_index: u32,
pub opposite_outcome: String,
pub opposite_asset: String,
pub end_date: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum TradeSide {
Buy,
Sell,
}
impl std::fmt::Display for TradeSide {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Buy => write!(f, "BUY"),
Self::Sell => write!(f, "SELL"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum TradeFilterType {
Cash,
Tokens,
}
impl std::fmt::Display for TradeFilterType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Cash => write!(f, "CASH"),
Self::Tokens => write!(f, "TOKENS"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all(deserialize = "camelCase"))]
pub struct Trade {
pub proxy_wallet: String,
pub side: TradeSide,
pub asset: String,
pub condition_id: String,
pub size: f64,
pub price: f64,
pub timestamp: i64,
pub title: String,
pub slug: String,
pub icon: Option<String>,
pub event_slug: Option<String>,
pub outcome: String,
pub outcome_index: u32,
pub name: Option<String>,
pub pseudonym: Option<String>,
pub bio: Option<String>,
pub profile_image: Option<String>,
pub profile_image_optimized: Option<String>,
pub transaction_hash: Option<String>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum ActivityType {
Trade,
Split,
Merge,
Redeem,
Reward,
Conversion,
}
impl std::fmt::Display for ActivityType {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Trade => write!(f, "TRADE"),
Self::Split => write!(f, "SPLIT"),
Self::Merge => write!(f, "MERGE"),
Self::Redeem => write!(f, "REDEEM"),
Self::Reward => write!(f, "REWARD"),
Self::Conversion => write!(f, "CONVERSION"),
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ActivitySortBy {
#[default]
Timestamp,
Tokens,
Cash,
}
impl std::fmt::Display for ActivitySortBy {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self {
Self::Timestamp => write!(f, "TIMESTAMP"),
Self::Tokens => write!(f, "TOKENS"),
Self::Cash => write!(f, "CASH"),
}
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all(deserialize = "camelCase"))]
pub struct Activity {
pub proxy_wallet: String,
pub timestamp: i64,
pub condition_id: String,
#[serde(rename = "type")]
pub activity_type: ActivityType,
pub size: f64,
pub usdc_size: f64,
pub transaction_hash: Option<String>,
pub price: Option<f64>,
pub asset: Option<String>,
pub side: Option<String>,
pub outcome_index: Option<u32>,
pub title: Option<String>,
pub slug: Option<String>,
pub icon: Option<String>,
pub outcome: Option<String>,
pub name: Option<String>,
pub pseudonym: Option<String>,
pub bio: Option<String>,
pub profile_image: Option<String>,
pub profile_image_optimized: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all(deserialize = "camelCase"))]
pub struct Position {
pub proxy_wallet: String,
pub asset: String,
pub condition_id: String,
pub size: f64,
pub avg_price: f64,
pub initial_value: f64,
pub current_value: f64,
pub cash_pnl: f64,
pub percent_pnl: f64,
pub total_bought: f64,
pub realized_pnl: f64,
pub percent_realized_pnl: f64,
pub cur_price: f64,
pub redeemable: bool,
pub mergeable: bool,
pub title: String,
pub slug: String,
pub icon: Option<String>,
pub event_slug: Option<String>,
pub outcome: String,
pub outcome_index: u32,
pub opposite_outcome: String,
pub opposite_asset: String,
pub end_date: Option<String>,
pub negative_risk: bool,
}