rust_okx/api/finance/requests/
staking.rs1use serde::Serialize;
2
3#[derive(Debug, Clone, Default, Serialize)]
5pub struct StakingDefiOffersRequest {
6 #[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
7 product_id: Option<String>,
8 #[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
9 protocol_type: Option<String>,
10 #[serde(skip_serializing_if = "Option::is_none")]
11 ccy: Option<String>,
12}
13
14impl StakingDefiOffersRequest {
15 pub fn new() -> Self {
17 Self::default()
18 }
19
20 pub fn product_id(mut self, value: impl Into<String>) -> Self {
22 self.product_id = Some(value.into());
23 self
24 }
25
26 pub fn protocol_type(mut self, value: impl Into<String>) -> Self {
28 self.protocol_type = Some(value.into());
29 self
30 }
31
32 pub fn currency(mut self, value: impl Into<String>) -> Self {
34 self.ccy = Some(value.into());
35 self
36 }
37}
38
39#[derive(Debug, Clone, Serialize)]
41pub struct StakingDefiInvestment {
42 ccy: String,
43 amt: String,
44}
45
46impl StakingDefiInvestment {
47 pub fn new(ccy: impl Into<String>, amt: impl Into<String>) -> Self {
49 Self {
50 ccy: ccy.into(),
51 amt: amt.into(),
52 }
53 }
54}
55
56#[derive(Debug, Clone, Serialize)]
58pub struct StakingDefiPurchaseRequest {
59 #[serde(rename = "productId")]
60 product_id: String,
61 #[serde(rename = "investData")]
62 invest_data: Vec<StakingDefiInvestment>,
63 #[serde(skip_serializing_if = "Option::is_none")]
64 term: Option<String>,
65 #[serde(skip_serializing_if = "Option::is_none")]
66 tag: Option<String>,
67}
68
69impl StakingDefiPurchaseRequest {
70 pub fn new(product_id: impl Into<String>, invest_data: Vec<StakingDefiInvestment>) -> Self {
72 Self {
73 product_id: product_id.into(),
74 invest_data,
75 term: None,
76 tag: None,
77 }
78 }
79
80 pub fn term(mut self, value: impl Into<String>) -> Self {
82 self.term = Some(value.into());
83 self
84 }
85
86 pub fn tag(mut self, value: impl Into<String>) -> Self {
88 self.tag = Some(value.into());
89 self
90 }
91}
92
93#[derive(Debug, Clone, Serialize)]
95pub struct StakingDefiRedeemRequest {
96 #[serde(rename = "ordId")]
97 ord_id: String,
98 #[serde(rename = "protocolType")]
99 protocol_type: String,
100 #[serde(rename = "allowEarlyRedeem", skip_serializing_if = "Option::is_none")]
101 allow_early_redeem: Option<bool>,
102}
103
104impl StakingDefiRedeemRequest {
105 pub fn new(ord_id: impl Into<String>, protocol_type: impl Into<String>) -> Self {
107 Self {
108 ord_id: ord_id.into(),
109 protocol_type: protocol_type.into(),
110 allow_early_redeem: None,
111 }
112 }
113
114 pub fn allow_early_redeem(mut self, value: bool) -> Self {
116 self.allow_early_redeem = Some(value);
117 self
118 }
119}
120
121#[derive(Debug, Clone, Serialize)]
123pub struct StakingDefiCancelRequest {
124 #[serde(rename = "ordId")]
125 ord_id: String,
126 #[serde(rename = "protocolType")]
127 protocol_type: String,
128}
129
130impl StakingDefiCancelRequest {
131 pub fn new(ord_id: impl Into<String>, protocol_type: impl Into<String>) -> Self {
133 Self {
134 ord_id: ord_id.into(),
135 protocol_type: protocol_type.into(),
136 }
137 }
138}
139
140#[derive(Debug, Clone, Default, Serialize)]
142pub struct StakingDefiActiveOrdersRequest {
143 #[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
144 product_id: Option<String>,
145 #[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
146 protocol_type: Option<String>,
147 #[serde(skip_serializing_if = "Option::is_none")]
148 ccy: Option<String>,
149 #[serde(skip_serializing_if = "Option::is_none")]
150 state: Option<String>,
151}
152
153impl StakingDefiActiveOrdersRequest {
154 pub fn new() -> Self {
156 Self::default()
157 }
158
159 pub fn product_id(mut self, value: impl Into<String>) -> Self {
161 self.product_id = Some(value.into());
162 self
163 }
164
165 pub fn protocol_type(mut self, value: impl Into<String>) -> Self {
167 self.protocol_type = Some(value.into());
168 self
169 }
170
171 pub fn currency(mut self, value: impl Into<String>) -> Self {
173 self.ccy = Some(value.into());
174 self
175 }
176
177 pub fn state(mut self, value: impl Into<String>) -> Self {
179 self.state = Some(value.into());
180 self
181 }
182}
183
184#[derive(Debug, Clone, Default, Serialize)]
186pub struct StakingDefiOrderHistoryRequest {
187 #[serde(rename = "productId", skip_serializing_if = "Option::is_none")]
188 product_id: Option<String>,
189 #[serde(rename = "protocolType", skip_serializing_if = "Option::is_none")]
190 protocol_type: Option<String>,
191 #[serde(skip_serializing_if = "Option::is_none")]
192 ccy: Option<String>,
193 #[serde(skip_serializing_if = "Option::is_none")]
194 after: Option<String>,
195 #[serde(skip_serializing_if = "Option::is_none")]
196 before: Option<String>,
197 #[serde(skip_serializing_if = "Option::is_none")]
198 limit: Option<u32>,
199}
200
201impl StakingDefiOrderHistoryRequest {
202 pub fn new() -> Self {
204 Self::default()
205 }
206
207 pub fn product_id(mut self, value: impl Into<String>) -> Self {
209 self.product_id = Some(value.into());
210 self
211 }
212
213 pub fn protocol_type(mut self, value: impl Into<String>) -> Self {
215 self.protocol_type = Some(value.into());
216 self
217 }
218
219 pub fn currency(mut self, value: impl Into<String>) -> Self {
221 self.ccy = Some(value.into());
222 self
223 }
224
225 pub fn after(mut self, value: impl Into<String>) -> Self {
227 self.after = Some(value.into());
228 self
229 }
230
231 pub fn before(mut self, value: impl Into<String>) -> Self {
233 self.before = Some(value.into());
234 self
235 }
236
237 pub fn limit(mut self, value: u32) -> Self {
239 self.limit = Some(value);
240 self
241 }
242}