Skip to main content

rust_okx/api/finance/requests/
savings.rs

1use serde::Serialize;
2
3/// Request body for `POST /api/v5/finance/savings/purchase-redempt`.
4#[derive(Debug, Clone, Serialize)]
5pub struct SavingsPurchaseRedemptionRequest {
6    ccy: String,
7    amt: String,
8    side: String,
9    #[serde(skip_serializing_if = "Option::is_none")]
10    rate: Option<String>,
11}
12
13impl SavingsPurchaseRedemptionRequest {
14    /// Create a Simple Earn purchase or redemption request.
15    ///
16    /// `side` must be `purchase` or `redempt`.
17    pub fn new(ccy: impl Into<String>, amt: impl Into<String>, side: impl Into<String>) -> Self {
18        Self {
19            ccy: ccy.into(),
20            amt: amt.into(),
21            side: side.into(),
22            rate: None,
23        }
24    }
25
26    /// Set the minimum annual lending rate for a purchase.
27    ///
28    /// OKX documents the accepted range as `0.01` through `3.65` (1%–365%).
29    pub fn rate(mut self, rate: impl Into<String>) -> Self {
30        self.rate = Some(rate.into());
31        self
32    }
33}