Skip to main content

Overview

Integrating Kamino’s Earn vaults lets users supply tokens to curated lending strategies on Solana. Deposits are routed to lending markets according to the vault configuration, and interest from borrowers becomes yield for depositors. On deposit, users receive share tokens representing their position. If the vault has a farm attached, shares are automatically staked in the farm and are not visible in the user’s wallet. If the vault has no farm, shares remain in the user’s wallet.

Key Components of Earn Integration

Vault Operations

Deposit, withdraw, and track user positions in the Lend program.

Yield Tracking

Read APY and performance from the public API or on-chain accounts, present recent and longer windows.

Ways to Fetch Data

Public API

Simplest source for vault lists, APY, TVL, status.

SDK

Helpers to deposit, withdraw, and read user positions.

Deposit

import { createSolanaRpc, address, createNoopSigner } from '@solana/kit';
import { KaminoVault } from '@kamino-finance/klend-sdk';
import { Decimal } from 'decimal.js';

const vault = new KaminoVault(
  createSolanaRpc('https://api.mainnet-beta.solana.com'), // RPC
  address('HDsayqAsDWy3QvANGqh2yNraqcD8Fnjgh73Mhb3WRS5E') // USDC vault
);

const user = await parseKeypairFile(signer as string);
const multisigUser = createNoopSigner(address('EZC9wzVCvihCsCHEMGADYdsRhcpdRYWzSCZAVegSCfqY'));
const depositIxs = await vault.depositIxs(
  user, // user (a local keypair) or multisigUser (a multisig, cannot sign directly), type TransactionSigner
  new Decimal(100.0) // 100 USDC tokens
);

console.log('Deposit Instructions:', depositIxs);
View Code
For the full deposit example, including transaction sending and confirmation, check out Deposit Operations.

Withdraw

import { createSolanaRpc, address, createNoopSigner } from '@solana/kit';
import { KaminoVault } from '@kamino-finance/klend-sdk';
import { Decimal } from 'decimal.js';

const vault = new KaminoVault(
  createSolanaRpc('https://api.mainnet-beta.solana.com'), // RPC
  address('HDsayqAsDWy3QvANGqh2yNraqcD8Fnjgh73Mhb3WRS5E') // USDC vault
);

const user = await parseKeypairFile(signer as string);
const multisigUser = createNoopSigner(address('EZC9wzVCvihCsCHEMGADYdsRhcpdRYWzSCZAVegSCfqY'));
const withdrawIxs = await vault.withdrawIxs(
  user, // user (a local keypair) or multisigUser (a multisig, cannot sign directly), type TransactionSigner
  new Decimal(1.5) // withdraw 1.5 shares
);

console.log('Withdraw Instructions:', withdrawIxs);
View Code
For the full withdraw example, including transaction sending and confirmation, check out Withdraw Operations.

Key Data Structures

VaultState
class VaultState {
  tokenMint: Address
  tokenVault: Address
  sharesMint: Address
  tokenAvailable: BN
  sharesIssued: BN
  performanceFeeBps: BN
  managementFeeBps: BN
  vaultAllocationStrategy: Array<VaultAllocation>
  unallocatedTokensCap: BN
  unallocatedWeight: BN
  minDepositAmount: BN
  withdrawalPenaltyLamports: BN
  withdrawalPenaltyBps: BN
  cumulativeEarnedInterestSf: BN
  cumulativeMgmtFeesSf: BN
  cumulativePerfFeesSf: BN
  name: Array<number>
  vaultFarm: Address
  creationTimestamp: BN
  allowAllocationsInWhitelistedReservesOnly: Boolean
  allowInvestInWhitelistedReservesOnly: Boolean
}
View Full Typescript VaultState