Skip to main content

rust_okx/api/funding/
responses.rs

1use serde::Deserialize;
2
3use crate::model::NumberString;
4
5/// Currency metadata and chain settings.
6#[derive(Debug, Clone, Default, Deserialize)]
7#[serde(rename_all = "camelCase")]
8#[non_exhaustive]
9pub struct Currency {
10    /// Currency code.
11    #[serde(default)]
12    pub ccy: String,
13    /// Display name.
14    #[serde(default)]
15    pub name: String,
16    /// Chain name.
17    #[serde(default)]
18    pub chain: String,
19    /// Minimum withdrawal amount.
20    #[serde(default, rename = "minWd")]
21    pub min_wd: NumberString,
22    /// Minimum deposit amount.
23    #[serde(default, rename = "minDep")]
24    pub min_dep: NumberString,
25    /// Withdrawal fee.
26    #[serde(default, rename = "minFee")]
27    pub min_fee: NumberString,
28    /// Whether deposit is enabled.
29    #[serde(default, rename = "canDep")]
30    pub can_dep: bool,
31    /// Whether withdrawal is enabled.
32    #[serde(default, rename = "canWd")]
33    pub can_wd: bool,
34    /// Whether internal transfer is enabled.
35    #[serde(default, rename = "canInternal")]
36    pub can_internal: bool,
37}
38
39/// Funding-account balance for one currency.
40#[derive(Debug, Clone, Default, Deserialize)]
41#[serde(rename_all = "camelCase")]
42#[non_exhaustive]
43pub struct FundingBalance {
44    /// Currency code.
45    #[serde(default)]
46    pub ccy: String,
47    /// Total balance.
48    #[serde(default)]
49    pub bal: NumberString,
50    /// Frozen balance.
51    #[serde(default)]
52    pub frozen_bal: NumberString,
53    /// Available balance.
54    #[serde(default)]
55    pub avail_bal: NumberString,
56}
57
58/// Non-tradable asset row.
59#[derive(Debug, Clone, Default, Deserialize)]
60#[serde(rename_all = "camelCase")]
61#[non_exhaustive]
62pub struct NonTradableAsset {
63    /// Currency code.
64    #[serde(default)]
65    pub ccy: String,
66    /// Asset amount.
67    #[serde(default)]
68    pub amt: NumberString,
69    /// Asset type.
70    #[serde(default, rename = "type")]
71    pub asset_type: String,
72}
73
74/// Deposit address for one currency/chain.
75#[derive(Debug, Clone, Default, Deserialize)]
76#[serde(rename_all = "camelCase")]
77#[non_exhaustive]
78pub struct DepositAddress {
79    /// Currency code.
80    #[serde(default)]
81    pub ccy: String,
82    /// Chain name.
83    #[serde(default)]
84    pub chain: String,
85    /// Deposit address.
86    #[serde(default)]
87    pub addr: String,
88    /// Address tag, memo, or payment ID when required by the chain.
89    #[serde(default)]
90    pub tag: String,
91    /// Selected account.
92    #[serde(default)]
93    pub selected: bool,
94}
95
96/// Funds-transfer result.
97#[derive(Debug, Clone, Default, Deserialize)]
98#[serde(rename_all = "camelCase")]
99#[non_exhaustive]
100pub struct TransferResult {
101    /// Transfer ID.
102    #[serde(default, rename = "transId")]
103    pub trans_id: String,
104    /// Client-supplied ID.
105    #[serde(default, rename = "clientId")]
106    pub client_id: String,
107    /// Currency code.
108    #[serde(default)]
109    pub ccy: String,
110    /// The remitting account.
111    #[serde(default, rename = "from")]
112    pub from_account: String,
113    /// Transfer amount.
114    #[serde(default)]
115    pub amt: NumberString,
116    /// The beneficiary account.
117    #[serde(default)]
118    pub to: String,
119}
120
121/// Funds-transfer state.
122#[derive(Debug, Clone, Default, Deserialize)]
123#[serde(rename_all = "camelCase")]
124#[non_exhaustive]
125pub struct TransferState {
126    /// Transfer ID.
127    #[serde(default, rename = "transId")]
128    pub trans_id: String,
129    /// Client-supplied ID.
130    #[serde(default, rename = "clientId")]
131    pub client_id: String,
132    /// Currency code.
133    #[serde(default)]
134    pub ccy: String,
135    /// Transfer amount.
136    #[serde(default)]
137    pub amt: NumberString,
138    /// Transfer type.
139    #[serde(default, rename = "type")]
140    pub transfer_type: String,
141    /// Source account.
142    #[serde(default, rename = "from")]
143    pub from_account: String,
144    /// Destination account.
145    #[serde(default)]
146    pub to: String,
147    /// Name of the sub-account.
148    #[serde(default, rename = "subAcct")]
149    pub sub_account: String,
150    /// Transfer state.
151    #[serde(default)]
152    pub state: String,
153}
154
155/// Withdrawal result.
156#[derive(Debug, Clone, Default, Deserialize)]
157#[serde(rename_all = "camelCase")]
158#[non_exhaustive]
159pub struct WithdrawalResult {
160    /// Withdrawal ID.
161    #[serde(default, rename = "wdId")]
162    pub wd_id: String,
163    /// Client withdrawal ID.
164    #[serde(default, rename = "clientId")]
165    pub client_id: String,
166    /// Currency code.
167    #[serde(default)]
168    pub ccy: String,
169    /// Withdrawal amount.
170    #[serde(default)]
171    pub amt: NumberString,
172}
173
174/// Deposit history row.
175#[derive(Debug, Clone, Default, Deserialize)]
176#[serde(rename_all = "camelCase")]
177#[non_exhaustive]
178pub struct DepositRecord {
179    /// Deposit ID.
180    #[serde(default, rename = "depId")]
181    pub dep_id: String,
182    /// Transaction ID.
183    #[serde(default, rename = "txId")]
184    pub tx_id: String,
185    /// Currency code.
186    #[serde(default)]
187    pub ccy: String,
188    /// Chain name.
189    #[serde(default)]
190    pub chain: String,
191    /// Deposit amount.
192    #[serde(default)]
193    pub amt: NumberString,
194    /// Deposit state.
195    #[serde(default)]
196    pub state: String,
197    /// Timestamp.
198    #[serde(default)]
199    pub ts: NumberString,
200}
201
202/// Withdrawal history row.
203#[derive(Debug, Clone, Default, Deserialize)]
204#[serde(rename_all = "camelCase")]
205#[non_exhaustive]
206pub struct WithdrawalRecord {
207    /// Withdrawal ID.
208    #[serde(default, rename = "wdId")]
209    pub wd_id: String,
210    /// Client withdrawal ID.
211    #[serde(default, rename = "clientId")]
212    pub client_id: String,
213    /// Transaction ID.
214    #[serde(default, rename = "txId")]
215    pub tx_id: String,
216    /// Currency code.
217    #[serde(default)]
218    pub ccy: String,
219    /// Chain name.
220    #[serde(default)]
221    pub chain: String,
222    /// Withdrawal amount.
223    #[serde(default)]
224    pub amt: NumberString,
225    /// Fee.
226    #[serde(default)]
227    pub fee: NumberString,
228    /// Withdrawal state.
229    #[serde(default)]
230    pub state: String,
231    /// Timestamp.
232    #[serde(default)]
233    pub ts: NumberString,
234}
235
236/// Funding-account bill row.
237#[derive(Debug, Clone, Default, Deserialize)]
238#[serde(rename_all = "camelCase")]
239#[non_exhaustive]
240pub struct FundingBill {
241    /// Bill ID.
242    #[serde(default, rename = "billId")]
243    pub bill_id: String,
244    /// Currency code.
245    #[serde(default)]
246    pub ccy: String,
247    /// Balance change.
248    #[serde(default)]
249    pub bal_chg: NumberString,
250    /// Balance after change.
251    #[serde(default)]
252    pub bal: NumberString,
253    /// Bill type.
254    #[serde(default, rename = "type")]
255    pub bill_type: String,
256    /// Timestamp.
257    #[serde(default)]
258    pub ts: NumberString,
259}
260
261/// Lightning deposit invoice.
262#[derive(Debug, Clone, Default, Deserialize)]
263#[serde(rename_all = "camelCase")]
264#[non_exhaustive]
265pub struct DepositLightning {
266    /// Currency code.
267    #[serde(default)]
268    pub ccy: String,
269    /// Invoice amount.
270    #[serde(default)]
271    pub amt: NumberString,
272    /// Lightning invoice.
273    #[serde(default)]
274    pub invoice: String,
275    /// Recipient.
276    #[serde(default)]
277    pub to: String,
278}
279
280/// Lightning withdrawal result.
281#[derive(Debug, Clone, Default, Deserialize)]
282#[serde(rename_all = "camelCase")]
283#[non_exhaustive]
284pub struct WithdrawalLightning {
285    /// Currency code.
286    #[serde(default)]
287    pub ccy: String,
288    /// Withdrawal amount.
289    #[serde(default)]
290    pub amt: NumberString,
291    /// Withdrawal ID.
292    #[serde(default, rename = "wdId")]
293    pub wd_id: String,
294}
295
296/// Total asset valuation.
297#[derive(Debug, Clone, Default, Deserialize)]
298#[serde(rename_all = "camelCase")]
299#[non_exhaustive]
300pub struct AssetValuation {
301    /// Valuation details by account area.
302    #[serde(default)]
303    pub details: AssetValuationDetails,
304    /// Total balance in the requested valuation currency.
305    #[serde(default, rename = "totalBal")]
306    pub total_bal: NumberString,
307}
308
309/// Asset valuation details by account area.
310#[derive(Debug, Clone, Default, Deserialize)]
311#[serde(rename_all = "camelCase")]
312#[non_exhaustive]
313pub struct AssetValuationDetails {
314    /// Funding-account valuation.
315    #[serde(default)]
316    pub funding: NumberString,
317    /// Trading-account valuation.
318    #[serde(default)]
319    pub trading: NumberString,
320    /// Earn-account valuation.
321    #[serde(default)]
322    pub earn: NumberString,
323    /// Classic-account valuation.
324    #[serde(default)]
325    pub classic: NumberString,
326}
327
328/// Deposit/withdrawal status row.
329#[derive(Debug, Clone, Default, Deserialize)]
330#[serde(rename_all = "camelCase")]
331#[non_exhaustive]
332pub struct DepositWithdrawStatus {
333    /// Withdrawal ID.
334    #[serde(default, rename = "wdId")]
335    pub wd_id: String,
336    /// Transaction ID.
337    #[serde(default, rename = "txId")]
338    pub tx_id: String,
339    /// Currency code.
340    #[serde(default)]
341    pub ccy: String,
342    /// Chain name.
343    #[serde(default)]
344    pub chain: String,
345    /// Destination address.
346    #[serde(default)]
347    pub to: String,
348    /// State.
349    #[serde(default)]
350    pub state: String,
351}
352
353/// Dust-conversion result.
354#[derive(Debug, Clone, Default, Deserialize)]
355#[serde(rename_all = "camelCase")]
356#[non_exhaustive]
357pub struct ConvertDustAssetsResult {
358    /// Currency code.
359    #[serde(default)]
360    pub ccy: String,
361    /// Converted amount.
362    #[serde(default)]
363    pub amt: NumberString,
364}
365
366/// Purchase/redemption result.
367#[derive(Debug, Clone, Default, Deserialize)]
368#[serde(rename_all = "camelCase")]
369#[non_exhaustive]
370pub struct PurchaseRedemptResult {
371    /// Currency code.
372    #[serde(default)]
373    pub ccy: String,
374    /// Amount.
375    #[serde(default)]
376    pub amt: NumberString,
377    /// Operation side.
378    #[serde(default)]
379    pub side: String,
380}