deribit_base/model/
transaction.rs1use pretty_simple_display::{DebugPretty, DisplaySimple};
7use serde::{Deserialize, Serialize};
8
9#[derive(Debug, Clone, Serialize, Deserialize, Default)]
11pub enum TransactionType {
12 Deposit,
14 Withdrawal,
16 #[default]
18 Trade,
19 Transfer,
21 Fee,
23 Funding,
25 Bonus,
27 Dividend,
29 Liquidation,
31 Insurance,
33}
34
35#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
37pub struct TransactionLogEntry {
38 pub id: u64,
40 pub currency: String,
42 pub amount: f64,
44 pub balance: f64,
46 pub timestamp: u64,
48 pub transaction_type: TransactionType,
50 pub info: Option<String>,
52}
53
54impl Default for TransactionLogEntry {
55 fn default() -> Self {
56 Self {
57 id: 0,
58 currency: String::new(),
59 amount: 0.0,
60 balance: 0.0,
61 timestamp: 0,
62 transaction_type: TransactionType::default(),
63 info: None,
64 }
65 }
66}
67
68#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize, Default)]
70pub struct TransactionLog {
71 pub continuation: Option<String>,
73 pub logs: Vec<TransactionLogEntry>,
75}
76
77#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
79pub struct Deposit {
80 pub address: String,
82 pub amount: f64,
84 pub currency: String,
86 pub state: String,
88 pub received_timestamp: u64,
90 pub transaction_id: Option<String>,
92 #[serde(skip_serializing_if = "Option::is_none")]
94 pub updated_timestamp: Option<u64>,
95}
96
97#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
99pub struct DepositsResponse {
100 pub count: u32,
102 pub data: Vec<Deposit>,
104}
105
106#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
108pub struct Withdrawal {
109 pub address: String,
111 pub amount: f64,
113 pub currency: String,
115 pub fee: f64,
117 pub id: u64,
119 pub priority: String,
121 pub state: String,
123 pub created_timestamp: u64,
125 pub updated_timestamp: Option<u64>,
127 pub transaction_id: Option<String>,
129}
130
131#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
133pub struct WithdrawalsResponse {
134 pub count: u32,
136 pub data: Vec<Withdrawal>,
138}
139
140#[cfg(test)]
141mod tests {
142 use super::*;
143
144 #[test]
145 fn test_default_transaction_log_entry() {
146 let tx = TransactionLogEntry::default();
147 assert_eq!(tx.id, 0);
148 assert_eq!(tx.amount, 0.0);
149 }
150}