Documentation Index
Fetch the complete documentation index at: https://kamino.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Reading Market Data
Retrieve market metrics, reserve information, and TVL data using the Kamino SDK and API.
Historical market data is only available via the API.
Get Market Info
Retrieves real-time market-wide metrics including total deposits and borrows TVL across all reserves.Using the SDK requires a private RPC connection or the public rate-limited
RPC endpoint. import { createSolanaRpc, address } from "@solana/kit";
import { KaminoMarket } from "@kamino-finance/klend-sdk";
const slotDuration = 400; // ms
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const marketPubkey = address("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF");
const market = await KaminoMarket.load(rpc, marketPubkey, slotDuration);
console.log({
deposits: market!.getTotalDepositTVL(),
borrows: market!.getTotalBorrowTVL(),
});
View CodeGet Reserve Info
Queries detailed information for all reserves in the market including deposit/borrow TVL, APY rates, and utilization ratios.import { createSolanaRpc, address } from "@solana/kit";
import { KaminoMarket } from "@kamino-finance/klend-sdk";
const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
const marketPubkey = address("DxXdAyU3kCjnyggvHmY5nAwg5cRbbmdyX3npfDMjjMek");
const slotDuration = 400; // ms
const slot = await rpc.getSlot().send();
const market = await KaminoMarket.load(rpc, marketPubkey, slotDuration);
for (const reserve of market!.getReserves()) {
console.log(`Reserve ${reserve.symbol}:`);
console.log(` Deposit TVL: ${reserve.getDepositTvl().toFixed(2)}`);
console.log(` Borrow TVL: ${reserve.getBorrowTvl().toFixed(2)}`);
console.log(` Borrow APY: ${reserve.totalBorrowAPY(slot)}%`);
console.log(` Supply APY: ${reserve.totalSupplyAPY(slot)}%`);
console.log(` Utilization: ${reserve.calculateUtilizationRatio()}%`);
}
View Codeget_market_and_reserves.rs
// Additional deps: klend-interface = "0.1.0", solana-client = "~2.3",
// solana-pubkey = "2.1", solana-account = "2.1", fixed = "1"
use klend_interface::accounts::from_account_data;
use klend_interface::state::{LendingMarket, Reserve};
use klend_interface::KLEND_PROGRAM_ID;
use solana_client::rpc_client::RpcClient;
use solana_client::rpc_config::RpcProgramAccountsConfig;
use solana_client::rpc_filter::{Memcmp, RpcFilterType};
use solana_account::ReadableAccount;
use solana_pubkey::Pubkey;
use fixed::types::U68F60;
use std::str::FromStr;
let rpc_client = RpcClient::new("https://api.mainnet-beta.solana.com");
let market_pubkey = Pubkey::from_str("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF").unwrap();
// Fetch and parse the lending market
let market_account = rpc_client.get_account(&market_pubkey)?;
let market = from_account_data::<LendingMarket>(&market_account.data)?;
println!("Market authority: {}", market.lending_market_owner);
// Fetch all reserves for this market using memcmp filter
let filters = vec![
RpcFilterType::Memcmp(Memcmp::new_raw_bytes(32, market_pubkey.to_bytes().to_vec())),
RpcFilterType::DataSize(8616),
];
let accounts = rpc_client.get_program_accounts_with_config(
&KLEND_PROGRAM_ID,
RpcProgramAccountsConfig { filters: Some(filters), ..Default::default() },
)?;
// Parse each reserve and print key metrics
// Fields suffixed with `_sf` are scaled fractions — use the `fixed` crate for precise conversion
for (pubkey, account) in &accounts {
let reserve = from_account_data::<Reserve>(account.data())?;
let borrowed = U68F60::from_bits(reserve.liquidity.borrowed_amount_sf as u128);
let price = U68F60::from_bits(reserve.liquidity.market_price_sf as u128);
println!("Reserve: {pubkey}");
println!(" Available liquidity: {}", reserve.liquidity.available_amount);
println!(" Borrowed amount: {borrowed}");
println!(" Market price: {price}");
println!(" Mint decimals: {}", reserve.liquidity.mint_decimals);
println!(" LTV: {}%", reserve.config.loan_to_value_pct);
println!(" Deposit limit: {}", reserve.config.deposit_limit);
println!(" Borrow limit: {}", reserve.config.borrow_limit);
}
View CodeGet Historical Reserve APY
Fetch historical supply APY and borrow APY data for a specific reserve over time.const API_BASE_URL = "https://api.kamino.finance";
const marketPubkey = "7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF";
const reservePubkey = "d4A2prbA2whesmvHaL88BH6Ewn5N4bTSU2Ze8P6Bc4Q";
const url = `${API_BASE_URL}/kamino-market/${marketPubkey}/reserves/${reservePubkey}/metrics/history`;
const res = await fetch(url);
if (!res.ok) {
throw new Error(`Request failed: ${res.status} ${res.statusText}`);
}
const { history } = await res.json();
for (const item of history) {
console.log({
timestamp: item.timestamp,
symbol: item.metrics.symbol,
supplyInterestAPY: item.metrics.supplyInterestAPY,
borrowInterestAPY: item.metrics.borrowInterestAPY,
depositTvl: item.metrics.depositTvl,
borrowTvl: item.metrics.borrowTvl,
});
}
View Code
Additional Resources