kvault-interface
Instruction builders and zero-copy account deserialization for
Kamino Vault (Kvault). No anchor-lang dependency;
targets solana-sdk v2.x.
Quick start
Add to your Cargo.toml:
[]
= { = "https://github.com/Kamino-Finance/kvault" }
= { = "https://github.com/Kamino-Finance/klend" }
= "2.1"
= "2.1"
= "~2.3"
= "2.1"
= "6"
Two-level API
The crate provides two levels of instruction building:
-
Low-level ([
instructions]): one function per Kvault instruction, returning a single [solana_instruction::Instruction]. You supply every account address manually. -
High-level ([
helpers]): workflow builders that accept [VaultInfo] / [ReserveInfo] and auto-derive PDAs and remaining accounts.
Core types
| Type | Purpose |
|---|---|
[VaultInfo] |
On-chain vault metadata; built via [VaultInfo::from_account_data]. |
[ReserveInfo] |
Klend reserve metadata needed by withdraw / invest / redeem helpers. |
[state::VaultState] |
Zero-copy deserialization of the on-chain VaultState account (62 544 bytes). |
[state::GlobalConfig] |
Zero-copy deserialization of the on-chain GlobalConfig account (1 024 bytes). |
[state::VaultAllocation] |
Per-reserve allocation slot embedded in VaultState (2 160 bytes). |
Typical flow
use ;
use Pubkey;
#
Scaled fraction fields (_sf)
All on-chain fields ending in _sf (e.g. prev_aum_sf, pending_fees_sf) are
fixed-point integers using the [Fraction] type (68 integer bits, 60 fractional bits).
Convert with Fraction::from_bits(u128_value).
Examples
The examples/ directory contains runnable examples matching the
Kamino developer documentation:
| Example | Description |
|---|---|
deposit |
Deposit tokens into a vault and receive shares. |
withdraw |
Withdraw shares from a vault to receive tokens. |
vault_data |
Fetch and inspect vault state, allocations, and AUM. |
user_position |
Read a user's share balance and compute token value. |