dydx_v3_rust/
types.rs

1use serde::{Deserialize, Serialize};
2use serde_json::Value;
3use std::collections::HashMap;
4
5#[derive(Debug, Clone, Serialize, Deserialize)]
6pub struct ApiKeyCredentialsResponseObject {
7    pub key: String,
8    pub secret: String,
9    pub passphrase: String,
10}
11
12#[derive(Debug, Clone, Serialize, Deserialize)]
13#[serde(rename_all = "camelCase")]
14pub struct ApiKeyCredentialsResponse {
15    pub api_key: ApiKeyCredentialsResponseObject,
16}
17
18#[derive(Debug, Clone, Serialize, Deserialize)]
19#[serde(rename_all = "camelCase")]
20pub struct ApiKeysResponse {
21    pub api_keys: Vec<ApiKeyResponseObject>,
22}
23
24#[derive(Debug, Clone, Serialize, Deserialize)]
25pub struct ApiKeyResponseObject {
26    pub key: String,
27}
28
29#[derive(Debug, Clone, Serialize, Deserialize)]
30pub struct ApiKeyCredentials<'a> {
31    pub key: &'a str,
32    pub secret: &'a str,
33    pub passphrase: &'a str,
34}
35
36#[derive(Debug, Clone, Serialize, Deserialize)]
37#[serde(rename_all = "camelCase")]
38pub struct KeyPairWithYCoordinate<'a> {
39    pub public_key: &'a str,
40    pub public_key_y_coordinate: &'a str,
41    pub private_key: &'a str,
42}
43
44#[non_exhaustive]
45#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct OrderSide;
47
48impl OrderSide {
49    pub const BUY: &'static str = "BUY";
50    pub const SELL: &'static str = "SELL";
51}
52
53#[non_exhaustive]
54#[derive(Debug, Clone, Serialize, Deserialize)]
55pub struct OrderType;
56
57impl OrderType {
58    pub const MARKET: &'static str = "MARKET";
59    pub const LIMIT: &'static str = "LIMIT";
60    pub const STOP_LIMIT: &'static str = "STOP_LIMIT";
61    pub const TRAILING_STOP: &'static str = "TRAILING_STOP";
62    pub const TAKE_PROFIT: &'static str = "TAKE_PROFIT";
63}
64
65#[non_exhaustive]
66#[derive(Debug, Clone, Serialize, Deserialize)]
67pub struct TimeInForce;
68impl TimeInForce {
69    pub const GTT: &'static str = "GTT";
70    pub const FOK: &'static str = "FOK";
71    pub const IOC: &'static str = "IOC";
72}
73
74#[derive(Debug, Clone, Serialize, Deserialize)]
75#[serde(rename_all = "camelCase")]
76pub struct MarketStatsResponse {
77    pub markets: HashMap<String, MarketStats>,
78}
79
80#[derive(Debug, Clone, Serialize, Deserialize)]
81#[serde(rename_all = "camelCase")]
82pub struct MarketStats {
83    pub market: String,
84    pub open: String,
85    pub high: String,
86    pub low: String,
87    pub close: String,
88    pub base_volume: String,
89    pub quote_volume: String,
90    #[serde(rename = "type")]
91    pub type_field: String,
92}
93
94#[derive(Default, Debug, Serialize, Deserialize)]
95pub struct MarketStatisticDay;
96impl MarketStatisticDay {
97    pub const ONE: &'static str = "1";
98    pub const SEVEN: &'static str = "7";
99    pub const THIRTY: &'static str = "30";
100}
101
102#[derive(Debug, Clone, Serialize, Deserialize)]
103#[serde(rename_all = "camelCase")]
104pub struct HistoricalFundingResponse {
105    pub historical_funding: Vec<HistoricalFunding>,
106}
107
108#[derive(Debug, Clone, Serialize, Deserialize)]
109#[serde(rename_all = "camelCase")]
110pub struct HistoricalFunding {
111    pub market: String,
112    pub rate: String,
113    pub price: String,
114    pub effective_at: String,
115}
116
117#[derive(Debug, Clone, Serialize, Deserialize)]
118#[serde(rename_all = "camelCase")]
119pub struct ConfigResponse {
120    pub collateral_asset_id: String,
121    pub collateral_token_address: String,
122    pub default_maker_fee: String,
123    pub default_taker_fee: String,
124    pub exchange_address: String,
125    pub max_expected_batch_length_minutes: String,
126    pub max_fast_withdrawal_amount: String,
127    pub cancel_order_rate_limiting: CancelOrderRateLimiting,
128    pub place_order_rate_limiting: PlaceOrderRateLimiting,
129}
130
131#[derive(Debug, Clone, Serialize, Deserialize)]
132#[serde(rename_all = "camelCase")]
133pub struct CancelOrderRateLimiting {
134    pub max_points_multi: u32,
135    pub max_points_single: u32,
136    pub window_sec_multi: u32,
137    pub window_sec_single: u32,
138}
139
140#[derive(Debug, Clone, Serialize, Deserialize)]
141#[serde(rename_all = "camelCase")]
142pub struct PlaceOrderRateLimiting {
143    pub max_points: u32,
144    pub window_sec: u32,
145    pub target_notional: u32,
146    pub min_limit_consumption: u32,
147    pub min_market_consumption: u32,
148    pub min_triggerable_consumption: u32,
149    pub max_order_consumption: u32,
150}
151
152#[derive(Debug, Clone, Serialize, Deserialize)]
153#[serde(rename_all = "camelCase")]
154pub struct LeaderboardPnlResponse {
155    pub top_pnls: Vec<PNLForPeriod>,
156    pub num_participants: u32,
157    pub started_at: Option<String>,
158    pub ends_at: Option<String>,
159    pub updated_at: String,
160    pub season_number: Option<u16>,
161    pub prize_pool: Option<u32>,
162    pub num_hedgies_winners: Option<u16>,
163    pub num_prize_winners: Option<u16>,
164    pub ratio_promoted: Option<f32>,
165    pub ratio_demoted: Option<f32>,
166    pub minimum_equity: Option<u16>,
167    pub minimum_dydx_tokens: Option<u16>,
168}
169
170#[derive(Debug, Clone, Serialize, Deserialize)]
171#[serde(rename_all = "camelCase")]
172pub struct PNLForPeriod {
173    pub username: Option<String>,
174    pub ethereum_address: Option<String>,
175    pub public_id: String,
176    pub absolute_pnl: String,
177    pub percent_pnl: String,
178    pub absolute_rank: u32,
179    pub percent_rank: u32,
180    pub season_expected_outcome: Option<String>,
181    pub hedgie_won: Option<u16>,
182    pub prize_won: Option<String>,
183}
184
185#[derive(Debug, Clone, Serialize, Deserialize)]
186#[serde(rename_all = "camelCase")]
187pub struct UserExistsResponse {
188    pub exists: bool,
189    pub is_proxy_signer: bool,
190    pub contract_address: String,
191}
192
193#[derive(Debug, Clone, Serialize, Deserialize)]
194#[serde(rename_all = "camelCase")]
195pub struct UsernameExistsResponse {
196    pub exists: bool,
197}
198
199#[derive(Debug, Clone, Serialize, Deserialize)]
200#[serde(rename_all = "camelCase")]
201pub struct GetTimeResponse {
202    pub iso: String,
203    pub epoch: f64,
204}
205
206#[derive(Debug, Clone, Serialize, Deserialize)]
207#[serde(rename_all = "camelCase")]
208pub struct CurrentlyRevealedHedgies {
209    pub daily: HedgiePeriodResponseObject,
210    pub weekly: HedgiePeriodResponseObject,
211}
212
213#[derive(Debug, Clone, Serialize, Deserialize)]
214#[serde(rename_all = "camelCase")]
215pub struct HedgiePeriodResponse {
216    pub historical_token_ids: Vec<HedgiePeriodResponseObject>,
217}
218
219#[derive(Debug, Clone, Serialize, Deserialize)]
220#[serde(rename_all = "camelCase")]
221pub struct HedgiePeriodResponseObject {
222    pub block_number: String,
223    pub token_ids: Vec<String>,
224    pub competition_period: u16,
225}
226
227#[derive(Default, Debug, Serialize, Deserialize)]
228#[non_exhaustive]
229pub struct NftRevealType;
230impl NftRevealType {
231    pub const DAY: &'static str = "daily";
232    pub const WEEK: &'static str = "weekly";
233}
234
235#[derive(Debug, Clone, Serialize, Deserialize)]
236#[serde(rename_all = "camelCase")]
237pub struct InsuranceFundBalanceResponse {
238    pub balance: String,
239}
240
241#[derive(Debug, Clone, Serialize, Deserialize)]
242#[serde(rename_all = "camelCase")]
243pub struct ProfilePublicResponse {
244    pub username: Option<String>,
245    pub ethereum_address: String,
246    #[serde(rename = "DYDXHoldings")]
247    pub dydx_holdings: String,
248    #[serde(rename = "stakedDYDXHoldings")]
249    pub staked_dydx_holdings: String,
250    pub hedgies_held: Vec<u16>,
251    pub twitter_handle: String,
252    pub trading_leagues: TradingLeagues,
253    pub trading_pnls: TradingPnls,
254}
255
256#[derive(Debug, Clone, Serialize, Deserialize)]
257#[serde(rename_all = "camelCase")]
258pub struct ProfilePrivateResponse {
259    pub username: Option<String>,
260    pub public_id: String,
261    pub ethereum_address: String,
262    #[serde(rename = "DYDXHoldings")]
263    pub dydx_holdings: String,
264    #[serde(rename = "stakedDYDXHoldings")]
265    pub staked_dydx_holdings: String,
266    pub hedgies_held: Vec<u16>,
267    pub twitter_handle: String,
268    pub affiliate_link: Option<String>,
269    pub trading_leagues: TradingLeagues,
270    pub trading_pnls: TradingPnls,
271    pub trading_rewards: TradingRewards,
272}
273
274#[derive(Debug, Clone, Serialize, Deserialize)]
275#[serde(rename_all = "camelCase")]
276pub struct TradingLeagues {
277    pub current_league: Option<String>,
278    pub current_league_ranking: Option<u32>,
279}
280
281#[derive(Debug, Clone, Serialize, Deserialize)]
282#[serde(rename_all = "camelCase")]
283pub struct TradingPnls {
284    pub absolute_pnl30_d: Option<String>,
285    pub percent_pnl30_d: Option<String>,
286    pub volume30_d: String,
287}
288
289#[derive(Debug, Clone, Serialize, Deserialize)]
290#[serde(rename_all = "camelCase")]
291pub struct TradingRewards {
292    pub cur_epoch: u16,
293    pub cur_epoch_estimated_rewards: String,
294    pub prev_epoch_estimated_rewards: String,
295}
296
297#[derive(Debug, Clone, Serialize, Deserialize)]
298#[serde(rename_all = "camelCase")]
299pub struct MarketsResponse {
300    pub markets: HashMap<String, MarketData>,
301}
302
303#[derive(Default, Debug, Serialize, Deserialize)]
304pub struct CandleResolution;
305impl CandleResolution {
306    pub const ONE_DAY: &'static str = "1DAY";
307    pub const FOUR_HOURS: &'static str = "4HOURS";
308    pub const ONE_HOUR: &'static str = "1HOUR";
309    pub const THIRTY_MINS: &'static str = "30MINS";
310    pub const FIFTEEN_MINS: &'static str = "15MINS";
311    pub const FIVE_MINS: &'static str = "5MINS";
312    pub const ONE_MIN: &'static str = "1MIN";
313}
314
315#[derive(Default, Debug, Serialize, Deserialize)]
316#[non_exhaustive]
317pub struct DydxMarket;
318
319impl DydxMarket {
320    pub const BTC_USD: &'static str = "BTC-USD";
321    pub const SUSHI_USD: &'static str = "SUSHI-USD";
322    pub const AVAX_USD: &'static str = "AVAX-USD";
323    pub const INCH_USD: &'static str = "1INCH-USD";
324    pub const ETH_USD: &'static str = "ETH-USD";
325    pub const XMR_USD: &'static str = "XMR-USD";
326    pub const COMP_USD: &'static str = "COMP-USD";
327    pub const ALGO_USD: &'static str = "ALGO-USD";
328    pub const BCH_USD: &'static str = "BCH-USD";
329    pub const CRV_USD: &'static str = "CRV-USD";
330    pub const ETC_USD: &'static str = "ETC-USD";
331    pub const UNI_USD: &'static str = "UNI-USD";
332    pub const MKR_USD: &'static str = "MKR-USD";
333    pub const LTC_USD: &'static str = "LTC-USD";
334    pub const EOS_USD: &'static str = "EOS-USD";
335    pub const DOGE_USD: &'static str = "DOGE-USD";
336    pub const ATOM_USD: &'static str = "ATOM-USD";
337    pub const ZRX_USD: &'static str = "ZRX-USD";
338    pub const SOL_USD: &'static str = "SOL-USD";
339    pub const UMA_USD: &'static str = "UMA-USD";
340    pub const AAVE_USD: &'static str = "AAVE-USD";
341    pub const ADA_USD: &'static str = "ADA-USD";
342    pub const SNX_USD: &'static str = "SNX-USD";
343    pub const FIL_USD: &'static str = "FIL-USD";
344    pub const ZEC_USD: &'static str = "ZEC-USD";
345    pub const YFI_USD: &'static str = "YFI-USD";
346    pub const XLM_USD: &'static str = "XLM-USD";
347    pub const LINK_USD: &'static str = "LINK-USD";
348    pub const DOT_USD: &'static str = "DOT-USD";
349    pub const MATIC_USD: &'static str = "MATIC-USD";
350    pub const ENJ_USD: &'static str = "ENJ-USD";
351    pub const NEAR_USD: &'static str = "NEAR-USD";
352    pub const LUNA_USD: &'static str = "LUNA-USD";
353    pub const CELO_USD: &'static str = "CELO-USD";
354    pub const XTZ_USD: &'static str = "XTZ-USD";
355    pub const RUNE_USD: &'static str = "RUNE-USD";
356    pub const TRX_USD: &'static str = "TRX-USD";
357    pub const ICP_USD: &'static str = "ICP-USD";
358}
359
360#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
361#[serde(rename_all = "camelCase")]
362pub struct MarketData {
363    pub market: String,
364    pub status: String,
365    pub base_asset: String,
366    pub quote_asset: String,
367    pub step_size: String,
368    pub tick_size: String,
369    pub index_price: String,
370    pub oracle_price: String,
371    #[serde(rename = "priceChange24H")]
372    pub price_change24h: String,
373    pub next_funding_rate: String,
374    pub next_funding_at: String,
375    pub min_order_size: String,
376    #[serde(rename = "type")]
377    pub type_field: String,
378    pub initial_margin_fraction: String,
379    pub maintenance_margin_fraction: String,
380    #[serde(rename = "volume24H")]
381    pub volume24h: String,
382    #[serde(rename = "trades24H")]
383    pub trades24h: String,
384    pub open_interest: String,
385    pub incremental_initial_margin_fraction: String,
386    pub incremental_position_size: String,
387    pub max_position_size: String,
388    pub baseline_position_size: String,
389    pub asset_resolution: String,
390    pub synthetic_asset_id: String,
391}
392
393#[derive(Debug, Clone, Serialize, Deserialize)]
394#[serde(rename_all = "camelCase")]
395pub struct OrderbookResponse {
396    pub asks: Vec<OrderbookResponseOrder>,
397    pub bids: Vec<OrderbookResponseOrder>,
398}
399
400#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
401#[serde(rename_all = "camelCase")]
402pub struct OrderbookResponseOrder {
403    pub size: String,
404    pub price: String,
405}
406
407#[derive(Debug, Clone, Serialize, Deserialize)]
408#[serde(rename_all = "camelCase")]
409pub struct Trade {
410    pub side: String,
411    pub size: String,
412    pub price: String,
413    pub created_at: String,
414}
415
416#[derive(Debug, Clone, Serialize, Deserialize)]
417pub struct TradesResponse {
418    pub trades: Vec<Trade>,
419}
420
421#[derive(Debug, Clone, Serialize, Deserialize)]
422#[serde(rename_all = "camelCase")]
423pub struct Candle {
424    pub started_at: String,
425    pub updated_at: String,
426    pub market: String,
427    // pub resolution: CandleResolution;
428    pub resolution: String,
429    pub low: String,
430    pub high: String,
431    pub open: String,
432    pub close: String,
433    pub base_token_volume: String,
434    pub trades: String,
435    pub usd_volume: String,
436    pub starting_open_interest: String,
437}
438
439#[derive(Debug, Clone, Serialize, Deserialize)]
440pub struct CandlesResponse {
441    pub candles: Vec<Candle>,
442}
443
444#[derive(Debug, Clone, Serialize, Deserialize)]
445pub struct AccountResponse {
446    pub account: AccountObject,
447}
448
449#[derive(Debug, Clone, Serialize, Deserialize)]
450pub struct AccountsResponse {
451    pub accounts: Vec<AccountObject>,
452}
453
454#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
455#[serde(rename_all = "camelCase")]
456pub struct AccountObject {
457    pub stark_key: String,
458    pub position_id: String,
459    pub equity: String,
460    pub free_collateral: String,
461    pub pending_deposits: String,
462    pub pending_withdrawals: String,
463    pub open_positions: HashMap<String, PositionResponseObject>,
464    pub account_number: String,
465    pub id: String,
466    pub quote_balance: String,
467}
468
469#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
470#[serde(rename_all = "camelCase")]
471pub struct RecoveryResponse {
472    pub stark_key: String,
473    pub position_id: String,
474    pub quote_balance: String,
475    pub positions: Vec<PositionResponseObject>,
476    pub equity: String,
477    pub free_collateral: String,
478}
479
480#[derive(Default, Debug, Clone, PartialEq, Serialize, Deserialize)]
481pub struct PositionsResponse {
482    pub positions: Vec<PositionResponseObject>,
483}
484
485#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
486#[serde(rename_all = "camelCase")]
487pub struct PositionResponseObject {
488    // pub market: Market;
489    pub market: String,
490    // pub status: PositionStatus,
491    pub status: String,
492    pub side: String,
493    pub size: String,
494    pub max_size: String,
495    pub entry_price: String,
496    pub exit_price: Option<String>,
497    pub unrealized_pnl: String,
498    pub realized_pnl: Option<String>,
499    pub created_at: String,
500    pub closed_at: Option<String>,
501    pub sum_open: Option<String>,
502    pub sum_close: Option<String>,
503    pub net_funding: Option<String>,
504}
505
506#[derive(Debug, Clone, Serialize)]
507#[serde(rename_all = "camelCase")]
508pub struct ApiOrder<'a> {
509    pub market: &'a str,
510    pub side: &'a str,
511    #[serde(rename = "type")]
512    pub type_field: &'a str,
513    pub time_in_force: &'a str,
514    pub post_only: bool,
515    pub size: &'a str,
516    pub price: &'a str,
517    pub limit_fee: &'a str,
518    #[serde(skip_serializing_if = "Option::is_none")]
519    pub cancel_id: Option<&'a str>,
520    #[serde(skip_serializing_if = "Option::is_none")]
521    pub trigger_price: Option<&'a str>,
522    #[serde(skip_serializing_if = "Option::is_none")]
523    pub trailing_percent: Option<&'a str>,
524    pub expiration: &'a str,
525    pub client_id: &'a str,
526    pub signature: &'a str,
527}
528
529#[derive(Debug, Clone, Serialize)]
530pub struct ApiOrderParams<'a> {
531    pub position_id: &'a str,
532    pub market: &'a str,
533    pub side: &'a str,
534    #[serde(rename = "type")]
535    pub type_field: &'a str,
536    pub size: &'a str,
537    pub price: &'a str,
538    pub time_in_force: &'a str,
539    pub post_only: bool,
540    pub limit_fee: &'a str,
541    #[serde(skip_serializing_if = "Option::is_none")]
542    pub client_id: Option<&'a str>,
543    #[serde(skip_serializing_if = "Option::is_none")]
544    pub cancel_id: Option<&'a str>,
545    #[serde(skip_serializing_if = "Option::is_none")]
546    pub trigger_price: Option<&'a str>,
547    #[serde(skip_serializing_if = "Option::is_none")]
548    pub trailing_percent: Option<&'a str>,
549    pub expiration: i64,
550}
551
552#[derive(Debug, Clone, Serialize, Deserialize)]
553#[serde(rename_all = "camelCase")]
554pub struct OrderResponse {
555    pub order: OrderResponseObject,
556}
557
558#[derive(Debug, Clone, Serialize, Deserialize)]
559#[serde(rename_all = "camelCase")]
560pub struct OrdersResponse {
561    pub orders: Vec<OrderResponseObject>,
562}
563
564#[derive(Debug, Clone, Serialize, Deserialize)]
565#[serde(rename_all = "camelCase")]
566pub struct ActiveOrdersResponse {
567    pub orders: Vec<ActiveOrderResponseObject>,
568}
569#[derive(Debug, Clone, Serialize, Deserialize)]
570#[serde(rename_all = "camelCase")]
571pub struct ActiveOrderResponseObject {
572    pub id: String,
573    pub account_id: String,
574    pub market: String,
575    pub side: String,
576    pub price: String,
577    pub remaining_size: String,
578}
579
580#[derive(Debug, Clone, Serialize, Deserialize)]
581#[serde(rename_all = "camelCase")]
582pub struct FillsResponse {
583    pub fills: Vec<FillResponseObject>,
584}
585
586#[derive(Debug, Clone, Deserialize)]
587#[serde(rename_all = "camelCase")]
588pub struct FundingResponse {
589    pub funding_payments: Vec<FundingResponseObject>,
590}
591
592#[derive(Debug, Clone, Serialize, Deserialize)]
593#[serde(rename_all = "camelCase")]
594pub struct HistoricalPnlResponse {
595    pub historical_pnl: Vec<HistoricalPnlResponseObject>,
596}
597
598#[derive(Debug, Clone, Serialize, Deserialize)]
599#[serde(rename_all = "camelCase")]
600pub struct HistoricalPnlResponseObject {
601    pub equity: String,
602    pub total_pnl: String,
603    pub created_at: String,
604    pub net_transfers: String,
605    pub account_id: String,
606}
607
608#[derive(Debug, Clone, Serialize, Deserialize)]
609#[serde(rename_all = "camelCase")]
610pub struct FundingResponseObject {
611    pub market: String,
612    pub payment: String,
613    pub rate: String,
614    pub position_size: String,
615    pub price: String,
616    pub effective_at: String,
617}
618
619#[derive(Debug, Clone, Serialize, Deserialize)]
620#[serde(rename_all = "camelCase")]
621pub struct TradingRewardsResponse {
622    pub epoch: u16,
623    pub epoch_start: String,
624    pub epoch_end: String,
625    pub fees: Fees,
626    pub open_interest: OpenInterest,
627    pub weight: Weight,
628    #[serde(rename = "stakedDYDX")]
629    pub staked_dydx: StakedDYDX,
630    pub total_rewards: String,
631    pub estimated_rewards: String,
632}
633
634#[derive(Debug, Clone, Serialize, Deserialize)]
635#[serde(rename_all = "camelCase")]
636pub struct Weight {
637    pub weight: String,
638    pub total_weight: String,
639}
640
641#[derive(Debug, Clone, Serialize, Deserialize)]
642#[serde(rename_all = "camelCase")]
643pub struct Fees {
644    pub fees_paid: String,
645    pub total_fees_paid: String,
646}
647
648#[derive(Debug, Clone, Serialize, Deserialize)]
649#[serde(rename_all = "camelCase")]
650pub struct OpenInterest {
651    pub average_open_interest: String,
652    pub total_average_open_interest: String,
653}
654
655#[derive(Debug, Clone, Serialize, Deserialize)]
656#[serde(rename_all = "camelCase")]
657pub struct LiquidityProviderRewardsResponse {
658    pub epoch: u16,
659    pub epoch_start: String,
660    pub epoch_end: String,
661    pub markets: HashMap<String, LiquidityRewards>,
662    #[serde(rename = "stakedDYDX")]
663    pub staked_dydx: LiqStakedDYDX,
664}
665
666#[derive(Debug, Clone, Serialize, Deserialize)]
667#[serde(rename_all = "camelCase")]
668pub struct LiquidityRewards {
669    pub market: String,
670    pub depth_spread_score: String,
671    pub uptime: String,
672    pub max_uptime: String,
673    pub score: String,
674    pub total_score: String,
675    pub maker_volume: String,
676    pub total_maker_volume: String,
677    pub total_rewards: String,
678    pub estimated_rewards: String,
679}
680
681#[derive(Debug, Clone, Serialize, Deserialize)]
682#[serde(rename_all = "camelCase")]
683pub struct LiqStakedDYDX {
684    #[serde(rename = "averageStakedDYDX")]
685    pub average_staked_dydx: String,
686    #[serde(rename = "totalAverageStakedDYDX")]
687    pub total_average_staked_dydx: String,
688}
689
690#[derive(Debug, Clone, Serialize, Deserialize)]
691#[serde(rename_all = "camelCase")]
692pub struct StakedDYDX {
693    #[serde(rename = "averageStakedDYDX")]
694    pub average_staked_dydx: String,
695    #[serde(rename = "averageStakedDYDXWithFloor")]
696    pub average_staked_dydxwith_floor: String,
697    #[serde(rename = "totalAverageStakedDYDX")]
698    pub total_average_staked_dydx: String,
699}
700
701#[derive(Debug, Clone, Serialize, Deserialize)]
702#[serde(rename_all = "camelCase")]
703pub struct RetroactiveMiningRewardsResponse {
704    pub epoch: u16,
705    pub epoch_start: String,
706    pub epoch_end: String,
707    pub retroactive_mining: RetroactiveMiningRewardsResponseObject,
708    pub estimated_rewards: String,
709}
710
711#[derive(Debug, Clone, Serialize, Deserialize)]
712#[serde(rename_all = "camelCase")]
713pub struct RetroactiveMiningRewardsResponseObject {
714    pub allocation: String,
715    pub target_volume: String,
716    pub volume: String,
717}
718
719#[derive(Debug, Clone, Serialize, Deserialize)]
720#[serde(rename_all = "camelCase")]
721pub struct PublicRetroactiveMiningRewardsResponse {
722    pub allocation: String,
723    pub target_volume: String,
724}
725
726#[derive(Debug, Clone, Serialize, Deserialize)]
727#[serde(rename_all = "camelCase")]
728pub struct FillResponseObject {
729    pub id: String,
730    pub side: String,
731    pub liquidity: String,
732    #[serde(rename = "type")]
733    pub type_field: String,
734    pub market: String,
735    pub order_id: String,
736    pub price: String,
737    pub size: String,
738    pub fee: String,
739    pub created_at: String,
740}
741
742#[derive(Debug, Clone, Serialize, Deserialize)]
743pub struct RegistrationResponse {
744    pub signature: String,
745}
746
747#[derive(Debug, Clone, Serialize, Deserialize)]
748#[serde(rename_all = "camelCase")]
749pub struct AccountPnlsResponse {
750    pub absolute_pnl: String,
751    pub percent_pnl: String,
752    pub absolute_rank: Option<u16>,
753    pub percent_rank: Option<u16>,
754    pub started_at: Option<String>,
755    pub ends_at: Option<String>,
756    pub updated_at: String,
757    pub period: String,
758    pub season_expected_outcome: Option<String>,
759    pub season_number: Option<String>,
760    pub hedgie_won: Option<String>,
761    pub prize_won: Option<String>,
762}
763
764#[derive(Debug, Serialize, Deserialize)]
765#[serde(rename_all = "camelCase")]
766pub struct HistoricalLeaderboardPnlsResponse {
767    pub leaderboard_pnls: Vec<AccountPnlsResponse>,
768}
769
770#[derive(Debug, Serialize, Deserialize)]
771#[serde(rename_all = "camelCase")]
772pub struct HistoricalLeaderboardPnlsResponseObject {}
773
774#[derive(Debug, Clone, Serialize, Deserialize)]
775#[serde(rename_all = "camelCase")]
776pub struct OrderResponseObject {
777    pub id: String,
778    pub client_id: String,
779    pub account_id: String,
780    pub market: String,
781    pub side: String,
782    pub price: String,
783    pub trigger_price: Option<String>,
784    pub trailing_percent: Option<String>,
785    pub size: String,
786    pub remaining_size: String,
787    #[serde(rename = "type")]
788    pub type_field: String,
789    pub created_at: String,
790    pub unfillable_at: Option<String>,
791    pub expires_at: Option<String>,
792    pub status: String,
793    pub time_in_force: String,
794    pub post_only: bool,
795    pub cancel_reason: Option<String>,
796}
797
798#[derive(Debug, Serialize, Deserialize)]
799#[serde(rename_all = "camelCase")]
800pub struct CancelOrderResponse {
801    pub cancel_order: OrderResponseObject,
802}
803
804#[derive(Debug, Serialize, Deserialize)]
805#[serde(rename_all = "camelCase")]
806pub struct CancelOrdersResponse {
807    pub cancel_orders: Vec<OrderResponseObject>,
808}
809
810#[derive(Debug, Clone, Serialize, Deserialize)]
811#[serde(rename_all = "camelCase")]
812pub struct UserResponseObject {
813    pub public_id: String,
814    pub ethereum_address: String,
815    pub is_registered: bool,
816    pub email: Option<String>,
817    pub username: Option<String>,
818    pub user_data: Value,
819    pub maker_fee_rate: Option<String>,
820    pub taker_fee_rate: Option<String>,
821    pub maker_volume30_d: Option<String>,
822    pub taker_volume30_d: Option<String>,
823    pub fees30_d: Option<String>,
824    pub referred_by_affiliate_link: Option<String>,
825    pub is_sharing_username: Option<bool>,
826    pub is_sharing_address: Option<bool>,
827    pub dydx_token_balance: String,
828    pub staked_dydx_token_balance: String,
829    pub active_staked_dydx_token_balance: String,
830    pub is_email_verified: bool,
831    pub country: Option<String>,
832    pub hedgies_held: Vec<usize>,
833}
834
835#[derive(Debug, Clone, Serialize, Deserialize)]
836pub struct UserResponse {
837    pub user: UserResponseObject,
838}
839
840#[derive(Debug, Clone, Serialize)]
841#[serde(rename_all = "camelCase")]
842pub struct UserParams<'a> {
843    #[serde(skip_serializing_if = "Option::is_none")]
844    pub email: Option<&'a str>,
845    #[serde(skip_serializing_if = "Option::is_none")]
846    pub country: Option<&'a str>,
847    #[serde(skip_serializing_if = "Option::is_none")]
848    pub is_sharing_address: Option<bool>,
849    #[serde(skip_serializing_if = "Option::is_none")]
850    pub is_sharing_username: Option<bool>,
851    pub user_data: &'a str,
852    #[serde(skip_serializing_if = "Option::is_none")]
853    pub username: Option<&'a str>,
854}
855
856#[derive(Debug, Clone, Serialize)]
857#[serde(rename_all = "camelCase")]
858pub struct CreateUserParams<'a> {
859    pub stark_key: &'a str,
860    pub stark_key_y_coordinate: &'a str,
861    #[serde(skip_serializing_if = "Option::is_none")]
862    pub referred_by_affiliate_link: Option<&'a str>,
863    #[serde(skip_serializing_if = "Option::is_none")]
864    pub country: Option<&'a str>,
865}
866
867#[derive(Debug, Clone, Serialize, Deserialize)]
868#[serde(rename_all = "camelCase")]
869pub struct TransferResponseObject {
870    pub id: String,
871    #[serde(rename = "type")]
872    pub type_field: String,
873    pub debit_asset: String,
874    pub credit_asset: String,
875    pub debit_amount: String,
876    pub credit_amount: String,
877    pub transaction_hash: Option<String>,
878    pub status: String,
879    pub created_at: String,
880    pub confirmed_at: Option<String>,
881    pub client_id: String,
882    pub from_address: Option<String>,
883    pub to_address: Option<String>,
884}
885
886#[derive(Debug, Clone, Serialize, Deserialize)]
887pub struct TransferResponse {
888    pub transfer: TransferResponseObject,
889}
890
891#[derive(Debug, Clone, Serialize, Deserialize)]
892pub struct TransfersResponse {
893    pub transfers: Vec<TransferResponseObject>,
894}
895
896#[derive(Debug, Clone, Serialize, Deserialize)]
897pub struct WithdrawalResponse {
898    pub withdrawal: TransferResponseObject,
899}
900
901#[derive(Debug, Clone, Serialize)]
902#[serde(rename_all = "camelCase")]
903pub struct CreateAccountParams<'a> {
904    pub stark_key: &'a str,
905    pub stark_key_y_coordinate: &'a str,
906}
907
908#[derive(Debug, Clone, Serialize)]
909#[serde(rename_all = "camelCase")]
910pub struct TransferParams<'a> {
911    pub amount: &'a str,
912    pub position_id: &'a str,
913    pub receiver_account_id: &'a str,
914    pub receiver_public_key: &'a str,
915    pub receiver_position_id: &'a str,
916    pub expiration: i64,
917}
918
919#[derive(Debug, Clone, Serialize)]
920#[serde(rename_all = "camelCase")]
921pub struct ApiTransfer<'a> {
922    pub amount: &'a str,
923    pub receiver_account_id: &'a str,
924    pub expiration: &'a str,
925    pub client_id: &'a str,
926    pub signature: &'a str,
927}
928
929#[derive(Debug, Clone, Serialize)]
930#[serde(rename_all = "camelCase")]
931pub struct ApiWithdrawParams<'a> {
932    pub position_id: &'a str,
933    pub amount: &'a str,
934    pub asset: &'a str,
935    pub expiration: i64,
936}
937
938#[derive(Debug, Clone, Serialize)]
939#[serde(rename_all = "camelCase")]
940pub struct ApiWithdraw<'a> {
941    pub amount: &'a str,
942    pub asset: &'a str,
943    pub expiration: &'a str,
944    pub client_id: &'a str,
945    pub signature: &'a str,
946}
947
948#[derive(Debug, Clone, Serialize)]
949#[serde(rename_all = "camelCase")]
950pub struct ApiFastWithdrawalParams<'a> {
951    pub position_id: &'a str,
952    pub credit_asset: &'a str,
953    pub credit_amount: &'a str,
954    pub debit_amount: &'a str,
955    pub to_address: &'a str,
956    pub lp_position_id: &'a str,
957    pub lp_stark_key: &'a str,
958    pub expiration: i64,
959}
960
961#[derive(Debug, Clone, Serialize)]
962#[serde(rename_all = "camelCase")]
963pub struct ApiFastWithdrawal<'a> {
964    pub credit_asset: &'a str,
965    pub credit_amount: &'a str,
966    pub debit_amount: &'a str,
967    pub to_address: &'a str,
968    pub lp_position_id: &'a str,
969    pub expiration: &'a str,
970    pub client_id: &'a str,
971    pub signature: &'a str,
972}
973
974#[derive(Debug, Clone, Serialize, Deserialize)]
975#[serde(rename_all = "camelCase")]
976pub struct CreateUserResponse {
977    pub api_key: ApiKeyCredentialsResponseObject,
978    pub user: UserResponseObject,
979    pub account: AccountObject,
980}