1use rust_decimal::Decimal;
2use serde::{Deserialize, Serialize};
3use serde_aux::prelude::deserialize_number_from_string as number;
4
5use crate::{LtOrderStatus, LtOrderType, LtStatus, Timestamp, serde::empty_string_as_none};
6
7#[derive(Debug, Serialize, Clone)]
12#[serde(rename_all = "camelCase")]
13pub struct GetLeverageTokenInfoParams {
14 #[serde(skip_serializing_if = "Option::is_none")]
16 pub lt_coin: Option<String>,
17}
18
19impl GetLeverageTokenInfoParams {
20 pub fn new() -> Self {
22 Self { lt_coin: None }
23 }
24
25 pub fn with_lt_coin(mut self, v: impl Into<String>) -> Self {
27 self.lt_coin = Some(v.into());
28 self
29 }
30}
31
32impl Default for GetLeverageTokenInfoParams {
33 fn default() -> Self {
34 Self::new()
35 }
36}
37
38#[derive(Debug, Deserialize, PartialEq)]
40#[serde(rename_all = "camelCase")]
41pub struct LeverageTokenInfo {
42 pub lt_coin: String,
44 pub lt_name: String,
46 pub max_purchase: Decimal,
48 pub min_purchase: Decimal,
50 pub max_purchase_daily: Decimal,
52 pub max_redeem: Decimal,
54 pub min_redeem: Decimal,
56 pub max_redeem_daily: Decimal,
58 pub purchase_fee_rate: Decimal,
60 pub redeem_fee_rate: Decimal,
62 pub lt_status: LtStatus,
64 pub fund_fee: Decimal,
66 #[serde(deserialize_with = "number")]
68 pub fund_fee_time: Timestamp,
69 pub manage_fee_rate: Decimal,
71 #[serde(deserialize_with = "number")]
73 pub manage_fee_time: Timestamp,
74 pub value: Decimal,
76 pub net_value: Decimal,
78 pub total: Decimal,
80}
81
82#[derive(Debug, Serialize, Clone)]
87#[serde(rename_all = "camelCase")]
88pub struct GetLeverageTokenMarketParams {
89 pub lt_coin: String,
91}
92
93impl GetLeverageTokenMarketParams {
94 pub fn new(lt_coin: impl Into<String>) -> Self {
96 let lt_coin: String = lt_coin.into();
97 Self { lt_coin }
98 }
99}
100
101#[derive(Debug, Deserialize, PartialEq)]
103#[serde(rename_all = "camelCase")]
104pub struct LeverageTokenMarket {
105 pub lt_coin: String,
107 pub nav: Decimal,
109 #[serde(deserialize_with = "number")]
111 pub nav_time: Timestamp,
112 pub circulation: Decimal,
114 pub basket: Decimal,
116 pub leverage: Decimal,
118}
119
120#[derive(Debug, Serialize, Clone)]
125#[serde(rename_all = "camelCase")]
126pub struct PurchaseLeverageTokenRequest {
127 pub lt_coin: String,
129 pub lt_amount: Decimal,
131 #[serde(skip_serializing_if = "Option::is_none")]
133 pub serial_no: Option<String>,
134}
135
136impl PurchaseLeverageTokenRequest {
137 pub fn new(lt_coin: impl Into<String>, lt_amount: Decimal) -> Self {
139 let lt_coin: String = lt_coin.into();
140 Self {
141 lt_coin,
142 lt_amount,
143 serial_no: None,
144 }
145 }
146
147 pub fn with_serial_no(mut self, v: impl Into<String>) -> Self {
149 self.serial_no = Some(v.into());
150 self
151 }
152}
153
154#[derive(Debug, Deserialize, PartialEq)]
156#[serde(rename_all = "camelCase")]
157pub struct PurchaseLeverageTokenResult {
158 pub lt_coin: String,
160 pub lt_order_status: LtOrderStatus,
162 pub exec_qty: Decimal,
164 pub exec_amt: Decimal,
166 pub amount: Decimal,
168 pub purchase_id: String,
170 #[serde(default, deserialize_with = "empty_string_as_none")]
172 pub serial_no: Option<String>,
173 pub value_coin: String,
175}
176
177#[derive(Debug, Serialize, Clone)]
182#[serde(rename_all = "camelCase")]
183pub struct RedeemLeverageTokenRequest {
184 pub lt_coin: String,
186 pub quantity: Decimal,
188 #[serde(skip_serializing_if = "Option::is_none")]
190 pub serial_no: Option<String>,
191}
192
193impl RedeemLeverageTokenRequest {
194 pub fn new(lt_coin: impl Into<String>, quantity: Decimal) -> Self {
196 let lt_coin: String = lt_coin.into();
197 Self {
198 lt_coin,
199 quantity,
200 serial_no: None,
201 }
202 }
203
204 pub fn with_serial_no(mut self, v: impl Into<String>) -> Self {
206 self.serial_no = Some(v.into());
207 self
208 }
209}
210
211#[derive(Debug, Deserialize, PartialEq)]
213#[serde(rename_all = "camelCase")]
214pub struct RedeemLeverageTokenResult {
215 pub lt_coin: String,
217 pub lt_order_status: LtOrderStatus,
219 pub quantity: Decimal,
221 pub exec_qty: Decimal,
223 pub exec_amt: Decimal,
225 pub redeem_id: String,
227 #[serde(default, deserialize_with = "empty_string_as_none")]
229 pub serial_no: Option<String>,
230 pub value_coin: String,
232}
233
234#[derive(Clone, Debug, Serialize)]
239#[serde(rename_all = "camelCase")]
240pub struct GetLeverageTokenOrderRecordsParams {
241 #[serde(skip_serializing_if = "Option::is_none")]
243 pub lt_coin: Option<String>,
244 #[serde(skip_serializing_if = "Option::is_none")]
246 pub order_id: Option<String>,
247 #[serde(skip_serializing_if = "Option::is_none")]
249 pub start_time: Option<Timestamp>,
250 #[serde(skip_serializing_if = "Option::is_none")]
252 pub end_time: Option<Timestamp>,
253 #[serde(skip_serializing_if = "Option::is_none")]
255 pub limit: Option<u64>,
256 #[serde(skip_serializing_if = "Option::is_none")]
258 pub lt_order_type: Option<LtOrderType>,
259 #[serde(skip_serializing_if = "Option::is_none")]
261 pub serial_no: Option<String>,
262}
263
264impl GetLeverageTokenOrderRecordsParams {
265 pub fn new() -> Self {
267 Self {
268 lt_coin: None,
269 order_id: None,
270 start_time: None,
271 end_time: None,
272 limit: None,
273 lt_order_type: None,
274 serial_no: None,
275 }
276 }
277
278 pub fn with_lt_coin(mut self, v: impl Into<String>) -> Self {
280 self.lt_coin = Some(v.into());
281 self
282 }
283 pub fn with_order_id(mut self, v: impl Into<String>) -> Self {
285 self.order_id = Some(v.into());
286 self
287 }
288 pub fn with_start_time(mut self, v: Timestamp) -> Self {
290 self.start_time = Some(v);
291 self
292 }
293 pub fn with_end_time(mut self, v: Timestamp) -> Self {
295 self.end_time = Some(v);
296 self
297 }
298 pub fn with_limit(mut self, v: u64) -> Self {
300 self.limit = Some(v);
301 self
302 }
303 pub fn with_lt_order_type(mut self, v: LtOrderType) -> Self {
305 self.lt_order_type = Some(v);
306 self
307 }
308 pub fn with_serial_no(mut self, v: impl Into<String>) -> Self {
310 self.serial_no = Some(v.into());
311 self
312 }
313}
314
315impl Default for GetLeverageTokenOrderRecordsParams {
316 fn default() -> Self {
317 Self::new()
318 }
319}
320
321#[derive(Debug, Deserialize, PartialEq)]
323#[serde(rename_all = "camelCase")]
324pub struct LeverageTokenOrderRecord {
325 pub lt_coin: String,
327 pub order_id: String,
329 pub lt_order_type: LtOrderType,
331 pub order_time: Timestamp,
333 pub update_time: Timestamp,
335 pub lt_order_status: LtOrderStatus,
337 pub fee: Decimal,
339 pub amount: Decimal,
341 pub value: Decimal,
343 pub value_coin: String,
345 #[serde(default, deserialize_with = "empty_string_as_none")]
347 pub serial_no: Option<String>,
348}