Skip to main content

bucks_api/state/
vault.rs

1use serde::{Deserialize, Serialize};
2use steel::*;
3
4use super::BucksAccount;
5
6/// Vault - Global state for the Bucks protocol.
7/// Manages all deposited USDC across multiple yield protocols.
8///
9/// Invariant: total_deposits == sum(all Stable.total_deposits)
10/// Invariant: total_deposits == sum(all ProtocolRegistry.receipt_token_balance * exchange_rate) - yield
11#[repr(C)]
12#[derive(Clone, Copy, Debug, PartialEq, Pod, Zeroable, Serialize, Deserialize)]
13pub struct Vault {
14    /// The admin authority that can manage the vault.
15    pub admin: Pubkey,
16
17    /// Treasury address where platform fees are collected.
18    pub treasury: Pubkey,
19
20    /// The total amount of USDC currently deposited across all protocols.
21    /// This is a cached sum of all Stable.total_deposits.
22    pub total_deposits: u64,
23
24    /// Unix timestamp of last checkpoint update.
25    pub last_checkpoint: i64,
26
27    /// The total amount of yield claimed over the lifetime of the program.
28    pub lifetime_yield: u64,
29
30    /// Platform fee in basis points (1000 = 10%).
31    pub platform_fee_bps: u16,
32
33    /// The primary protocol ID where new deposits are routed.
34    pub primary_protocol: u8,
35
36    /// Emergency pause flag (0 = active, 1 = paused).
37    pub paused: u8,
38
39    /// Number of active protocols registered.
40    pub protocol_count: u8,
41
42    /// Padding for alignment to 8-byte boundary.
43    pub _padding: [u8; 3],
44}
45
46account!(BucksAccount, Vault);