1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct UserValue {
6 pub user: String,
8 pub value: f64,
10}
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
14pub struct OpenInterest {
15 pub market: String,
17 pub value: f64,
19}
20
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
23#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
24pub enum PositionSortBy {
25 Current,
27 Initial,
29 Tokens,
31 CashPnl,
33 PercentPnl,
35 Title,
37 Resolving,
39 Price,
41 AvgPrice,
43}
44
45impl std::fmt::Display for PositionSortBy {
46 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
47 match self {
48 Self::Current => write!(f, "CURRENT"),
49 Self::Initial => write!(f, "INITIAL"),
50 Self::Tokens => write!(f, "TOKENS"),
51 Self::CashPnl => write!(f, "CASHPNL"),
52 Self::PercentPnl => write!(f, "PERCENTPNL"),
53 Self::Title => write!(f, "TITLE"),
54 Self::Resolving => write!(f, "RESOLVING"),
55 Self::Price => write!(f, "PRICE"),
56 Self::AvgPrice => write!(f, "AVGPRICE"),
57 }
58 }
59}
60
61#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
63#[serde(rename_all = "UPPERCASE")]
64pub enum SortDirection {
65 Asc,
67 #[default]
69 Desc,
70}
71
72impl std::fmt::Display for SortDirection {
73 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
74 match self {
75 Self::Asc => write!(f, "ASC"),
76 Self::Desc => write!(f, "DESC"),
77 }
78 }
79}
80
81#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
83#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
84pub enum ClosedPositionSortBy {
85 #[default]
87 RealizedPnl,
88 Title,
90 Price,
92 AvgPrice,
94 Timestamp,
96}
97
98impl std::fmt::Display for ClosedPositionSortBy {
99 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
100 match self {
101 Self::RealizedPnl => write!(f, "REALIZEDPNL"),
102 Self::Title => write!(f, "TITLE"),
103 Self::Price => write!(f, "PRICE"),
104 Self::AvgPrice => write!(f, "AVGPRICE"),
105 Self::Timestamp => write!(f, "TIMESTAMP"),
106 }
107 }
108}
109
110#[derive(Debug, Clone, Serialize, Deserialize)]
112#[serde(rename_all(deserialize = "camelCase"))]
113pub struct ClosedPosition {
114 pub proxy_wallet: String,
116 pub asset: String,
118 pub condition_id: String,
120 pub avg_price: f64,
122 pub total_bought: f64,
124 pub realized_pnl: f64,
126 pub cur_price: f64,
128 pub timestamp: i64,
130 pub title: String,
132 pub slug: String,
134 pub icon: Option<String>,
136 pub event_slug: Option<String>,
138 pub outcome: String,
140 pub outcome_index: u32,
142 pub opposite_outcome: String,
144 pub opposite_asset: String,
146 pub end_date: Option<String>,
148}
149
150#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
152#[serde(rename_all = "UPPERCASE")]
153pub enum TradeSide {
154 Buy,
156 Sell,
158}
159
160impl std::fmt::Display for TradeSide {
161 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
162 match self {
163 Self::Buy => write!(f, "BUY"),
164 Self::Sell => write!(f, "SELL"),
165 }
166 }
167}
168
169#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
171#[serde(rename_all = "UPPERCASE")]
172pub enum TradeFilterType {
173 Cash,
175 Tokens,
177}
178
179impl std::fmt::Display for TradeFilterType {
180 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
181 match self {
182 Self::Cash => write!(f, "CASH"),
183 Self::Tokens => write!(f, "TOKENS"),
184 }
185 }
186}
187
188#[derive(Debug, Clone, Serialize, Deserialize)]
190#[serde(rename_all(deserialize = "camelCase"))]
191pub struct Trade {
192 pub proxy_wallet: String,
194 pub side: TradeSide,
196 pub asset: String,
198 pub condition_id: String,
200 pub size: f64,
202 pub price: f64,
204 pub timestamp: i64,
206 pub title: String,
208 pub slug: String,
210 pub icon: Option<String>,
212 pub event_slug: Option<String>,
214 pub outcome: String,
216 pub outcome_index: u32,
218 pub name: Option<String>,
220 pub pseudonym: Option<String>,
222 pub bio: Option<String>,
224 pub profile_image: Option<String>,
226 pub profile_image_optimized: Option<String>,
228 pub transaction_hash: Option<String>,
230}
231
232#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
234#[serde(rename_all = "UPPERCASE")]
235pub enum ActivityType {
236 Trade,
238 Split,
240 Merge,
242 Redeem,
244 Reward,
246 Conversion,
248}
249
250impl std::fmt::Display for ActivityType {
251 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
252 match self {
253 Self::Trade => write!(f, "TRADE"),
254 Self::Split => write!(f, "SPLIT"),
255 Self::Merge => write!(f, "MERGE"),
256 Self::Redeem => write!(f, "REDEEM"),
257 Self::Reward => write!(f, "REWARD"),
258 Self::Conversion => write!(f, "CONVERSION"),
259 }
260 }
261}
262
263#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
265#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
266pub enum ActivitySortBy {
267 #[default]
269 Timestamp,
270 Tokens,
272 Cash,
274}
275
276impl std::fmt::Display for ActivitySortBy {
277 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
278 match self {
279 Self::Timestamp => write!(f, "TIMESTAMP"),
280 Self::Tokens => write!(f, "TOKENS"),
281 Self::Cash => write!(f, "CASH"),
282 }
283 }
284}
285
286#[derive(Debug, Clone, Serialize, Deserialize)]
288#[serde(rename_all(deserialize = "camelCase"))]
289pub struct Activity {
290 pub proxy_wallet: String,
292 pub timestamp: i64,
294 pub condition_id: String,
296 #[serde(rename = "type")]
298 pub activity_type: ActivityType,
299 pub size: f64,
301 pub usdc_size: f64,
303 pub transaction_hash: Option<String>,
305 pub price: Option<f64>,
307 pub asset: Option<String>,
309 pub side: Option<String>,
312 pub outcome_index: Option<u32>,
314 pub title: Option<String>,
316 pub slug: Option<String>,
318 pub icon: Option<String>,
320 pub outcome: Option<String>,
322 pub name: Option<String>,
324 pub pseudonym: Option<String>,
326 pub bio: Option<String>,
328 pub profile_image: Option<String>,
330 pub profile_image_optimized: Option<String>,
332}
333
334#[derive(Debug, Clone, Serialize, Deserialize)]
336#[serde(rename_all(deserialize = "camelCase"))]
337pub struct Position {
338 pub proxy_wallet: String,
340 pub asset: String,
342 pub condition_id: String,
344 pub size: f64,
346 pub avg_price: f64,
348 pub initial_value: f64,
350 pub current_value: f64,
352 pub cash_pnl: f64,
354 pub percent_pnl: f64,
356 pub total_bought: f64,
358 pub realized_pnl: f64,
360 pub percent_realized_pnl: f64,
362 pub cur_price: f64,
364 pub redeemable: bool,
366 pub mergeable: bool,
368 pub title: String,
370 pub slug: String,
372 pub icon: Option<String>,
374 pub event_slug: Option<String>,
376 pub outcome: String,
378 pub outcome_index: u32,
380 pub opposite_outcome: String,
382 pub opposite_asset: String,
384 pub end_date: Option<String>,
386 pub negative_risk: bool,
388}