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
/****************************************************************************
Author: Joaquín Béjar García
Email: jb@taunais.com
Date: 21/7/25
******************************************************************************/
use pretty_simple_display::{DebugPretty, DisplaySimple};
use serde::{Deserialize, Serialize};
/// Transaction type enumeration
#[derive(Debug, Clone, Serialize, Deserialize, Default)]
pub enum TransactionType {
/// Deposit transaction
Deposit,
/// Withdrawal transaction
Withdrawal,
/// Trade transaction (default)
#[default]
Trade,
/// Transfer transaction
Transfer,
/// Fee transaction
Fee,
/// Funding transaction
Funding,
/// Bonus transaction
Bonus,
/// Dividend transaction
Dividend,
/// Liquidation transaction
Liquidation,
/// Insurance transaction
Insurance,
}
/// Generic transaction log entry
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
pub struct TransactionLogEntry {
/// Unique transaction identifier
pub id: u64,
/// Currency of the transaction
pub currency: String,
/// Transaction amount
pub amount: f64,
/// Account balance after transaction
pub balance: f64,
/// Transaction timestamp
pub timestamp: u64,
/// Type of transaction
pub transaction_type: TransactionType,
/// Additional transaction information
pub info: Option<String>,
}
impl Default for TransactionLogEntry {
fn default() -> Self {
Self {
id: 0,
currency: String::new(),
amount: 0.0,
balance: 0.0,
timestamp: 0,
transaction_type: TransactionType::default(),
info: None,
}
}
}
/// Paginated transaction log response
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize, Default)]
pub struct TransactionLog {
/// Continuation token for pagination
pub continuation: Option<String>,
/// List of transaction log entries
pub logs: Vec<TransactionLogEntry>,
}
/// Deposit information
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
pub struct Deposit {
/// Deposit address
pub address: String,
/// Deposit amount
pub amount: f64,
/// Currency of the deposit
pub currency: String,
/// Current state of the deposit
pub state: String,
/// Timestamp when deposit was received
pub received_timestamp: u64,
/// Transaction ID on the blockchain
pub transaction_id: Option<String>,
/// Timestamp when deposit was last updated
#[serde(skip_serializing_if = "Option::is_none")]
pub updated_timestamp: Option<u64>,
}
/// Deposits response wrapper
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
pub struct DepositsResponse {
/// Total count of deposits
pub count: u32,
/// List of deposit entries
pub data: Vec<Deposit>,
}
/// Withdrawal information
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
pub struct Withdrawal {
/// Withdrawal address
pub address: String,
/// Withdrawal amount
pub amount: f64,
/// Currency of the withdrawal
pub currency: String,
/// Withdrawal fee
pub fee: f64,
/// Unique withdrawal identifier
pub id: u64,
/// Withdrawal priority level
pub priority: String,
/// Current state of the withdrawal
pub state: String,
/// Timestamp when withdrawal was created
pub created_timestamp: u64,
/// Timestamp when withdrawal was last updated
pub updated_timestamp: Option<u64>,
/// Transaction ID on the blockchain
pub transaction_id: Option<String>,
}
/// Withdrawals response wrapper
#[derive(DebugPretty, DisplaySimple, Clone, Serialize, Deserialize)]
pub struct WithdrawalsResponse {
/// Total count of withdrawals
pub count: u32,
/// List of withdrawal entries
pub data: Vec<Withdrawal>,
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_default_transaction_log_entry() {
let tx = TransactionLogEntry::default();
assert_eq!(tx.id, 0);
assert_eq!(tx.amount, 0.0);
}
}