1use serde::{Deserialize, Serialize};
2
3use crate::ws::types::{MarketInfo, TokenInfo};
4
5#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
7#[non_exhaustive]
8pub struct Vault {
9 pub vault_pda: String,
10 pub vault_id: String,
11 pub governance: String,
12 pub fee_recipient: String,
13 pub primary_delegate: String,
14 pub main_mint: String,
15 pub second_mint: String,
16 pub share_mint: String,
17 pub main_token_program: TokenProgramKind,
18 pub second_token_program: TokenProgramKind,
19 pub main_decimals: u8,
20 pub second_decimals: u8,
21 pub phase: String,
23 pub safety: String,
25 pub capabilities: u32,
26 pub active_expiry: String,
27 pub open_positions: String,
28 pub total_shares: String,
29 pub share_price: String,
30 pub equity: String,
31 pub capital_generation: String,
32 pub accepting_deposits: bool,
33 pub equity_computed: bool,
34 pub pending_deposit_count: u32,
35 pub pending_withdraw_count: u32,
36 pub pending_deposit_amount: String,
37 pub pending_withdraw_shares: String,
38 pub performance_fee_bps: u16,
39 pub management_fee_bps: u16,
40 pub manager_stake_min_bps: u16,
41 pub share_price_hwm: String,
42 pub last_hwm_update_ts: String,
43 pub last_hwm_reset_ts: String,
44 pub last_settlement_ts: String,
45 pub cap_limit: String,
46 pub capital_fallback_delay_secs: String,
47 pub deposit_window_set_ts: Option<String>,
48 pub main_balance: Option<String>,
49 pub second_balance: Option<String>,
50 pub balance_updated_at: Option<String>,
51 pub live_share_supply: Option<String>,
52 pub observed_manager_stake_shares: Option<String>,
53 pub balance_chain_slot: Option<String>,
54 pub policy: VaultPolicy,
55 pub projection: ProjectionCursor,
56 pub performance: VaultPerformance,
57}
58
59#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
60#[non_exhaustive]
61pub enum TokenProgramKind {
62 #[serde(rename = "legacy_spl")]
63 LegacySpl,
64 #[serde(rename = "token_2022")]
65 Token2022,
66 #[serde(other)]
67 Unknown,
68}
69
70#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
71#[non_exhaustive]
72pub struct VaultPolicy {
73 pub max_open_positions: u16,
74 pub max_rebalance_drift_bps: u16,
75 pub min_main_liquidity_bps: u16,
76}
77
78#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
79#[non_exhaustive]
80pub struct ProjectionCursor {
81 pub version: String,
82 pub slot: String,
83 pub transaction_index: u32,
84 pub signature: String,
85 pub event_index: u32,
86}
87
88#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
89#[serde(tag = "status", rename_all = "snake_case")]
90#[non_exhaustive]
91pub enum VaultPerformance {
92 Unavailable,
93 NoTrackRecord,
94 ShortTrackRecord(TrackRecord),
95 Annualized {
96 #[serde(flatten)]
97 track_record: TrackRecord,
98 annualized_return_pct: f64,
99 },
100 #[serde(other)]
101 Unknown,
102}
103
104#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
105#[non_exhaustive]
106pub struct TrackRecord {
107 pub cycles_completed: u32,
108 pub last_cycle_return_pct: f64,
109 pub cumulative_return_pct: f64,
110 pub track_record_secs: String,
111}
112
113#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
115#[non_exhaustive]
116pub struct VaultPosition {
117 pub vault: String,
118 pub position: String,
119 pub order_id: String,
120 pub role: VaultPositionRole,
121 pub market: String,
122 pub position_type: VaultPositionType,
123 pub strike: String,
124 pub quantity: String,
125 pub net_premium: String,
126 pub counterparty: String,
127 pub funded_amount: Option<String>,
128 pub status: VaultPositionStatus,
129 pub is_otm: Option<bool>,
130 pub created_at: String,
131 pub acquired_at: String,
132 pub settled_at: Option<String>,
133 pub transaction_signature: Option<String>,
134}
135
136#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
137#[serde(rename_all = "snake_case")]
138#[non_exhaustive]
139pub enum VaultPositionRole {
140 Writer,
141 Holder,
142 #[serde(other)]
143 Unknown,
144}
145
146#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
147#[serde(rename_all = "snake_case")]
148#[non_exhaustive]
149pub enum VaultPositionType {
150 CoveredCall,
151 CashSecuredPut,
152 #[serde(other)]
153 Unknown,
154}
155
156#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
157#[serde(rename_all = "snake_case")]
158#[non_exhaustive]
159pub enum VaultPositionStatus {
160 Open,
161 Funded,
162 Liquidated,
163 Settled,
164 #[serde(other)]
165 Unknown,
166}
167
168#[derive(Debug, Clone, Serialize, Deserialize)]
169pub(super) struct VaultPositionsResponse {
170 pub(super) positions: Vec<VaultPosition>,
171 pub(super) next_cursor: Option<String>,
172}
173
174#[derive(Debug, Clone, Serialize, Deserialize)]
175pub(super) struct VaultsResponse {
176 pub(super) vaults: Vec<Vault>,
177}
178
179#[derive(Debug, Clone, Serialize, Deserialize)]
180pub(super) struct MarketsResponse {
181 pub(super) markets: Vec<MarketInfo>,
182}
183
184#[derive(Debug, Clone, Serialize, Deserialize)]
185pub(super) struct TokensResponse {
186 pub(super) tokens: Vec<TokenInfo>,
187}
188
189#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
191#[non_exhaustive]
192pub struct Venue {
193 pub program_id: String,
194 pub min_quote_validity_seconds: u32,
195 pub settlement_buffer_seconds: u32,
196 pub quote_refresh_lead_seconds: u32,
197 pub min_rfq_timeout_seconds: u32,
198 pub max_rfq_timeout_seconds: u32,
199 pub signature_timeout_seconds: u64,
200 pub max_quotes_per_rfq: Option<u64>,
201 pub max_active_rfqs_per_taker: Option<u64>,
202 pub pre_expiry_cutoff_seconds: u64,
203}