dydx 0.3.0

dYdX v4 asynchronous client.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
use bigdecimal::BigDecimal;
use chrono::{DateTime, Utc};
use derive_more::{Display, From};
use serde::{Deserialize, Serialize};
use std::collections::HashMap;

use crate::indexer::types::*;

/// REST Indexer response error.
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct ResponseError {
    /// Errors.
    pub errors: Vec<ErrorMsg>,
}

/// REST Indexer error message.
#[derive(Deserialize)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct ErrorMsg {
    /// Message.
    pub msg: String,
    /// Parameter.
    pub param: String,
    /// Location.
    pub location: String,
}

/// Profit and loss tick id.
#[derive(Deserialize, Debug, Clone, From, Display, PartialEq, Eq, PartialOrd, Ord, Hash)]
pub struct PnlTickId(pub String);

/// PnL tick resolution.
#[derive(
    Deserialize, Serialize, Debug, Clone, Copy, From, Display, PartialEq, Eq, PartialOrd, Ord, Hash,
)]
#[serde(rename_all = "lowercase")]
pub enum PnlTickInterval {
    /// Hour.
    Hour,
    /// Day.
    Day,
}

/// Transfer id.
#[derive(
    Serialize, Deserialize, Debug, Clone, From, Display, PartialEq, Eq, PartialOrd, Ord, Hash,
)]
pub struct TransferId(pub String);

/// Period to aggregate rewards over.
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum TradingRewardAggregationPeriod {
    /// Day.
    Daily,
    /// Week.
    Weekly,
    /// Month.
    Monthly,
}

/// Sparkline time period.
#[derive(Serialize, Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Hash)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum SparklineTimePeriod {
    /// 1 day.
    OneDay,
    /// 7 days.
    SevenDays,
}

/// Fundings response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct HistoricalFundingResponse {
    /// List of fundings
    pub historical_funding: Vec<HistoricalFundingResponseObject>,
}

/// Funding response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct HistoricalFundingResponseObject {
    /// Market ticker.
    pub ticker: Ticker,
    /// Time.
    pub effective_at: DateTime<Utc>,
    /// Block height.
    pub effective_at_height: Height,
    /// Price.
    pub price: Price,
    /// Funding rate.
    pub rate: BigDecimal,
}

/// Sparkline response.
pub type SparklineResponseObject = HashMap<Ticker, Vec<BigDecimal>>;

/// Indexer server time.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct TimeResponse {
    /// Time (UTC).
    pub iso: DateTime<Utc>,
    /// Unix epoch.
    pub epoch: f64,
}

/// Compliance response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct ComplianceResponse {
    /// Whether the address is restricted.
    pub restricted: bool,
    /// Reason.
    pub reason: Option<String>,
}

/// Compliance status.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ComplianceStatus {
    /// Compliant.
    Compliant,
    /// First strike close only.
    FirstStrikeCloseOnly,
    /// First strike.
    FirstStrike,
    /// Close only.
    CloseOnly,
    /// Blocked.
    Blocked,
}

/// Compliance reason.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum ComplianceReason {
    /// Manual.
    Manual,
    /// US geo.
    UsGeo,
    /// CA geo.
    CaGeo,
    /// GB geo.
    GbGeo,
    /// Sanctioned geo.
    SanctionedGeo,
    /// Compliance provider.
    ComplianceProvider,
}

/// Compliance response v2.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct ComplianceV2Response {
    /// Status.
    pub status: ComplianceStatus,
    /// Reason.
    pub reason: Option<ComplianceReason>,
    /// Updated at.
    pub updated_at: Option<DateTime<Utc>>,
}

/// Address response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct AddressResponse {
    /// List of all subaccounts.
    pub subaccounts: Vec<SubaccountResponseObject>,
    /// Total rewards.
    pub total_trading_rewards: BigDecimal,
}

/// Subaccount response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct SubaccountResponse {
    /// Subaccount.
    pub subaccount: SubaccountResponseObject,
}

/// Parent subaccount response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct ParentSubaccountResponse {
    /// Subaccount.
    pub subaccount: ParentSubaccountResponseObject,
}

/// Asset positions response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct AssetPositionResponse {
    /// Asset positions.
    pub positions: Vec<AssetPositionResponseObject>,
}

/// Perpetual positions response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct PerpetualPositionResponse {
    /// Perpetual positions.
    pub positions: Vec<PerpetualPositionResponseObject>,
}

/// Pagination request.
#[derive(Serialize, Default, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct PaginationRequest {
    /// Limit.
    pub limit: Option<u32>,
    /// Offset.
    pub offset: Option<u32>,
}

/// Affiliate metadata response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct AffiliateMetadataResponse {
    /// Referral code.
    pub referral_code: String,
    /// Is volume eligible.
    pub is_volume_eligible: bool,
    /// Is affiliate.
    pub is_affiliate: bool,
}

/// Affiliate address response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct AffiliateAddressResponse {
    /// Address.
    pub address: Address,
}

/// Affiliate snapshot response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct AffiliateSnapshotResponse {
    /// Affiliate list.
    pub affiliate_list: Vec<AffiliateSnapshotResponseObject>,
    /// Total.
    pub total: u32,
    /// Current offset.
    pub current_offset: u32,
}

/// Affiliate snapshot response object.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct AffiliateSnapshotResponseObject {
    /// Affiliate address.
    pub affiliate_address: Address,
    /// Affiliate referral code.
    pub affiliate_referral_code: String,
    /// Affiliate earnings.
    pub affiliate_earnings: BigDecimal,
    /// Affiliate referred trades.
    pub affiliate_referred_trades: u32,
    /// Affiliate total referred fees.
    pub affiliate_total_referred_fees: BigDecimal,
    /// Affiliate referred users.
    pub affiliate_referred_users: u32,
    /// Affiliate referred net protocol earnings.
    pub affiliate_referred_net_protocol_earnings: BigDecimal,
    /// Affiliate referred total volume.
    pub affiliate_referred_total_volume: BigDecimal,
    /// Affiliate referred maker fees.
    pub affiliate_referred_maker_fees: BigDecimal,
    /// Affiliate referred taker fees.
    pub affiliate_referred_taker_fees: BigDecimal,
    /// Affiliate referred maker rebates.
    pub affiliate_referred_maker_rebates: BigDecimal,
}

/// Affiliate total volume response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct AffiliateTotalVolumeResponse {
    /// Total volume.
    pub total_volume: Option<BigDecimal>,
}

/// Pagination response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct PaginationResponse {
    /// Page size.
    pub page_size: Option<u32>,
    /// Total results.
    pub total_results: Option<u32>,
    /// Offset.
    pub offset: Option<u32>,
}

/// Transfers response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct TransferResponse {
    /// List of transfers.
    pub transfers: Vec<TransferResponseObject>,
    /// Pagination.
    #[serde(flatten)]
    pub pagination: PaginationResponse,
}

/// Parent subaccount transfer response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct ParentSubaccountTransferResponse {
    /// List of transfers.
    pub transfers: Vec<ParentSubaccountTransferResponseObject>,
}

/// Trader search response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct TraderSearchResponse {
    /// Result.
    pub result: Option<TraderSearchResponseObject>,
}

/// Trader search response object.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct TraderSearchResponseObject {
    /// Address.
    pub address: Address,
    /// Subaccount number.
    pub subaccount_number: SubaccountNumber,
    /// Subaccount id.
    pub subaccount_id: SubaccountId,
    /// Username.
    pub username: String,
}

/// Transfer between response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct TransferBetweenResponse {
    /// List of transfers.
    pub transfers_subset: Vec<TransferResponseObject>,
    /// Total net transfers.
    pub total_net_transfers: BigDecimal,
    /// Pagination.
    #[serde(flatten)]
    pub pagination: PaginationResponse,
}

/// Funding payment response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct FundingPaymentResponse {
    /// List of funding payments.
    pub funding_payments: Vec<FundingPaymentResponseObject>,
    /// Pagination.
    #[serde(flatten)]
    pub pagination: PaginationResponse,
}

/// Funding payment response object.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct FundingPaymentResponseObject {
    /// Time (UTC).
    pub created_at: DateTime<Utc>,
    /// Block height.
    pub created_at_height: Height,
    /// Perpetual id.
    pub perpetual_id: String,
    /// Ticker.
    pub ticker: Ticker,
    /// Oracle price.
    pub oracle_price: BigDecimal,
    /// Size.
    pub size: BigDecimal,
    /// Side.
    pub side: FundingOrderSide,
    /// Rate.
    pub rate: BigDecimal,
    /// Payment.
    pub payment: BigDecimal,
    /// Subaccount number.
    pub subaccount_number: SubaccountNumber,
    /// Funding index.
    pub funding_index: String,
}

/// Funding order side.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
pub enum FundingOrderSide {
    /// Long.
    Long,
    /// Short.
    Short,
}

/// Transfer response.
/// T is the type of the sender and recipient.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct TransferResponseObject {
    /// Transfer id.
    pub id: TransferId,
    /// Sender of transfer.
    pub sender: Account,
    /// Recipient of transfer.
    pub recipient: Account,
    /// Size of transfer.
    pub size: BigDecimal,
    /// Time (UTC).
    pub created_at: DateTime<Utc>,
    /// Block height.
    pub created_at_height: Height,
    /// Token symbol.
    pub symbol: Symbol,
    /// Transfer type.
    #[serde(rename = "type")]
    pub transfer_type: TransferType,
    /// Transfer transaction hash.
    pub transaction_hash: String,
}

/// Parent subaccount transfer response object.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct ParentSubaccountTransferResponseObject {
    /// Transfer id.
    pub id: TransferId,
    /// Sender of transfer.
    pub sender: AccountWithParentSubaccountNumber,
    /// Recipient of transfer.
    pub recipient: AccountWithParentSubaccountNumber,
    /// Size of transfer.
    pub size: BigDecimal,
    /// Time (UTC).
    pub created_at: DateTime<Utc>,
    /// Block height.
    pub created_at_height: Height,
    /// Token symbol.
    pub symbol: Symbol,
    /// Transfer type.
    #[serde(rename = "type")]
    pub transfer_type: TransferType,
    /// Transfer transaction hash.
    pub transaction_hash: String,
}

/// Orders list response.
pub type ListOrdersResponse = Vec<OrderResponseObject>;

/// Fills response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct FillResponse {
    /// List of fills.
    pub fills: Vec<FillResponseObject>,
}

/// Fill response.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct FillResponseObject {
    /// Fill id.
    pub id: FillId,
    /// Side (buy/sell).
    pub side: OrderSide,
    /// Liquidity.
    pub liquidity: Liquidity,
    /// Fill type.
    #[serde(rename = "type")]
    pub fill_type: FillType,
    /// Market ticker.
    pub market: Ticker,
    /// Market type.
    pub market_type: MarketType,
    /// Price.
    pub price: Price,
    /// Size.
    pub size: BigDecimal,
    /// Fee.
    pub fee: BigDecimal,
    /// Affiliate rev share.
    pub affiliate_rev_share: BigDecimal,
    /// Time (UTC).
    pub created_at: DateTime<Utc>,
    /// Block height.
    pub created_at_height: Height,
    /// Order id.
    pub order_id: Option<OrderId>,
    /// Client metadata.
    pub client_metadata: Option<ClientMetadata>,
    /// Subaccount number.
    pub subaccount_number: SubaccountNumber,
    /// Builder fee.
    pub builder_fee: Option<BigDecimal>,
    /// Builder address.
    pub builder_address: Option<Address>,
    /// Order router address.
    pub order_router_address: Option<Address>,
    /// Order router fee.
    pub order_router_fee: Option<BigDecimal>,
}

/// Profit and loss reports.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct HistoricalPnlResponse {
    /// List of PnL reports.
    pub historical_pnl: Vec<PnlTicksResponseObject>,
}

/// Profit and loss report.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct PnlTicksResponseObject {
    /// Block height.
    pub block_height: Height,
    /// Time (UTC).
    pub block_time: DateTime<Utc>,
    /// Time (UTC).
    pub created_at: DateTime<Utc>,
    /// Equity.
    pub equity: BigDecimal,
    /// Total PnL.
    pub total_pnl: BigDecimal,
    /// Net transfers.
    pub net_transfers: BigDecimal,
}

/// Trading rewards reports.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct HistoricalBlockTradingRewardsResponse {
    /// List of reports.
    pub rewards: Vec<HistoricalBlockTradingReward>,
}

/// Trading rewards report.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct HistoricalBlockTradingReward {
    /// Trading reward amount.
    pub trading_reward: BigDecimal,
    /// Block height.
    pub created_at_height: Height,
    /// Time (UTC).
    pub created_at: DateTime<Utc>,
}

/// Trading rewards aggregation reports.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct HistoricalTradingRewardAggregationsResponse {
    /// List of reports.
    pub rewards: Vec<HistoricalTradingRewardAggregation>,
}

/// Trading rewards aggregation report.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct HistoricalTradingRewardAggregation {
    /// Trading reward amount.
    pub trading_reward: BigDecimal,
    /// Block height.
    pub started_at_height: Height,
    /// Time (UTC).
    pub started_at: DateTime<Utc>,
    /// Block height.
    pub ended_at_height: Option<Height>,
    /// Time (UTC).
    pub ended_at: Option<DateTime<Utc>>,
    /// Aggregation period.
    pub period: TradingRewardAggregationPeriod,
}

/// MegaVault Profit and loss reports.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct MegaVaultHistoricalPnlResponse {
    /// List of PnL reports.
    pub megavault_pnl: Vec<PnlTicksResponseObject>,
}

/// MegaVault Profit and loss reports.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct MegaVaultPositionResponse {
    /// List MegaVault positions.
    pub positions: Vec<VaultPosition>,
}

/// Vaults profit and loss reports.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct VaultsHistoricalPnLResponse {
    /// List of PnL reports.
    pub vaults_pnl: Vec<VaultHistoricalPnl>,
}

/// Vault Profit and loss reports.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct VaultHistoricalPnl {
    /// Associated ticker.
    pub ticker: String,
    /// List of PnL reports.
    pub historical_pnl: Vec<PnlTicksResponseObject>,
}

/// Vault position.
#[derive(Deserialize, Debug, Clone)]
#[serde(rename_all = "camelCase")]
#[cfg_attr(any(test, feature = "strict-serde"), serde(deny_unknown_fields))]
pub struct VaultPosition {
    /// Associated ticker.
    pub ticker: String,
    /// Asset position.
    pub asset_position: Option<AssetPositionResponseObject>,
    /// Perpetual position.
    pub perpetual_position: Option<PerpetualPositionResponseObject>,
    /// Equity.
    pub equity: BigDecimal,
}