Skip to main content

bpx_api_types/
vault.rs

1use chrono::{DateTime, Utc};
2use rust_decimal::Decimal;
3use serde::{Deserialize, Serialize};
4
5/// Public vault information.
6#[derive(Debug, Clone, Serialize, Deserialize)]
7#[serde(rename_all = "camelCase")]
8pub struct Vault {
9    /// Unique identifier for the vault.
10    pub id: u32,
11    /// The asset that represents shares in this vault.
12    pub vault_token: String,
13    /// The symbol used for minting and redeeming vault tokens.
14    pub symbol: String,
15    /// Whether the vault is currently accepting mints.
16    pub mints_enabled: bool,
17    /// Whether the vault is currently allowing redeems.
18    pub redeems_enabled: bool,
19    /// Minimum quantity required to mint vault tokens.
20    pub min_mint_quantity: Decimal,
21    /// Minimum vault token amount required to redeem.
22    pub min_redeem_tokens: Decimal,
23    /// Minimum delay (in milliseconds) between redeem request and execution.
24    pub redeem_delay_ms: i64,
25    /// Step size for vault token quantities.
26    pub token_step_size: Decimal,
27}
28
29/// Request payload for minting vault tokens.
30#[derive(Debug, Clone, Serialize, Deserialize)]
31#[serde(rename_all = "camelCase")]
32pub struct VaultMintRequest {
33    /// The vault ID to mint tokens from.
34    pub vault_id: u32,
35    /// The symbol of the asset to deposit.
36    pub symbol: String,
37    /// Amount to deposit.
38    pub quantity: Decimal,
39    /// Whether to allow auto borrowing when depositing into vault.
40    pub auto_borrow: Option<bool>,
41    /// Whether to allow auto redeem lent assets when depositing into vault.
42    pub auto_lend_redeem: Option<bool>,
43}
44
45/// Request payload for redeeming vault tokens.
46#[derive(Debug, Clone, Serialize, Deserialize)]
47#[serde(rename_all = "camelCase")]
48pub struct VaultRedeemRequest {
49    /// The vault ID to redeem from.
50    pub vault_id: u32,
51    /// Amount of vault tokens to deposit to redeem USDC.
52    /// If not specified, uses all available vault tokens for the redemptions.
53    pub vault_token_quantity: Option<Decimal>,
54}
55
56/// Request payload for canceling a vault redeem request.
57#[derive(Debug, Clone, Serialize, Deserialize)]
58#[serde(rename_all = "camelCase")]
59pub struct VaultRedeemCancelRequest {
60    /// The vault ID to cancel the redeem request for.
61    pub vault_id: u32,
62}
63
64/// Historical vault data.
65#[derive(Debug, Clone, Serialize, Deserialize)]
66#[serde(rename_all = "camelCase")]
67pub struct VaultHistory {
68    /// The vault ID.
69    pub vault_id: u32,
70    /// Timestamp of the snapshot.
71    pub timestamp: DateTime<Utc>,
72    /// Net asset value per token.
73    pub nav: Option<Decimal>,
74    /// Total vault equity in USDC.
75    pub vault_equity: Option<Decimal>,
76    /// Total circulating vault tokens.
77    pub token_circulating_supply: Option<Decimal>,
78}
79
80/// Time interval for vault history data.
81#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
82#[serde(rename_all = "camelCase")]
83pub enum VaultHistoryInterval {
84    #[serde(rename = "1d")]
85    OneDay,
86    #[serde(rename = "1w")]
87    OneWeek,
88    #[serde(rename = "1month")]
89    OneMonth,
90    #[serde(rename = "1year")]
91    OneYear,
92}
93
94/// Parameters for fetching vault history.
95#[derive(Debug, Clone, Serialize, Deserialize)]
96#[serde(rename_all = "camelCase")]
97pub struct VaultHistoryParams {
98    /// Time interval for historical data.
99    pub interval: VaultHistoryInterval,
100    /// Optional vault ID to filter by.
101    #[serde(skip_serializing_if = "Option::is_none")]
102    pub vault_id: Option<u32>,
103}
104
105#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
106pub enum VaultRedeemStatus {
107    Requested,
108    Redeemed,
109    Cancelled,
110}
111
112#[derive(Debug, Clone, Serialize, Deserialize)]
113#[serde(rename_all = "camelCase")]
114pub struct VaultRedeem {
115    pub status: VaultRedeemStatus,
116    pub id: String,
117    pub vault_id: u32,
118    pub vault_token_quantity: Decimal,
119    pub vault_token: Option<String>,
120    pub symbol: Option<String>,
121    pub quantity: Option<Decimal>,
122    pub nav: Option<Decimal>,
123    pub reason: Option<String>,
124    pub timestamp: i64,
125}