Skip to main content

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.
1

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.
getMarketInfo
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 Code
2

Get Reserve Info

Queries detailed information for all reserves in the market including deposit/borrow TVL, APY rates, and utilization ratios.
getReserveInfo
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 Code

Additional Resources