pub struct VaultInfo {
pub address: Pubkey,
pub token_mint: Pubkey,
pub token_program: Pubkey,
/* private fields */
}Expand description
On-chain vault data that cannot be derived from PDAs.
The caller reads these fields from the deserialized VaultState account.
Vault PDAs (authority, token vault, shares mint) and remaining accounts
are derived automatically by the helpers.
§Reserve slot-ordering contract
reserves mirrors the on-chain non-empty
vault_allocation_strategy[] slots in slot order. The on-chain refresh
check (check_allocation_reserves_refreshed) walks the refresh remaining
accounts in exactly that order, so the order must be preserved. The
constructors enforce this by re-deriving the order from the allocation
strategy regardless of the order in which reserve data is supplied, so the
refresh check cannot be violated through this type.
Fields§
§address: PubkeyVault account address.
token_mint: PubkeySPL token mint for the vault’s underlying asset (e.g. USDC).
token_program: PubkeyToken program for token_mint (TOKEN_PROGRAM_ID or Token-2022).
Implementations§
Source§impl VaultInfo
impl VaultInfo
Sourcepub fn active_reserve_addresses(vault: &VaultState) -> Vec<Pubkey>
pub fn active_reserve_addresses(vault: &VaultState) -> Vec<Pubkey>
Addresses of the reserves with active allocations, in
vault_allocation_strategy[] slot order.
Use this to learn which reserve accounts to fetch before building a
VaultInfo (the lending markets needed by the constructors live on
those reserve accounts).
Sourcepub fn from_vault_state(
address: Pubkey,
vault: &VaultState,
reserves: &[ReserveInfo],
) -> Result<Self, VaultInfoError>
pub fn from_vault_state( address: Pubkey, vault: &VaultState, reserves: &[ReserveInfo], ) -> Result<Self, VaultInfoError>
Build from a deserialized VaultState and the fetched reserve data.
The reserve+lending-market list is built by iterating the active
allocations in slot order and looking up the matching ReserveInfo
by address, so the order of reserves does not matter. Returns
VaultInfoError::MissingReserve if any active allocation reserve has
no matching ReserveInfo.
Sourcepub fn from_account_data(
address: Pubkey,
data: &[u8],
reserves: &[ReserveInfo],
) -> Result<Self, VaultInfoError>
pub fn from_account_data( address: Pubkey, data: &[u8], reserves: &[ReserveInfo], ) -> Result<Self, VaultInfoError>
Build from raw account bytes (includes 8-byte discriminator) and the fetched reserve data.
See from_vault_state for the slot-ordering
contract and the reserves lookup semantics.
Sourcepub fn reserves(&self) -> &[VaultReserve]
pub fn reserves(&self) -> &[VaultReserve]
Active allocations (reserve + lending market) in
vault_allocation_strategy[] slot order.
The order mirrors the on-chain non-empty allocation slots and is enforced by the constructors (see the type-level docs), so it is safe to use directly to build the refresh remaining accounts.
Sourcepub fn reserve_addresses(&self) -> impl Iterator<Item = Pubkey> + '_
pub fn reserve_addresses(&self) -> impl Iterator<Item = Pubkey> + '_
Addresses of the reserves with active allocations, in slot order.
Convenience iterator for read-only consumers that only need the reserve pubkeys.