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    /// Remaining vault tokens available to mint.
28    pub remaining_mint_quantity: Decimal,
29}
30
31/// Request payload for minting vault tokens.
32#[derive(Debug, Clone, Serialize, Deserialize)]
33#[serde(rename_all = "camelCase")]
34pub struct VaultMintRequest {
35    /// The vault ID to mint tokens from.
36    pub vault_id: u32,
37    /// The symbol of the asset to deposit.
38    pub symbol: String,
39    /// Amount to deposit.
40    pub quantity: Decimal,
41    /// Whether to allow auto borrowing when depositing into vault.
42    pub auto_borrow: Option<bool>,
43    /// Whether to allow auto redeem lent assets when depositing into vault.
44    pub auto_lend_redeem: Option<bool>,
45}
46
47/// Request payload for redeeming vault tokens.
48#[derive(Debug, Clone, Serialize, Deserialize)]
49#[serde(rename_all = "camelCase")]
50pub struct VaultRedeemRequest {
51    /// The vault ID to redeem from.
52    pub vault_id: u32,
53    /// Amount of vault tokens to deposit to redeem USDC.
54    /// If not specified, uses all available vault tokens for the redemptions.
55    pub vault_token_quantity: Option<Decimal>,
56}
57
58/// Vault mint event from history.
59#[derive(Debug, Clone, Serialize, Deserialize)]
60#[serde(rename_all = "camelCase")]
61pub struct VaultMint {
62    /// Unique identifier for the mint event.
63    pub id: String,
64    /// Vault ID.
65    pub vault_id: u32,
66    /// The vault token asset.
67    pub vault_token: String,
68    /// The symbol used for minting.
69    pub symbol: String,
70    /// Amount deposited.
71    pub quantity: Decimal,
72    /// Number of vault tokens received.
73    pub vault_tokens_minted: Decimal,
74    /// NAV at time of mint.
75    pub nav: Decimal,
76    /// Timestamp of the mint in milliseconds.
77    pub timestamp: i64,
78}
79
80/// Request payload for canceling a vault redeem request.
81#[derive(Debug, Clone, Serialize, Deserialize)]
82#[serde(rename_all = "camelCase")]
83pub struct VaultRedeemCancelRequest {
84    /// The vault ID to cancel the redeem request for.
85    pub vault_id: u32,
86}
87
88/// Historical vault data.
89#[derive(Debug, Clone, Serialize, Deserialize)]
90#[serde(rename_all = "camelCase")]
91pub struct VaultHistory {
92    /// The vault ID.
93    pub vault_id: u32,
94    /// Timestamp of the snapshot.
95    pub timestamp: DateTime<Utc>,
96    /// Net asset value per token.
97    pub nav: Option<Decimal>,
98    /// Total vault equity in USDC.
99    pub vault_equity: Option<Decimal>,
100    /// Total circulating vault tokens.
101    pub token_circulating_supply: Option<Decimal>,
102}
103
104/// Time interval for vault history data.
105#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize)]
106#[serde(rename_all = "camelCase")]
107pub enum VaultHistoryInterval {
108    #[serde(rename = "1d")]
109    OneDay,
110    #[serde(rename = "1w")]
111    OneWeek,
112    #[serde(rename = "1month")]
113    OneMonth,
114    #[serde(rename = "1year")]
115    OneYear,
116}
117
118/// Parameters for fetching vault history.
119#[derive(Debug, Clone, Serialize, Deserialize)]
120#[serde(rename_all = "camelCase")]
121pub struct VaultHistoryParams {
122    /// Time interval for historical data.
123    pub interval: VaultHistoryInterval,
124    /// Optional vault ID to filter by.
125    #[serde(skip_serializing_if = "Option::is_none")]
126    pub vault_id: Option<u32>,
127}
128
129/// Parameters for fetching vault mint history.
130#[derive(Debug, Clone, Default, Serialize, Deserialize)]
131#[serde(rename_all = "camelCase")]
132pub struct VaultMintHistoryParams {
133    /// Filter for a subaccount.
134    #[serde(skip_serializing_if = "Option::is_none")]
135    pub subaccount_id: Option<i32>,
136    /// Filter to a specific vault.
137    #[serde(skip_serializing_if = "Option::is_none")]
138    pub vault_id: Option<u32>,
139    /// Maximum number to return. Default 100, maximum 1000.
140    #[serde(skip_serializing_if = "Option::is_none")]
141    pub limit: Option<u64>,
142    /// Offset. Default 0.
143    #[serde(skip_serializing_if = "Option::is_none")]
144    pub offset: Option<u64>,
145}
146
147/// Parameters for fetching vault redeem history.
148#[derive(Debug, Clone, Default, Serialize, Deserialize)]
149#[serde(rename_all = "camelCase")]
150pub struct VaultRedeemHistoryParams {
151    /// Filter for a subaccount.
152    #[serde(skip_serializing_if = "Option::is_none")]
153    pub subaccount_id: Option<i32>,
154    /// Filter to a specific vault.
155    #[serde(skip_serializing_if = "Option::is_none")]
156    pub vault_id: Option<u32>,
157    /// Maximum number to return. Default 100, maximum 1000.
158    #[serde(skip_serializing_if = "Option::is_none")]
159    pub limit: Option<u64>,
160    /// Offset. Default 0.
161    #[serde(skip_serializing_if = "Option::is_none")]
162    pub offset: Option<u64>,
163}
164
165#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
166pub enum VaultRedeemStatus {
167    Requested,
168    Redeemed,
169    Cancelled,
170}
171
172#[derive(Debug, Clone, Serialize, Deserialize)]
173#[serde(rename_all = "camelCase")]
174pub struct VaultRedeem {
175    pub status: VaultRedeemStatus,
176    pub id: String,
177    pub vault_id: u32,
178    pub vault_token_quantity: Decimal,
179    pub vault_token: Option<String>,
180    pub symbol: Option<String>,
181    pub quantity: Option<Decimal>,
182    pub nav: Option<Decimal>,
183    pub reason: Option<String>,
184    pub timestamp: i64,
185}