1use serde::{Deserialize, Serialize};
2
3#[cfg_attr(feature = "specta", derive(specta::Type))]
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct UserValue {
7 pub user: String,
9 pub value: f64,
11}
12
13#[cfg_attr(feature = "specta", derive(specta::Type))]
15#[derive(Debug, Clone, Serialize, Deserialize)]
16pub struct OpenInterest {
17 pub market: String,
19 pub value: f64,
21}
22
23#[cfg_attr(feature = "specta", derive(specta::Type))]
25#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
26#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
27pub enum PositionSortBy {
28 Current,
30 Initial,
32 Tokens,
34 CashPnl,
36 PercentPnl,
38 Title,
40 Resolving,
42 Price,
44 AvgPrice,
46}
47
48impl std::fmt::Display for PositionSortBy {
49 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
50 match self {
51 Self::Current => write!(f, "CURRENT"),
52 Self::Initial => write!(f, "INITIAL"),
53 Self::Tokens => write!(f, "TOKENS"),
54 Self::CashPnl => write!(f, "CASHPNL"),
55 Self::PercentPnl => write!(f, "PERCENTPNL"),
56 Self::Title => write!(f, "TITLE"),
57 Self::Resolving => write!(f, "RESOLVING"),
58 Self::Price => write!(f, "PRICE"),
59 Self::AvgPrice => write!(f, "AVGPRICE"),
60 }
61 }
62}
63
64#[cfg_attr(feature = "specta", derive(specta::Type))]
66#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
67#[serde(rename_all = "UPPERCASE")]
68pub enum SortDirection {
69 Asc,
71 #[default]
73 Desc,
74}
75
76impl std::fmt::Display for SortDirection {
77 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
78 match self {
79 Self::Asc => write!(f, "ASC"),
80 Self::Desc => write!(f, "DESC"),
81 }
82 }
83}
84
85#[cfg_attr(feature = "specta", derive(specta::Type))]
87#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
88#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
89pub enum ClosedPositionSortBy {
90 #[default]
92 RealizedPnl,
93 Title,
95 Price,
97 AvgPrice,
99 Timestamp,
101}
102
103impl std::fmt::Display for ClosedPositionSortBy {
104 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
105 match self {
106 Self::RealizedPnl => write!(f, "REALIZEDPNL"),
107 Self::Title => write!(f, "TITLE"),
108 Self::Price => write!(f, "PRICE"),
109 Self::AvgPrice => write!(f, "AVGPRICE"),
110 Self::Timestamp => write!(f, "TIMESTAMP"),
111 }
112 }
113}
114
115#[cfg_attr(feature = "specta", derive(specta::Type))]
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(rename_all = "camelCase")]
119pub struct ClosedPosition {
120 pub proxy_wallet: String,
122 pub asset: String,
124 pub condition_id: String,
126 pub avg_price: f64,
128 pub total_bought: f64,
130 pub realized_pnl: f64,
132 pub cur_price: f64,
134 #[cfg_attr(feature = "specta", specta(type = f64))]
136 pub timestamp: i64,
137 pub title: String,
139 pub slug: String,
141 pub icon: Option<String>,
143 pub event_slug: Option<String>,
145 pub outcome: String,
147 pub outcome_index: u32,
149 pub opposite_outcome: String,
151 pub opposite_asset: String,
153 pub end_date: Option<String>,
155}
156
157#[cfg_attr(feature = "specta", derive(specta::Type))]
159#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
160#[serde(rename_all = "UPPERCASE")]
161pub enum TradeSide {
162 Buy,
164 Sell,
166}
167
168impl std::fmt::Display for TradeSide {
169 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
170 match self {
171 Self::Buy => write!(f, "BUY"),
172 Self::Sell => write!(f, "SELL"),
173 }
174 }
175}
176
177#[cfg_attr(feature = "specta", derive(specta::Type))]
179#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
180#[serde(rename_all = "UPPERCASE")]
181pub enum TradeFilterType {
182 Cash,
184 Tokens,
186}
187
188impl std::fmt::Display for TradeFilterType {
189 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
190 match self {
191 Self::Cash => write!(f, "CASH"),
192 Self::Tokens => write!(f, "TOKENS"),
193 }
194 }
195}
196
197#[cfg_attr(feature = "specta", derive(specta::Type))]
199#[derive(Debug, Clone, Serialize, Deserialize)]
200#[serde(rename_all = "camelCase")]
201pub struct Trade {
202 pub proxy_wallet: String,
204 pub side: TradeSide,
206 pub asset: String,
208 pub condition_id: String,
210 pub size: f64,
212 pub price: f64,
214 #[cfg_attr(feature = "specta", specta(type = f64))]
216 pub timestamp: i64,
217 pub title: String,
219 pub slug: String,
221 pub icon: Option<String>,
223 pub event_slug: Option<String>,
225 pub outcome: String,
227 pub outcome_index: u32,
229 pub name: Option<String>,
231 pub pseudonym: Option<String>,
233 pub bio: Option<String>,
235 pub profile_image: Option<String>,
237 pub profile_image_optimized: Option<String>,
239 pub transaction_hash: Option<String>,
241}
242
243#[cfg_attr(feature = "specta", derive(specta::Type))]
245#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
246#[serde(rename_all = "UPPERCASE")]
247pub enum ActivityType {
248 Trade,
250 Split,
252 Merge,
254 Redeem,
256 Reward,
258 Conversion,
260}
261
262impl std::fmt::Display for ActivityType {
263 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
264 match self {
265 Self::Trade => write!(f, "TRADE"),
266 Self::Split => write!(f, "SPLIT"),
267 Self::Merge => write!(f, "MERGE"),
268 Self::Redeem => write!(f, "REDEEM"),
269 Self::Reward => write!(f, "REWARD"),
270 Self::Conversion => write!(f, "CONVERSION"),
271 }
272 }
273}
274
275#[cfg_attr(feature = "specta", derive(specta::Type))]
277#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
278#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
279pub enum ActivitySortBy {
280 #[default]
282 Timestamp,
283 Tokens,
285 Cash,
287}
288
289impl std::fmt::Display for ActivitySortBy {
290 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
291 match self {
292 Self::Timestamp => write!(f, "TIMESTAMP"),
293 Self::Tokens => write!(f, "TOKENS"),
294 Self::Cash => write!(f, "CASH"),
295 }
296 }
297}
298
299#[cfg_attr(feature = "specta", derive(specta::Type))]
301#[derive(Debug, Clone, Serialize, Deserialize)]
302#[serde(rename_all = "camelCase")]
303pub struct Activity {
304 pub proxy_wallet: String,
306 #[cfg_attr(feature = "specta", specta(type = f64))]
308 pub timestamp: i64,
309 pub condition_id: String,
311 #[serde(rename = "type")]
313 pub activity_type: ActivityType,
314 pub size: f64,
316 pub usdc_size: f64,
318 pub transaction_hash: Option<String>,
320 pub price: Option<f64>,
322 pub asset: Option<String>,
324 pub side: Option<String>,
327 pub outcome_index: Option<u32>,
329 pub title: Option<String>,
331 pub slug: Option<String>,
333 pub icon: Option<String>,
335 pub outcome: Option<String>,
337 pub name: Option<String>,
339 pub pseudonym: Option<String>,
341 pub bio: Option<String>,
343 pub profile_image: Option<String>,
345 pub profile_image_optimized: Option<String>,
347}
348
349#[cfg_attr(feature = "specta", derive(specta::Type))]
351#[derive(Debug, Clone, Serialize, Deserialize)]
352#[serde(rename_all = "camelCase")]
353pub struct Position {
354 pub proxy_wallet: String,
356 pub asset: String,
358 pub condition_id: String,
360 pub size: f64,
362 pub avg_price: f64,
364 pub initial_value: f64,
366 pub current_value: f64,
368 pub cash_pnl: f64,
370 pub percent_pnl: f64,
372 pub total_bought: f64,
374 pub realized_pnl: f64,
376 pub percent_realized_pnl: f64,
378 pub cur_price: f64,
380 pub redeemable: bool,
382 pub mergeable: bool,
384 pub title: String,
386 pub slug: String,
388 pub icon: Option<String>,
390 pub event_slug: Option<String>,
392 pub outcome: String,
394 pub outcome_index: u32,
396 pub opposite_outcome: String,
398 pub opposite_asset: String,
400 pub end_date: Option<String>,
402 pub negative_risk: bool,
404}