rust_okx/api/finance/responses/staking.rs
1use crate::model::NumberString;
2use serde::Deserialize;
3
4/// Currency-level investment data returned by the Staking/DeFi offers endpoint.
5#[derive(Debug, Clone, Deserialize)]
6#[serde(rename_all = "camelCase")]
7#[non_exhaustive]
8pub struct StakingDefiInvestData {
9 /// Investment currency, e.g. `BTC`.
10 #[serde(default)]
11 pub ccy: String,
12 /// Available balance to invest.
13 #[serde(default)]
14 pub bal: NumberString,
15 /// Minimum subscription amount.
16 #[serde(default)]
17 pub min_amt: NumberString,
18 /// Maximum available subscription amount.
19 #[serde(default)]
20 pub max_amt: NumberString,
21}
22
23/// Earning data returned by the Staking/DeFi offers endpoint.
24#[derive(Debug, Clone, Deserialize)]
25#[serde(rename_all = "camelCase")]
26#[non_exhaustive]
27pub struct StakingDefiEarningData {
28 /// Earning currency, e.g. `BTC`.
29 #[serde(default)]
30 pub ccy: String,
31 /// Earning type.
32 ///
33 /// `0`: Estimated earning, `1`: Cumulative earning.
34 #[serde(default)]
35 pub earning_type: String,
36}
37
38/// Staking/DeFi offer row.
39#[derive(Debug, Clone, Deserialize)]
40#[serde(rename_all = "camelCase")]
41#[non_exhaustive]
42pub struct StakingDefiOffer {
43 /// Currency type, e.g. `BTC`.
44 #[serde(default)]
45 pub ccy: String,
46 /// Value returned by OKX in the `productId` field.
47 #[serde(default)]
48 pub product_id: String,
49 /// Protocol name.
50 #[serde(default)]
51 pub protocol: String,
52 /// Protocol type.
53 ///
54 /// `defi`: on-chain earn.
55 #[serde(default)]
56 pub protocol_type: String,
57 /// Protocol term.
58 ///
59 /// Returns the days of a fixed term, or `0` for a flexible product.
60 #[serde(default)]
61 pub term: String,
62 /// Estimated annualization. `0.07` represents 7%.
63 #[serde(default)]
64 pub apy: NumberString,
65 /// Whether the protocol supports early redemption.
66 #[serde(default)]
67 pub early_redeem: bool,
68 /// Current target currency information available for investment.
69 #[serde(default)]
70 pub invest_data: Vec<StakingDefiInvestData>,
71 /// Earning data.
72 #[serde(default)]
73 pub earning_data: Vec<StakingDefiEarningData>,
74 /// Product state.
75 ///
76 /// `purchasable`: Purchasable, `sold_out`: Sold out,
77 /// `Stop`: Suspension of subscription.
78 #[serde(default)]
79 pub state: String,
80 /// Redemption period, format `[min time, max time]` where `H`: Hour, `D`: Day.
81 ///
82 /// e.g. `["1H","24H"]` or `["14D","14D"]`.
83 #[serde(default)]
84 pub redeem_period: Vec<String>,
85 /// Fast redemption daily limit.
86 ///
87 /// Returns `''` if fast redemption is not supported.
88 #[serde(default)]
89 pub fast_redemption_daily_limit: NumberString,
90}
91
92/// Currency-level investment data returned by the Staking/DeFi order endpoints
93/// (active orders and order history).
94#[derive(Debug, Clone, Deserialize)]
95#[serde(rename_all = "camelCase")]
96#[non_exhaustive]
97pub struct StakingDefiOrderInvestData {
98 /// Investment currency, e.g. `BTC`.
99 #[serde(default)]
100 pub ccy: String,
101 /// Invested amount.
102 #[serde(default)]
103 pub amt: NumberString,
104}
105
106/// Earning data returned by the Staking/DeFi order endpoints.
107#[derive(Debug, Clone, Deserialize)]
108#[serde(rename_all = "camelCase")]
109#[non_exhaustive]
110pub struct StakingDefiOrderEarningData {
111 /// Earning currency, e.g. `BTC`.
112 #[serde(default)]
113 pub ccy: String,
114 /// Earning type.
115 ///
116 /// `0`: Estimated earning, `1`: Cumulative earning.
117 #[serde(default)]
118 pub earning_type: String,
119 /// Earning amount. Returned by the active-orders endpoint.
120 #[serde(default)]
121 pub earnings: NumberString,
122 /// Cumulative earning of redeemed orders. Returned by the order-history
123 /// endpoint; only valid when the order is in a redemption state.
124 #[serde(default)]
125 pub realized_earnings: NumberString,
126}
127
128/// Fast redemption data returned by the Staking/DeFi active-orders endpoint.
129#[derive(Debug, Clone, Deserialize)]
130#[serde(rename_all = "camelCase")]
131#[non_exhaustive]
132pub struct StakingDefiFastRedemptionData {
133 /// Currency, e.g. `BTC`.
134 #[serde(default)]
135 pub ccy: String,
136 /// Redeeming amount.
137 #[serde(default)]
138 pub redeeming_amt: NumberString,
139}
140
141/// Staking/DeFi order row, returned by both the active-orders and order-history
142/// endpoints.
143#[derive(Debug, Clone, Deserialize)]
144#[serde(rename_all = "camelCase")]
145#[non_exhaustive]
146pub struct StakingDefiOrder {
147 /// Currency, e.g. `BTC`.
148 #[serde(default)]
149 pub ccy: String,
150 /// Order ID.
151 #[serde(default)]
152 pub ord_id: String,
153 /// Product ID.
154 #[serde(default)]
155 pub product_id: String,
156 /// Order state.
157 ///
158 /// Active orders: `8`: Pending, `13`: Cancelling, `9`: Onchain,
159 /// `1`: Earning, `2`: Redeeming.
160 /// Order history: `3`: Completed (including canceled and redeemed).
161 #[serde(default)]
162 pub state: String,
163 /// Protocol.
164 #[serde(default)]
165 pub protocol: String,
166 /// Protocol type.
167 ///
168 /// `defi`: on-chain earn.
169 #[serde(default)]
170 pub protocol_type: String,
171 /// Protocol term.
172 ///
173 /// Returns the days of a fixed term, or `0` for a flexible product.
174 #[serde(default)]
175 pub term: String,
176 /// Estimated APY. `0.07` represents 7%. Retained to 4 decimal places
177 /// (truncated).
178 #[serde(default)]
179 pub apy: NumberString,
180 /// Investment data.
181 #[serde(default)]
182 pub invest_data: Vec<StakingDefiOrderInvestData>,
183 /// Earning data.
184 #[serde(default)]
185 pub earning_data: Vec<StakingDefiOrderEarningData>,
186 /// Fast redemption data. Only returned by the active-orders endpoint.
187 #[serde(default)]
188 pub fast_redemption_data: Vec<StakingDefiFastRedemptionData>,
189 /// Order purchased time, Unix timestamp in milliseconds, e.g.
190 /// `1597026383085`.
191 #[serde(default)]
192 pub purchased_time: NumberString,
193 /// Estimated redemption settlement time. Only returned by the active-orders
194 /// endpoint.
195 #[serde(default)]
196 pub est_settlement_time: NumberString,
197 /// Deadline for cancellation of a redemption application. Only returned by
198 /// the active-orders endpoint.
199 #[serde(default)]
200 pub cancel_redemption_deadline: NumberString,
201 /// Order redeemed time. Only returned by the order-history endpoint.
202 #[serde(default)]
203 pub redeemed_time: NumberString,
204 /// Order tag.
205 #[serde(default)]
206 pub tag: String,
207}
208
209/// Staking product-info row.
210#[derive(Debug, Clone, Deserialize)]
211#[serde(rename_all = "camelCase")]
212#[non_exhaustive]
213pub struct StakingProductInfo {
214 /// Fast redemption daily limit.
215 /// The master account and sub-accounts share the same limit.
216 #[serde(default)]
217 pub fast_redemption_daily_limit: NumberString,
218 /// The latest rate for checking crypto.
219 #[serde(default)]
220 pub rate: NumberString,
221 /// Redemption days of crypto.
222 #[serde(default)]
223 pub redempt_days: NumberString,
224 /// Minimum subscription amount of crypto.
225 #[serde(default)]
226 pub min_amt: NumberString,
227 /// urrently fast redemption max available amount
228 /// Only for `SOL_PRODUCT_INFO`
229 #[serde(default)]
230 pub fast_redemption_avail: Option<NumberString>,
231}
232
233/// Staking order row.
234#[derive(Debug, Clone, Deserialize)]
235#[serde(rename_all = "camelCase")]
236#[non_exhaustive]
237pub struct StakingOrder {
238 /// Value returned by OKX in the `ordId` field.
239 #[serde(default)]
240 pub ord_id: String,
241 /// Value returned by OKX in the `ccy` field.
242 #[serde(default)]
243 pub ccy: String,
244 /// Value returned by OKX in the `amt` field.
245 #[serde(default)]
246 pub amt: NumberString,
247 /// Value returned by OKX in the `state` field.
248 #[serde(default)]
249 pub state: String,
250 /// Value returned by OKX in the `type` field.
251 #[serde(default, rename = "type")]
252 pub order_type: String,
253 /// Value returned by OKX in the `cTime` field.
254 #[serde(default)]
255 pub c_time: NumberString,
256}
257
258/// Cancel redeem ETH
259#[derive(Debug, Clone, Deserialize)]
260#[serde(rename_all = "camelCase")]
261#[non_exhaustive]
262pub struct CancelRedeem {
263 /// Value returned by OKX in the `ordId` field
264 #[serde(default)]
265 pub ord_id: String,
266}
267
268/// Staking balance row.
269#[derive(Debug, Clone, Deserialize)]
270#[serde(rename_all = "camelCase")]
271#[non_exhaustive]
272pub struct StakingBalance {
273 /// Value returned by OKX in the `ccy` field.
274 #[serde(default)]
275 pub ccy: String,
276 /// Value returned by OKX in the `amt` field.
277 #[serde(default)]
278 pub amt: NumberString,
279 /// Value returned by OKX in the `latestInterestAccrual` field.
280 #[serde(default)]
281 pub latest_interest_accrual: NumberString,
282 /// Value returned by OKX in the `totalInterestAccrual` field.
283 #[serde(default)]
284 pub total_interest_accrual: NumberString,
285 /// Value returned by OKX in the `ts` field. Present for ETH balance;
286 /// absent for SOL balance.
287 #[serde(default)]
288 pub ts: NumberString,
289}
290
291/// Staking purchase/redeem history row.
292#[derive(Debug, Clone, Deserialize)]
293#[serde(rename_all = "camelCase")]
294#[non_exhaustive]
295pub struct StakingHistory {
296 /// Value returned by OKX in the `type` field.
297 #[serde(default, rename = "type")]
298 pub event_type: String,
299 /// Value returned by OKX in the `amt` field.
300 #[serde(default)]
301 pub amt: NumberString,
302 /// Value returned by OKX in the `redeemingAmt` field.
303 #[serde(default)]
304 pub redeeming_amt: NumberString,
305 /// Value returned by OKX in the `status` field.
306 #[serde(default)]
307 pub status: String,
308 /// Value returned by OKX in the `ordId` field. Present for ETH history;
309 /// absent for SOL history.
310 #[serde(default)]
311 pub ord_id: String,
312 /// Value returned by OKX in the `requestTime` field.
313 #[serde(default)]
314 pub request_time: NumberString,
315 /// Value returned by OKX in the `completedTime` field.
316 #[serde(default)]
317 pub completed_time: NumberString,
318 /// Value returned by OKX in the `estCompletedTime` field.
319 #[serde(default)]
320 pub est_completed_time: NumberString,
321}
322
323/// Staking APY-history row.
324#[derive(Debug, Clone, Deserialize)]
325#[serde(rename_all = "camelCase")]
326#[non_exhaustive]
327pub struct StakingApyHistory {
328 /// Value returned by OKX in the `rate` field.
329 #[serde(default)]
330 pub rate: NumberString,
331 /// Value returned by OKX in the `ts` field.
332 #[serde(default)]
333 pub ts: NumberString,
334}