use rust_decimal::Decimal;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PerpetualDex {
pub name: String,
pub full_name: String,
pub deployer: String,
pub oracle_updater: Option<String>,
pub fee_recipient: Option<String>,
pub asset_to_streaming_oi_cap: Vec<(String, String)>,
}
pub type PerpetualDexs = Vec<Option<PerpetualDex>>;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssetInfo {
pub name: String,
pub sz_decimals: u8,
pub max_leverage: u32,
#[serde(skip_serializing_if = "Option::is_none")]
pub only_isolated: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub is_delisted: Option<bool>,
#[serde(skip_serializing_if = "Option::is_none")]
pub margin_mode: Option<String>,
pub margin_table_id: usize,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MarginTier {
pub lower_bound: String,
pub max_leverage: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MarginTable {
pub description: String,
pub margin_tiers: Vec<MarginTier>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PerpetualsMetadata {
pub universe: Vec<AssetInfo>,
pub margin_tables: Vec<(u32, MarginTable)>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssetContext {
#[serde(with = "rust_decimal::serde::str")]
pub day_ntl_vlm: Decimal,
#[serde(with = "rust_decimal::serde::str")]
pub funding: Decimal,
pub impact_pxs: Option<[String; 2]>,
#[serde(with = "rust_decimal::serde::str")]
pub mark_px: Decimal,
#[serde(with = "rust_decimal::serde::str_option")]
pub mid_px: Option<Decimal>,
#[serde(with = "rust_decimal::serde::str")]
pub open_interest: Decimal,
#[serde(with = "rust_decimal::serde::str")]
pub oracle_px: Decimal,
#[serde(with = "rust_decimal::serde::str_option")]
pub premium: Option<Decimal>,
#[serde(with = "rust_decimal::serde::str")]
pub prev_day_px: Decimal,
}
pub type MetaAndAssetContexts = (PerpetualsMetadata, Vec<AssetContext>);
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct CumulativeFunding {
pub all_time: String,
pub since_change: String,
pub since_open: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Leverage {
#[serde(rename = "type")]
pub type_: String,
pub value: u32,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct Position {
pub coin: String,
pub cum_funding: CumulativeFunding,
pub entry_px: String,
pub leverage: Leverage,
pub liquidation_px: String,
pub margin_used: String,
pub max_leverage: u32,
pub position_value: String,
pub return_on_equity: String,
pub szi: String,
pub unrealized_pnl: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct AssetPosition {
pub position: Position,
#[serde(rename = "type")]
pub type_: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct MarginSummary {
pub account_value: String,
pub total_margin_used: String,
pub total_ntl_pos: String,
pub total_raw_usd: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ClearinghouseState {
pub asset_positions: Vec<AssetPosition>,
pub cross_maintenance_margin_used: String,
pub cross_margin_summary: MarginSummary,
pub margin_summary: MarginSummary,
pub time: u64,
pub withdrawable: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FundingDelta {
pub coin: String,
pub funding_rate: String,
pub szi: String,
#[serde(rename = "type")]
pub type_: String,
pub usdc: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct LedgerUpdate {
pub delta: FundingDelta,
pub hash: String,
pub time: u64,
}
pub type LedgerUpdates = Vec<LedgerUpdate>;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct FundingRate {
pub coin: String,
pub funding_rate: String,
pub premium: String,
pub time: u64,
}
pub type FundingHistory = Vec<FundingRate>;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PredictedFunding {
pub funding_rate: String,
pub next_funding_time: u64,
}
pub type VenueFundings = Vec<(String, PredictedFunding)>;
pub type PredictedFundings = Vec<(String, VenueFundings)>;
pub type PerpsAtOpenInterestCap = Vec<String>;
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PerpDeployAuctionStatus {
pub start_time_seconds: u64,
pub duration_seconds: u64,
pub start_gas: String,
pub current_gas: String,
pub end_gas: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ActiveAssetData {
pub user: String,
pub coin: String,
pub leverage: Leverage,
pub max_trade_szs: [String; 2],
pub available_to_trade: [String; 2],
#[serde(with = "rust_decimal::serde::str")]
pub mark_px: Decimal,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PerpDexLimits {
#[serde(with = "rust_decimal::serde::str")]
pub total_oi_cap: Decimal,
#[serde(with = "rust_decimal::serde::str")]
pub oi_sz_cap_per_perp: Decimal,
#[serde(with = "rust_decimal::serde::str")]
pub max_transfer_ntl: Decimal,
pub coin_to_oi_cap: Vec<(Decimal, Decimal)>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct PerpDexStatus {
#[serde(with = "rust_decimal::serde::str")]
pub total_net_deposit: Decimal,
}