kvault_interface/state/vault_state.rs
1use bytemuck::{Pod, Zeroable};
2use solana_pubkey::Pubkey;
3use spl_discriminator::SplDiscriminate;
4
5use super::pod::PodU128;
6
7use super::{VaultAllocation, VaultRewardInfo};
8use crate::MAX_RESERVES;
9
10/// Kamino Vault account state.
11#[derive(Debug, Clone, Copy, Pod, Zeroable, SplDiscriminate)]
12#[discriminator_hash_input("account:VaultState")]
13#[repr(C)]
14pub struct VaultState {
15 /// Wallet authorised to manage the vault (update config, allocations, etc.).
16 pub vault_admin_authority: Pubkey,
17
18 /// PDA that signs CPI calls on behalf of the vault.
19 pub base_vault_authority: Pubkey,
20 /// Bump seed for [`base_vault_authority`](Self::base_vault_authority).
21 pub base_vault_authority_bump: u64,
22
23 /// SPL token mint for the vault's underlying asset (e.g. USDC).
24 pub token_mint: Pubkey,
25 /// Decimal places of [`token_mint`](Self::token_mint).
26 pub token_mint_decimals: u64,
27 /// Token account holding the vault's uninvested (available) liquidity.
28 pub token_vault: Pubkey,
29 /// Token program for [`token_mint`](Self::token_mint) (`TOKEN_PROGRAM_ID` or Token-2022).
30 pub token_program: Pubkey,
31
32 /// SPL mint for vault share tokens issued to depositors.
33 pub shares_mint: Pubkey,
34 /// Decimal places of [`shares_mint`](Self::shares_mint).
35 pub shares_mint_decimals: u64,
36
37 /// Amount of underlying tokens currently available (not invested).
38 pub token_available: u64,
39 /// Total vault share tokens currently outstanding.
40 pub shares_issued: u64,
41
42 /// Tokens reserved for crank operation fees.
43 pub available_crank_funds: u64,
44 /// Weight assigned to the unallocated (idle) portion of the vault.
45 pub unallocated_weight: u64,
46
47 /// Performance fee rate in basis points.
48 pub performance_fee_bps: u64,
49 /// Annual management fee rate in basis points.
50 pub management_fee_bps: u64,
51 /// Unix timestamp of the last fee charge.
52 pub last_fee_charge_timestamp: u64,
53 /// Previous assets under management as a scaled fraction ([`Fraction`](crate::Fraction)).
54 pub prev_aum_sf: PodU128,
55 /// Accrued but uncollected fees as a scaled fraction ([`Fraction`](crate::Fraction)).
56 pub pending_fees_sf: PodU128,
57
58 /// Per-reserve allocation slots. Active reserves have a non-default `reserve` pubkey.
59 pub vault_allocation_strategy: [VaultAllocation; MAX_RESERVES],
60 /// Reserved for future use.
61 pub padding_1: [PodU128; 256],
62
63 /// Minimum token amount accepted for a deposit.
64 pub min_deposit_amount: u64,
65 /// Minimum share amount accepted for a withdrawal.
66 pub min_withdraw_amount: u64,
67 /// Minimum token amount for an invest operation.
68 pub min_invest_amount: u64,
69 /// Minimum number of slots between consecutive invest calls.
70 pub min_invest_delay_slots: u64,
71 /// Crank fee charged per reserve during invest operations.
72 pub crank_fund_fee_per_reserve: u64,
73
74 /// Wallet that has been nominated as the next admin (two-step transfer).
75 pub pending_admin: Pubkey,
76
77 /// Cumulative interest earned by the vault, scaled fraction.
78 pub cumulative_earned_interest_sf: PodU128,
79 /// Cumulative management fees collected, scaled fraction.
80 pub cumulative_mgmt_fees_sf: PodU128,
81 /// Cumulative performance fees collected, scaled fraction.
82 pub cumulative_perf_fees_sf: PodU128,
83
84 /// Human-readable vault name (UTF-8, up to 40 bytes).
85 pub name: [u8; 40],
86 /// Address lookup table for the vault's accounts.
87 pub vault_lookup_table: Pubkey,
88 /// Kamino Farms state for the vault's share token farm.
89 pub vault_farm: Pubkey,
90
91 /// Unix timestamp when the vault was created.
92 pub creation_timestamp: u64,
93
94 /// Maximum amount of tokens that can remain unallocated.
95 pub unallocated_tokens_cap: u64,
96 /// Wallet authorised to manage allocations (may differ from [`vault_admin_authority`](Self::vault_admin_authority)).
97 pub allocation_admin: Pubkey,
98
99 /// Flat withdrawal penalty in lamports.
100 pub withdrawal_penalty_lamports: u64,
101 /// Withdrawal penalty in basis points.
102 pub withdrawal_penalty_bps: u64,
103
104 /// Farm state for first-loss capital providers.
105 pub first_loss_capital_farm: Pubkey,
106
107 /// When non-zero, allocations are restricted to whitelisted reserves only.
108 pub allow_allocations_in_whitelisted_reserves_only: u8,
109 /// When non-zero, invest is restricted to whitelisted reserves only.
110 pub allow_invest_in_whitelisted_reserves_only: u8,
111
112 /// Reserved for future use.
113 pub padding_2: [u8; 6],
114 /// Total vault deposit cap; `0` means uncapped (for backward compatibility).
115 /// This is a soft cap that only blocks new deposits — the vault AUM can still
116 /// grow above it through earned interest.
117 pub deposit_cap: u64,
118 /// Reward distribution state ([`VaultRewardInfo`]).
119 pub reward_info: VaultRewardInfo,
120 /// Reserved for future use.
121 pub padding_3: [PodU128; 232],
122}
123
124const _: () = assert!(core::mem::size_of::<VaultState>() == 62544);