kamino

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Kamino Finance Development Guide

Kamino Finance 开发指南

Build sophisticated DeFi applications on Solana with Kamino Finance - the comprehensive DeFi protocol offering lending, borrowing, automated liquidity management, leverage trading, and oracle aggregation.
借助Kamino Finance在Solana上构建复杂的DeFi应用——这是一款全面的DeFi协议,提供借贷、自动化流动性管理、杠杆交易和预言机聚合功能。

Overview

概述

Kamino Finance provides:
  • Kamino Lend (K-Lend): Lending and borrowing protocol with isolated markets
  • Kamino Liquidity (K-Liquidity): Automated CLMM liquidity management strategies
  • Scope Oracle: Oracle price aggregator for reliable pricing
  • Multiply/Leverage: Leveraged long/short positions on assets
  • Vaults: Yield-generating vault strategies
  • Obligation Orders: Automated LTV-based and price-based order execution
Kamino Finance 提供以下功能:
  • Kamino Lend(K-Lend): 具备独立市场的借贷协议
  • Kamino Liquidity(K-Liquidity): 自动化CLMM流动性管理策略
  • Scope Oracle: 提供可靠定价的预言机价格聚合器
  • 杠杆/倍数操作: 资产杠杆做多/空头寸
  • 金库: 生息金库策略
  • 债务订单: 基于LTV和价格阈值的自动化订单执行

Quick Start

快速开始

Installation

安装

bash
undefined
bash
undefined

Lending SDK

借贷SDK

npm install @kamino-finance/klend-sdk
npm install @kamino-finance/klend-sdk

Liquidity SDK

流动性SDK

npm install @kamino-finance/kliquidity-sdk
npm install @kamino-finance/kliquidity-sdk

Oracle SDK

预言机SDK

npm install @kamino-finance/scope-sdk
npm install @kamino-finance/scope-sdk

Required peer dependencies

必需的对等依赖

npm install @solana/web3.js @coral-xyz/anchor decimal.js
undefined
npm install @solana/web3.js @coral-xyz/anchor decimal.js
undefined

Environment Setup

环境配置

bash
undefined
bash
undefined

.env file

.env 文件

SOLANA_RPC_URL=https://api.mainnet-beta.solana.com WALLET_KEYPAIR_PATH=./keypair.json
undefined
SOLANA_RPC_URL=https://api.mainnet-beta.solana.com WALLET_KEYPAIR_PATH=./keypair.json
undefined

Kamino Lending (klend-sdk)

Kamino 借贷(klend-sdk)

The lending SDK enables interaction with Kamino's lending markets for deposits, borrows, repayments, and liquidations.
借贷SDK可用于与Kamino的借贷市场交互,实现存款、借款、还款和清算操作。

Core Classes

核心类

ClassPurpose
KaminoMarket
Load and interact with lending markets
KaminoAction
Build lending transactions (deposit, borrow, repay, withdraw)
KaminoObligation
Manage user obligations (positions)
KaminoReserve
Access reserve configurations and stats
VanillaObligation
Standard obligation type
用途
KaminoMarket
加载并与借贷市场交互
KaminoAction
构建借贷交易(存款、借款、还款、提取)
KaminoObligation
管理用户债务(头寸)
KaminoReserve
访问储备配置和统计数据
VanillaObligation
标准债务类型

Initialize Market

初始化市场

typescript
import { KaminoMarket } from "@kamino-finance/klend-sdk";
import { Connection, PublicKey } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");

// Main lending market address
const MAIN_MARKET = new PublicKey("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF");

// Load market with basic data
const market = await KaminoMarket.load(connection, MAIN_MARKET);

// Load reserves for detailed data
await market.loadReserves();

// Get specific reserve
const usdcReserve = market.getReserve("USDC");
console.log("Total Deposits:", usdcReserve?.stats.totalDepositsWads.toString());
console.log("LTV:", usdcReserve?.stats.loanToValueRatio);
console.log("Borrow APY:", usdcReserve?.stats.borrowInterestAPY);
console.log("Supply APY:", usdcReserve?.stats.supplyInterestAPY);

// Refresh all data including obligations
await market.refreshAll();
typescript
import { KaminoMarket } from "@kamino-finance/klend-sdk";
import { Connection, PublicKey } from "@solana/web3.js";

const connection = new Connection("https://api.mainnet-beta.solana.com");

// 主借贷市场地址
const MAIN_MARKET = new PublicKey("7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF");

// 加载基础数据的市场
const market = await KaminoMarket.load(connection, MAIN_MARKET);

// 加载储备以获取详细数据
await market.loadReserves();

// 获取特定储备
const usdcReserve = market.getReserve("USDC");
console.log("总存款:", usdcReserve?.stats.totalDepositsWads.toString());
console.log("贷款价值比(LTV):", usdcReserve?.stats.loanToValueRatio);
console.log("借款年化收益率(APY):", usdcReserve?.stats.borrowInterestAPY);
console.log("存款年化收益率(APY):", usdcReserve?.stats.supplyInterestAPY);

// 刷新所有数据,包括债务
await market.refreshAll();

Deposit Collateral

存入抵押品

typescript
import { KaminoAction, VanillaObligation, PROGRAM_ID } from "@kamino-finance/klend-sdk";
import { Keypair, sendAndConfirmTransaction } from "@solana/web3.js";
import Decimal from "decimal.js";

async function deposit(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal
) {
  // Build deposit transaction
  const kaminoAction = await KaminoAction.buildDepositTxns(
    market,
    amount.toString(),           // Amount in base units
    tokenSymbol,                  // e.g., "USDC", "SOL"
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,                            // Additional compute budget (optional)
    true,                         // Include Ata init instructions
    undefined,                    // Referrer (optional)
    undefined,                    // Current slot (optional)
    "finalized"                   // Commitment
  );

  // Get all instructions
  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  // Create and send transaction
  const tx = new Transaction().add(...instructions);
  const signature = await sendAndConfirmTransaction(connection, tx, [wallet]);

  return signature;
}
typescript
import { KaminoAction, VanillaObligation, PROGRAM_ID } from "@kamino-finance/klend-sdk";
import { Keypair, sendAndConfirmTransaction } from "@solana/web3.js";
import Decimal from "decimal.js";

async function deposit(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal
) {
  // 构建存款交易
  const kaminoAction = await KaminoAction.buildDepositTxns(
    market,
    amount.toString(),           // 基础单位金额
    tokenSymbol,                  // 例如 "USDC", "SOL"
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,                            // 额外计算预算(可选)
    true,                         // 包含Ata初始化指令
    undefined,                    // 推荐人(可选)
    undefined,                    // 当前插槽(可选)
    "finalized"                   // 确认级别
  );

  // 获取所有指令
  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  // 创建并发送交易
  const tx = new Transaction().add(...instructions);
  const signature = await sendAndConfirmTransaction(connection, tx, [wallet]);

  return signature;
}

Borrow Assets

借入资产

typescript
async function borrow(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal
) {
  const kaminoAction = await KaminoAction.buildBorrowTxns(
    market,
    amount.toString(),
    tokenSymbol,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    false,                        // Include deposit for fees (optional)
    undefined,
    undefined,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
async function borrow(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal
) {
  const kaminoAction = await KaminoAction.buildBorrowTxns(
    market,
    amount.toString(),
    tokenSymbol,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    false,                        // 包含费用存款(可选)
    undefined,
    undefined,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Repay Loan

偿还贷款

typescript
async function repay(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal | "max"
) {
  const repayAmount = amount === "max" ? "max" : amount.toString();

  const kaminoAction = await KaminoAction.buildRepayTxns(
    market,
    repayAmount,
    tokenSymbol,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    undefined,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
async function repay(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal | "max"
) {
  const repayAmount = amount === "max" ? "max" : amount.toString();

  const kaminoAction = await KaminoAction.buildRepayTxns(
    market,
    repayAmount,
    tokenSymbol,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    undefined,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Withdraw Collateral

提取抵押品

typescript
async function withdraw(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal | "max"
) {
  const withdrawAmount = amount === "max" ? "max" : amount.toString();

  const kaminoAction = await KaminoAction.buildWithdrawTxns(
    market,
    withdrawAmount,
    tokenSymbol,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    undefined,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
async function withdraw(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  amount: Decimal | "max"
) {
  const withdrawAmount = amount === "max" ? "max" : amount.toString();

  const kaminoAction = await KaminoAction.buildWithdrawTxns(
    market,
    withdrawAmount,
    tokenSymbol,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    undefined,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Get User Obligations

获取用户债务

typescript
// Get single vanilla obligation for user
const obligation = await market.getUserVanillaObligation(wallet.publicKey);

if (obligation) {
  console.log("Deposits:", obligation.state.deposits);
  console.log("Borrows:", obligation.state.borrows);
  console.log("Health Factor:", obligation.refreshedStats.borrowLimit);
}

// Get all obligations for user
const allObligations = await market.getAllUserObligations(wallet.publicKey);

// Get obligations for specific reserve
const reserveObligations = await market.getAllUserObligationsForReserve(
  wallet.publicKey,
  usdcReserve
);

// Check if reserve is part of obligation
const isReserveInObligation = market.isReserveInObligation(
  obligation,
  usdcReserve
);
typescript
// 获取用户的单个标准债务
const obligation = await market.getUserVanillaObligation(wallet.publicKey);

if (obligation) {
  console.log("存款:", obligation.state.deposits);
  console.log("借款:", obligation.state.borrows);
  console.log("健康因子:", obligation.refreshedStats.borrowLimit);
}

// 获取用户的所有债务
const allObligations = await market.getAllUserObligations(wallet.publicKey);

// 获取特定储备的用户债务
const reserveObligations = await market.getAllUserObligationsForReserve(
  wallet.publicKey,
  usdcReserve
);

// 检查储备是否属于某笔债务
const isReserveInObligation = market.isReserveInObligation(
  obligation,
  usdcReserve
);

Liquidation

清算

typescript
async function liquidate(
  market: KaminoMarket,
  liquidator: Keypair,
  obligationOwner: PublicKey,
  repayTokenSymbol: string,
  withdrawTokenSymbol: string,
  repayAmount: Decimal
) {
  const kaminoAction = await KaminoAction.buildLiquidateTxns(
    market,
    repayAmount.toString(),
    repayTokenSymbol,
    withdrawTokenSymbol,
    obligationOwner,
    liquidator.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [liquidator]);
}
typescript
async function liquidate(
  market: KaminoMarket,
  liquidator: Keypair,
  obligationOwner: PublicKey,
  repayTokenSymbol: string,
  withdrawTokenSymbol: string,
  repayAmount: Decimal
) {
  const kaminoAction = await KaminoAction.buildLiquidateTxns(
    market,
    repayAmount.toString(),
    repayTokenSymbol,
    withdrawTokenSymbol,
    obligationOwner,
    liquidator.publicKey,
    new VanillaObligation(PROGRAM_ID),
    0,
    true,
    "finalized"
  );

  const instructions = [
    ...kaminoAction.setupIxs,
    ...kaminoAction.lendingIxs,
    ...kaminoAction.cleanupIxs,
  ];

  const tx = new Transaction().add(...instructions);
  return await sendAndConfirmTransaction(connection, tx, [liquidator]);
}

Leverage/Multiply Operations

杠杆/倍数操作

Kamino supports leveraged positions through the multiply feature.
Kamino通过倍数功能支持杠杆头寸。

Open Leveraged Position

开立杠杆头寸

typescript
import {
  getLeverageDepositIxns,
  getLeverageWithdrawIxns,
  calculateLeverageMultiplier
} from "@kamino-finance/klend-sdk/leverage";

async function openLeveragedPosition(
  market: KaminoMarket,
  wallet: Keypair,
  collateralToken: string,
  borrowToken: string,
  depositAmount: Decimal,
  targetLeverage: number  // e.g., 2x, 3x
) {
  // Calculate parameters for target leverage
  const leverageParams = await calculateLeverageMultiplier(
    market,
    collateralToken,
    borrowToken,
    depositAmount,
    targetLeverage
  );

  // Build leverage deposit instructions
  const { instructions, lookupTables } = await getLeverageDepositIxns(
    market,
    wallet.publicKey,
    collateralToken,
    borrowToken,
    depositAmount,
    leverageParams,
    new VanillaObligation(PROGRAM_ID)
  );

  // Execute transaction with address lookup tables
  const tx = new VersionedTransaction(/* ... */);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
import {
  getLeverageDepositIxns,
  getLeverageWithdrawIxns,
  calculateLeverageMultiplier
} from "@kamino-finance/klend-sdk/leverage";

async function openLeveragedPosition(
  market: KaminoMarket,
  wallet: Keypair,
  collateralToken: string,
  borrowToken: string,
  depositAmount: Decimal,
  targetLeverage: number  // 例如 2倍, 3倍
) {
  // 计算目标杠杆的参数
  const leverageParams = await calculateLeverageMultiplier(
    market,
    collateralToken,
    borrowToken,
    depositAmount,
    targetLeverage
  );

  // 构建杠杆存款指令
  const { instructions, lookupTables } = await getLeverageDepositIxns(
    market,
    wallet.publicKey,
    collateralToken,
    borrowToken,
    depositAmount,
    leverageParams,
    new VanillaObligation(PROGRAM_ID)
  );

  // 使用地址查找表执行交易
  const tx = new VersionedTransaction(/* ... */);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Close Leveraged Position

平仓杠杆头寸

typescript
async function closeLeveragedPosition(
  market: KaminoMarket,
  wallet: Keypair,
  collateralToken: string,
  borrowToken: string
) {
  const { instructions, lookupTables } = await getLeverageWithdrawIxns(
    market,
    wallet.publicKey,
    collateralToken,
    borrowToken,
    "max",  // Withdraw full position
    new VanillaObligation(PROGRAM_ID)
  );

  const tx = new VersionedTransaction(/* ... */);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
async function closeLeveragedPosition(
  market: KaminoMarket,
  wallet: Keypair,
  collateralToken: string,
  borrowToken: string
) {
  const { instructions, lookupTables } = await getLeverageWithdrawIxns(
    market,
    wallet.publicKey,
    collateralToken,
    borrowToken,
    "max",  // 提取全部头寸
    new VanillaObligation(PROGRAM_ID)
  );

  const tx = new VersionedTransaction(/* ... */);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Obligation Orders

债务订单

Automate actions based on LTV or price thresholds.
基于LTV或价格阈值自动执行操作。

LTV-Based Orders

基于LTV的订单

typescript
import {
  createLtvBasedOrder,
  LtvOrderType
} from "@kamino-finance/klend-sdk/obligation_orders";

// Create order to repay when LTV exceeds threshold
async function createLtvOrder(
  market: KaminoMarket,
  wallet: Keypair,
  targetLtv: number,  // e.g., 0.8 for 80%
  repayToken: string,
  repayAmount: Decimal
) {
  const orderIx = await createLtvBasedOrder(
    market,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    {
      type: LtvOrderType.REPAY_ON_HIGH_LTV,
      triggerLtv: targetLtv,
      repayToken,
      repayAmount: repayAmount.toString(),
    }
  );

  const tx = new Transaction().add(orderIx);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
import {
  createLtvBasedOrder,
  LtvOrderType
} from "@kamino-finance/klend-sdk/obligation_orders";

// 创建当LTV超过阈值时的还款订单
async function createLtvOrder(
  market: KaminoMarket,
  wallet: Keypair,
  targetLtv: number,  // 例如 0.8 代表80%
  repayToken: string,
  repayAmount: Decimal
) {
  const orderIx = await createLtvBasedOrder(
    market,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    {
      type: LtvOrderType.REPAY_ON_HIGH_LTV,
      triggerLtv: targetLtv,
      repayToken,
      repayAmount: repayAmount.toString(),
    }
  );

  const tx = new Transaction().add(orderIx);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Price-Based Orders

基于价格的订单

typescript
import {
  createPriceBasedOrder,
  PriceOrderType
} from "@kamino-finance/klend-sdk/obligation_orders";

// Create stop-loss order
async function createStopLossOrder(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  triggerPrice: Decimal,
  action: "repay" | "withdraw"
) {
  const orderIx = await createPriceBasedOrder(
    market,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    {
      type: PriceOrderType.STOP_LOSS,
      tokenSymbol,
      triggerPrice: triggerPrice.toString(),
      action,
    }
  );

  const tx = new Transaction().add(orderIx);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
import {
  createPriceBasedOrder,
  PriceOrderType
} from "@kamino-finance/klend-sdk/obligation_orders";

// 创建止损订单
async function createStopLossOrder(
  market: KaminoMarket,
  wallet: Keypair,
  tokenSymbol: string,
  triggerPrice: Decimal,
  action: "repay" | "withdraw"
) {
  const orderIx = await createPriceBasedOrder(
    market,
    wallet.publicKey,
    new VanillaObligation(PROGRAM_ID),
    {
      type: PriceOrderType.STOP_LOSS,
      tokenSymbol,
      triggerPrice: triggerPrice.toString(),
      action,
    }
  );

  const tx = new Transaction().add(orderIx);
  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Kamino Liquidity (kliquidity-sdk)

Kamino 流动性(kliquidity-sdk)

Automated liquidity management for concentrated liquidity positions on Orca, Raydium, and Meteora.
为Orca、Raydium和Meteora上的集中流动性头寸提供自动化流动性管理。

Initialize SDK

初始化SDK

typescript
import { Kamino } from "@kamino-finance/kliquidity-sdk";
import { Connection, clusterApiUrl } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("mainnet-beta"));
const kamino = new Kamino("mainnet-beta", connection);
typescript
import { Kamino } from "@kamino-finance/kliquidity-sdk";
import { Connection, clusterApiUrl } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("mainnet-beta"));
const kamino = new Kamino("mainnet-beta", connection);

Fetch Strategies

获取策略

typescript
// Get all strategies
const strategies = await kamino.getStrategies();

// Get strategy by address
const strategy = await kamino.getStrategyByAddress(
  new PublicKey("strategy_address")
);

// Get strategy by kToken mint
const strategyByMint = await kamino.getStrategyByKTokenMint(
  new PublicKey("ktoken_mint")
);

// Get strategies with filters
const filteredStrategies = await kamino.getAllStrategiesWithFilters({
  strategyType: "NON_PEGGED",   // NON_PEGGED, PEGGED, STABLE
  status: "LIVE",               // LIVE, STAGING, DEPRECATED
  tokenA: new PublicKey("..."), // Filter by token A
  tokenB: new PublicKey("..."), // Filter by token B
});
typescript
// 获取所有策略
const strategies = await kamino.getStrategies();

// 通过地址获取策略
const strategy = await kamino.getStrategyByAddress(
  new PublicKey("strategy_address")
);

// 通过kToken铸币地址获取策略
const strategyByMint = await kamino.getStrategyByKTokenMint(
  new PublicKey("ktoken_mint")
);

// 带筛选条件获取策略
const filteredStrategies = await kamino.getAllStrategiesWithFilters({
  strategyType: "NON_PEGGED",   // NON_PEGGED, PEGGED, STABLE
  status: "LIVE",               // LIVE, STAGING, DEPRECATED
  tokenA: new PublicKey("..."), // 按Token A筛选
  tokenB: new PublicKey("..."), // 按Token B筛选
});

Strategy Types

策略类型

TypeDescriptionExample Pairs
NON_PEGGED
Uncorrelated assetsSOL-BONK, SOL-USDC
PEGGED
Loosely correlatedBSOL-JitoSOL, mSOL-SOL
STABLE
Price-stableUSDC-USDT, USDH-USDC
类型描述示例交易对
NON_PEGGED
非关联资产SOL-BONK, SOL-USDC
PEGGED
弱关联资产BSOL-JitoSOL, mSOL-SOL
STABLE
稳定币USDC-USDT, USDH-USDC

Get Strategy Data

获取策略数据

typescript
// Get share price
const sharePrice = await kamino.getStrategySharePrice(strategy);
console.log("Share Price:", sharePrice.toString());

// Get share data
const shareData = await kamino.getStrategyShareData(strategy);
console.log("Total Shares:", shareData.totalShares);
console.log("Token A per Share:", shareData.tokenAPerShare);
console.log("Token B per Share:", shareData.tokenBPerShare);

// Get token amounts per share
const tokenAmounts = await kamino.getTokenAAndBPerShare(strategy);
console.log("Token A:", tokenAmounts.tokenA);
console.log("Token B:", tokenAmounts.tokenB);

// Get strategy price range
const range = await kamino.getStrategyRange(strategy);
console.log("Lower Price:", range.lowerPrice);
console.log("Upper Price:", range.upperPrice);
console.log("Current Price:", range.currentPrice);
typescript
// 获取份额价格
const sharePrice = await kamino.getStrategySharePrice(strategy);
console.log("份额价格:", sharePrice.toString());

// 获取份额数据
const shareData = await kamino.getStrategyShareData(strategy);
console.log("总份额:", shareData.totalShares);
console.log("每份Token A数量:", shareData.tokenAPerShare);
console.log("每份Token B数量:", shareData.tokenBPerShare);

// 获取每份的Token数量
const tokenAmounts = await kamino.getTokenAAndBPerShare(strategy);
console.log("Token A:", tokenAmounts.tokenA);
console.log("Token B:", tokenAmounts.tokenB);

// 获取策略价格区间
const range = await kamino.getStrategyRange(strategy);
console.log("下限价格:", range.lowerPrice);
console.log("上限价格:", range.upperPrice);
console.log("当前价格:", range.currentPrice);

Deposit to Strategy

存入策略

typescript
import Decimal from "decimal.js";

async function depositToStrategy(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  tokenAAmount: Decimal,
  tokenBAmount: Decimal,
  slippage: Decimal  // e.g., new Decimal(0.01) for 1%
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  // Build deposit instructions
  const depositIxs = await kamino.deposit(
    strategy,
    wallet.publicKey,
    tokenAAmount,
    tokenBAmount,
    slippage
  );

  // Create transaction with extra compute budget
  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...depositIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
import Decimal from "decimal.js";

async function depositToStrategy(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  tokenAAmount: Decimal,
  tokenBAmount: Decimal,
  slippage: Decimal  // 例如 new Decimal(0.01) 代表1%
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  // 构建存款指令
  const depositIxs = await kamino.deposit(
    strategy,
    wallet.publicKey,
    tokenAAmount,
    tokenBAmount,
    slippage
  );

  // 创建包含额外计算预算的交易
  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...depositIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Single Token Deposit

单Token存款

typescript
async function singleTokenDeposit(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  tokenAmount: Decimal,
  isTokenA: boolean,  // true for Token A, false for Token B
  slippage: Decimal
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const depositIxs = await kamino.singleTokenDeposit(
    strategy,
    wallet.publicKey,
    tokenAmount,
    isTokenA,
    slippage
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...depositIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
async function singleTokenDeposit(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  tokenAmount: Decimal,
  isTokenA: boolean,  // true代表Token A,false代表Token B
  slippage: Decimal
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const depositIxs = await kamino.singleTokenDeposit(
    strategy,
    wallet.publicKey,
    tokenAmount,
    isTokenA,
    slippage
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...depositIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Withdraw from Strategy

从策略提取

typescript
async function withdrawFromStrategy(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  shareAmount: Decimal,  // Number of shares to withdraw
  slippage: Decimal
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const withdrawIxs = await kamino.withdraw(
    strategy,
    wallet.publicKey,
    shareAmount,
    slippage
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...withdrawIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

// Withdraw all shares
async function withdrawAllShares(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  slippage: Decimal
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const withdrawIxs = await kamino.withdrawAllShares(
    strategy,
    wallet.publicKey,
    slippage
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...withdrawIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
async function withdrawFromStrategy(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  shareAmount: Decimal,  // 要提取的份额数量
  slippage: Decimal
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const withdrawIxs = await kamino.withdraw(
    strategy,
    wallet.publicKey,
    shareAmount,
    slippage
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...withdrawIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

// 提取所有份额
async function withdrawAllShares(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey,
  slippage: Decimal
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const withdrawIxs = await kamino.withdrawAllShares(
    strategy,
    wallet.publicKey,
    slippage
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...withdrawIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Collect Fees & Rewards

收取费用与奖励

typescript
async function collectFeesAndRewards(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const collectIxs = await kamino.collectFeesAndRewards(
    strategy,
    wallet.publicKey
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...collectIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}
typescript
async function collectFeesAndRewards(
  kamino: Kamino,
  wallet: Keypair,
  strategyAddress: PublicKey
) {
  const strategy = await kamino.getStrategyByAddress(strategyAddress);

  const collectIxs = await kamino.collectFeesAndRewards(
    strategy,
    wallet.publicKey
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(...collectIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(connection, tx, [wallet]);
}

Get Pool Information

获取池信息

typescript
// Get supported DEXes
const dexes = kamino.getSupportedDexes();
// Returns: ["ORCA", "RAYDIUM", "METEORA"]

// Get fee tiers for DEX
const feeTiers = kamino.getFeeTiersForDex("ORCA");

// Get pools for token pair
const orcaPools = await kamino.getOrcaPoolsForTokens(tokenAMint, tokenBMint);
const raydiumPools = await kamino.getRaydiumPoolsForTokens(tokenAMint, tokenBMint);
const meteoraPools = await kamino.getMeteoraPoolsForTokens(tokenAMint, tokenBMint);

// Get current price for pair
const price = await kamino.getPriceForPair("ORCA", tokenAMint, tokenBMint);
typescript
// 获取支持的去中心化交易所(DEX)
const dexes = kamino.getSupportedDexes();
// 返回: ["ORCA", "RAYDIUM", "METEORA"]

// 获取DEX的手续费层级
const feeTiers = kamino.getFeeTiersForDex("ORCA");

// 获取交易对的池
const orcaPools = await kamino.getOrcaPoolsForTokens(tokenAMint, tokenBMint);
const raydiumPools = await kamino.getRaydiumPoolsForTokens(tokenAMint, tokenBMint);
const meteoraPools = await kamino.getMeteoraPoolsForTokens(tokenAMint, tokenBMint);

// 获取交易对当前价格
const price = await kamino.getPriceForPair("ORCA", tokenAMint, tokenBMint);

Rebalance Methods

再平衡方法

typescript
// Get available rebalance methods
const methods = kamino.getRebalanceMethods();
// Returns: ["MANUAL", "DRIFT", "TAKE_PROFIT", "PERIODIC", "PRICE_PERCENTAGE", ...]

// Get enabled methods
const enabledMethods = kamino.getEnabledRebalanceMethods();

// Get default method
const defaultMethod = kamino.getDefaultRebalanceMethod();

// Read rebalance parameters for strategy
const driftParams = await kamino.readDriftRebalanceParams(strategy);
const periodicParams = await kamino.readPeriodicRebalanceParams(strategy);
const priceParams = await kamino.readPricePercentageParams(strategy);
typescript
// 获取可用的再平衡方法
const methods = kamino.getRebalanceMethods();
// 返回: ["MANUAL", "DRIFT", "TAKE_PROFIT", "PERIODIC", "PRICE_PERCENTAGE", ...]

// 获取启用的方法
const enabledMethods = kamino.getEnabledRebalanceMethods();

// 获取默认方法
const defaultMethod = kamino.getDefaultRebalanceMethod();

// 读取策略的再平衡参数
const driftParams = await kamino.readDriftRebalanceParams(strategy);
const periodicParams = await kamino.readPeriodicRebalanceParams(strategy);
const priceParams = await kamino.readPricePercentageParams(strategy);

Create New Strategy

创建新策略

typescript
async function createStrategy(
  kamino: Kamino,
  admin: Keypair,
  params: {
    dex: "ORCA" | "RAYDIUM" | "METEORA";
    tokenAMint: PublicKey;
    tokenBMint: PublicKey;
    feeTierBps: Decimal;
    rebalanceMethod: string;
  }
) {
  const strategyKeypair = Keypair.generate();

  // Check token accounts exist
  const tokenAAccount = await kamino.getAssociatedTokenAddressAndData(
    params.tokenAMint,
    admin.publicKey
  );
  const tokenBAccount = await kamino.getAssociatedTokenAddressAndData(
    params.tokenBMint,
    admin.publicKey
  );

  // Create strategy account
  const createAccountIx = await kamino.createStrategyAccount(
    strategyKeypair.publicKey
  );

  // Initialize strategy
  const initIxs = await kamino.initializeStrategy(
    strategyKeypair.publicKey,
    admin.publicKey,
    params
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(createAccountIx, ...initIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(
    connection,
    tx,
    [admin, strategyKeypair],
    { commitment: "finalized" }
  );
}
typescript
async function createStrategy(
  kamino: Kamino,
  admin: Keypair,
  params: {
    dex: "ORCA" | "RAYDIUM" | "METEORA";
    tokenAMint: PublicKey;
    tokenBMint: PublicKey;
    feeTierBps: Decimal;
    rebalanceMethod: string;
  }
) {
  const strategyKeypair = Keypair.generate();

  // 检查Token账户是否存在
  const tokenAAccount = await kamino.getAssociatedTokenAddressAndData(
    params.tokenAMint,
    admin.publicKey
  );
  const tokenBAccount = await kamino.getAssociatedTokenAddressAndData(
    params.tokenBMint,
    admin.publicKey
  );

  // 创建策略账户
  const createAccountIx = await kamino.createStrategyAccount(
    strategyKeypair.publicKey
  );

  // 初始化策略
  const initIxs = await kamino.initializeStrategy(
    strategyKeypair.publicKey,
    admin.publicKey,
    params
  );

  const tx = kamino.createTransactionWithExtraBudget();
  tx.add(createAccountIx, ...initIxs);

  await kamino.assignBlockInfoToTransaction(tx);

  return await sendAndConfirmTransaction(
    connection,
    tx,
    [admin, strategyKeypair],
    { commitment: "finalized" }
  );
}

Scope Oracle (scope-sdk)

Scope 预言机(scope-sdk)

Oracle price aggregator providing reliable pricing data.
提供可靠定价数据的预言机价格聚合器。

Initialize Scope

初始化Scope

typescript
import { Scope } from "@kamino-finance/scope-sdk";
import { Connection, clusterApiUrl } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("mainnet-beta"));
const scope = new Scope("mainnet-beta", connection);
typescript
import { Scope } from "@kamino-finance/scope-sdk";
import { Connection, clusterApiUrl } from "@solana/web3.js";

const connection = new Connection(clusterApiUrl("mainnet-beta"));
const scope = new Scope("mainnet-beta", connection);

Get Oracle Prices

获取预言机价格

typescript
// Get all oracle prices
const prices = await scope.getOraclePrices();

// Prices indexed by token
console.log("SOL Price:", prices.get("SOL"));
console.log("USDC Price:", prices.get("USDC"));

// Get specific price
const solPrice = await scope.getPrice("SOL");
console.log("SOL/USD:", solPrice.price.toString());
console.log("Timestamp:", solPrice.timestamp);
console.log("Confidence:", solPrice.confidence);
typescript
// 获取所有预言机价格
const prices = await scope.getOraclePrices();

// 按Token索引的价格
console.log("SOL价格:", prices.get("SOL"));
console.log("USDC价格:", prices.get("USDC"));

// 获取特定价格
const solPrice = await scope.getPrice("SOL");
console.log("SOL/USD价格:", solPrice.price.toString());
console.log("时间戳:", solPrice.timestamp);
console.log("置信度:", solPrice.confidence);

Price Feeds

价格数据源

Scope aggregates from multiple oracle sources:
  • Pyth: Real-time market prices
  • Switchboard: Decentralized oracle network
  • TWAP: Time-weighted average prices
  • CLMM Prices: DEX-derived prices
typescript
// Get price with source info
const priceData = await scope.getPriceWithMetadata("SOL");
console.log("Price:", priceData.price);
console.log("Source:", priceData.source);
console.log("Age (slots):", priceData.ageSlots);
Scope从多个预言机源聚合数据:
  • Pyth: 实时市场价格
  • Switchboard: 去中心化预言机网络
  • TWAP: 时间加权平均价格
  • CLMM价格: 去中心化交易所(DEX)衍生价格
typescript
// 获取带源信息的价格
const priceData = await scope.getPriceWithMetadata("SOL");
console.log("价格:", priceData.price);
console.log("数据源:", priceData.source);
console.log("时长(插槽数):", priceData.ageSlots);

CLI Commands

CLI命令

Lending CLI

借贷CLI

bash
undefined
bash
undefined

Deposit tokens

存入代币

yarn cli deposit --url <RPC> --owner ./keypair.json --token USDC --amount 100
yarn cli deposit --url <RPC地址> --owner ./keypair.json --token USDC --amount 100

Print all lending market accounts

打印所有借贷市场账户

yarn cli print-all-lending-market-accounts --rpc <RPC>
yarn cli print-all-lending-market-accounts --rpc <RPC地址>

Print all reserve accounts

打印所有储备账户

yarn cli print-all-reserve-accounts --rpc <RPC>
yarn cli print-all-reserve-accounts --rpc <RPC地址>

Print all obligation accounts

打印所有债务账户

yarn cli print-all-obligation-accounts --rpc <RPC>
yarn cli print-all-obligation-accounts --rpc <RPC地址>

Filter with jq

使用jq过滤

yarn cli print-all-reserve-accounts --rpc <RPC> | jq '.lastUpdateSlot' yarn cli print-all-obligation-accounts --rpc <RPC> | jq --stream 'select(.[0][1] == "owner")'
undefined
yarn cli print-all-reserve-accounts --rpc <RPC地址> | jq '.lastUpdateSlot' yarn cli print-all-obligation-accounts --rpc <RPC地址> | jq --stream 'select(.[0][1] == "owner")'
undefined

Program Addresses

程序地址

Mainnet

主网

ProgramAddress
Kamino Lending
KLend2g3cP87ber41qQDzWpAFuqP2tCxDqC8S3k7L1U
Main Market
7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF
Kamino Liquidity
KLIQ... (varies)
Scope Oracle
ScopE... (varies)
程序地址
Kamino 借贷
KLend2g3cP87ber41qQDzWpAFuqP2tCxDqC8S3k7L1U
主市场
7u3HeHxYDLhnCoErrtycNokbQYbWGzLs6JSDqGAv5PfF
Kamino 流动性
KLIQ... (可变)
Scope 预言机
ScopE... (可变)

Reserve Configuration

储备配置

Each reserve has configurable parameters:
typescript
interface ReserveConfig {
  // Collateral configuration
  loanToValueRatio: number;        // Max borrowing power (e.g., 0.8 = 80%)
  liquidationThreshold: number;     // Liquidation trigger (e.g., 0.85 = 85%)
  liquidationBonus: number;         // Liquidator reward (e.g., 0.05 = 5%)

  // Interest rate model
  optimalUtilizationRate: number;   // Target utilization
  borrowRateCurve: {
    baseRate: number;
    optimalRate: number;
    maxRate: number;
  };

  // Fees
  protocolTakeRate: number;         // Protocol fee on interest
  hostFeeRate: number;              // Host integration fee

  // Limits
  depositLimit: number;             // Max deposits
  borrowLimit: number;              // Max borrows

  // Status
  depositEnabled: boolean;
  borrowEnabled: boolean;
  withdrawEnabled: boolean;
}
每个储备都有可配置的参数:
typescript
interface ReserveConfig {
  // 抵押品配置
  loanToValueRatio: number;        // 最大借款能力(例如 0.8 = 80%)
  liquidationThreshold: number;     // 清算触发阈值(例如 0.85 = 85%)
  liquidationBonus: number;         // 清算者奖励(例如 0.05 = 5%)

  // 利率模型
  optimalUtilizationRate: number;   // 目标利用率
  borrowRateCurve: {
    baseRate: number;
    optimalRate: number;
    maxRate: number;
  };

  // 手续费
  protocolTakeRate: number;         // 协议对利息收取的手续费
  hostFeeRate: number;              // 主机集成手续费

  // 限制
  depositLimit: number;             // 最大存款额
  borrowLimit: number;              // 最大借款额

  // 状态
  depositEnabled: boolean;
  borrowEnabled: boolean;
  withdrawEnabled: boolean;
}

Error Handling

错误处理

typescript
import { KaminoError, ErrorCode } from "@kamino-finance/klend-sdk";

try {
  await kaminoAction.execute();
} catch (error) {
  if (error instanceof KaminoError) {
    switch (error.code) {
      case ErrorCode.InsufficientCollateral:
        console.error("Not enough collateral for this borrow");
        break;
      case ErrorCode.BorrowLimitExceeded:
        console.error("Borrow limit reached for this reserve");
        break;
      case ErrorCode.LiquidationThresholdExceeded:
        console.error("Position is at risk of liquidation");
        break;
      case ErrorCode.InvalidObligation:
        console.error("Obligation account not found or invalid");
        break;
      default:
        console.error("Kamino error:", error.message);
    }
  } else {
    throw error;
  }
}
typescript
import { KaminoError, ErrorCode } from "@kamino-finance/klend-sdk";

try {
  await kaminoAction.execute();
} catch (error) {
  if (error instanceof KaminoError) {
    switch (error.code) {
      case ErrorCode.InsufficientCollateral:
        console.error("抵押品不足以支持此次借款");
        break;
      case ErrorCode.BorrowLimitExceeded:
        console.error("该储备的借款限额已达上限");
        break;
      case ErrorCode.LiquidationThresholdExceeded:
        console.error("头寸面临清算风险");
        break;
      case ErrorCode.InvalidObligation:
        console.error("债务账户未找到或无效");
        break;
      default:
        console.error("Kamino错误:", error.message);
    }
  } else {
    throw error;
  }
}

Best Practices

最佳实践

Health Factor Monitoring

健康因子监控

typescript
async function checkHealthFactor(
  market: KaminoMarket,
  wallet: PublicKey
): Promise<number> {
  await market.refreshAll();
  const obligation = await market.getUserVanillaObligation(wallet);

  if (!obligation) return Infinity;

  const stats = obligation.refreshedStats;
  const healthFactor = stats.borrowLimit / stats.borrowedValue;

  if (healthFactor < 1.1) {
    console.warn("WARNING: Health factor below 1.1, consider adding collateral");
  }

  return healthFactor;
}
typescript
async function checkHealthFactor(
  market: KaminoMarket,
  wallet: PublicKey
): Promise<number> {
  await market.refreshAll();
  const obligation = await market.getUserVanillaObligation(wallet);

  if (!obligation) return Infinity;

  const stats = obligation.refreshedStats;
  const healthFactor = stats.borrowLimit / stats.borrowedValue;

  if (healthFactor < 1.1) {
    console.warn("警告: 健康因子低于1.1,建议增加抵押品");
  }

  return healthFactor;
}

Transaction Optimization

交易优化

typescript
// Use lookup tables for smaller transactions
const { instructions, lookupTables } = await kaminoAction.buildWithLookupTables();

// Create versioned transaction
const messageV0 = new TransactionMessage({
  payerKey: wallet.publicKey,
  recentBlockhash: (await connection.getLatestBlockhash()).blockhash,
  instructions,
}).compileToV0Message(lookupTables);

const tx = new VersionedTransaction(messageV0);
tx.sign([wallet]);

await sendAndConfirmTransaction(connection, tx, [wallet]);
typescript
// 使用查找表减小交易大小
const { instructions, lookupTables } = await kaminoAction.buildWithLookupTables();

// 创建版本化交易
const messageV0 = new TransactionMessage({
  payerKey: wallet.publicKey,
  recentBlockhash: (await connection.getLatestBlockhash()).blockhash,
  instructions,
}).compileToV0Message(lookupTables);

const tx = new VersionedTransaction(messageV0);
tx.sign([wallet]);

await sendAndConfirmTransaction(connection, tx, [wallet]);

Slippage Protection

滑点保护

typescript
// For liquidity operations, always use slippage protection
const slippage = new Decimal(0.005); // 0.5% max slippage

const depositIxs = await kamino.deposit(
  strategy,
  wallet.publicKey,
  tokenAAmount,
  tokenBAmount,
  slippage  // Protects against price movement
);
typescript
// 对于流动性操作,始终使用滑点保护
const slippage = new Decimal(0.005); // 最大滑点0.5%

const depositIxs = await kamino.deposit(
  strategy,
  wallet.publicKey,
  tokenAAmount,
  tokenBAmount,
  slippage  // 防止价格波动影响
);

TypeScript Types

TypeScript类型

typescript
import type {
  // Lending types
  KaminoMarket,
  KaminoAction,
  KaminoObligation,
  KaminoReserve,
  VanillaObligation,
  ReserveConfig,
  ObligationStats,

  // Liquidity types
  Kamino,
  WhirlpoolStrategy,
  StrategyWithAddress,
  ShareData,
  PositionRange,
  RebalanceMethod,
  StrategiesFilters,

  // Oracle types
  Scope,
  OraclePrices,
  PriceData,
} from "@kamino-finance/klend-sdk";
typescript
import type {
  // 借贷类型
  KaminoMarket,
  KaminoAction,
  KaminoObligation,
  KaminoReserve,
  VanillaObligation,
  ReserveConfig,
  ObligationStats,

  // 流动性类型
  Kamino,
  WhirlpoolStrategy,
  StrategyWithAddress,
  ShareData,
  PositionRange,
  RebalanceMethod,
  StrategiesFilters,

  // 预言机类型
  Scope,
  OraclePrices,
  PriceData,
} from "@kamino-finance/klend-sdk";

Kamino 2.0 / K-Lend (New Features)

Kamino 2.0 / K-Lend(新功能)

Architecture Updates

架构更新

Kamino 2.0 introduced a fully integrated application with two key layers:
  • Market Layer: Core lending markets with advanced risk parameters
  • Vault Layer: Curator-managed vault strategies for optimized yield
Kamino 2.0推出了完全集成的应用,包含两个核心层:
  • 市场层: 具备高级风险参数的核心借贷市场
  • 金库层: 由策展人管理的金库策略,优化收益

New Collateral Support (2025)

2025年新增抵押品支持

AssetTypeNotes
nxSOLLSTNansen liquid staking token
Huma RWARWAReal-world asset backed collateral
JitoSOLLSTJito liquid staking token
资产类型说明
nxSOL流动性质押代币(LST)Nansen流动性质押代币
Huma RWA现实世界资产(RWA)由现实世界资产支持的抵押品
JitoSOL流动性质押代币(LST)Jito流动性质押代币

K-Lend V2 Features (Q4 2025)

K-Lend V2功能(2025年第四季度)

  • Modular Lending: Isolated markets for RWAs and institutional use cases
  • Enhanced Risk Engine: Improved liquidation parameters
  • Multi-collateral Positions: Borrow against multiple assets
  • 模块化借贷: 为现实世界资产(RWA)和机构用例提供独立市场
  • 增强型风险引擎: 改进的清算参数
  • 多抵押品头寸: 可借入多种资产

Governance (Q1 2026)

治理(2026年第一季度)

Decentralized decision-making via KMNO stakers will be activated, allowing token holders to vote on:
  • Reserve parameters
  • New market listings
  • Protocol fees
将激活由KMNO质押者参与的去中心化决策机制,代币持有者可对以下事项投票:
  • 储备参数
  • 新市场上线
  • 协议手续费

Security Milestones

安全里程碑

  • Fourth protocol verification completed (October 2025)
  • $1.5M bug bounty program active
  • 第四次协议审计完成(2025年10月)
  • 150万美元漏洞赏金计划已启动

Resources

资源

Skill Structure

技能结构

kamino/
├── SKILL.md                        # This file
├── resources/
│   ├── klend-api-reference.md      # Complete lending API
│   ├── kliquidity-api-reference.md # Complete liquidity API
│   ├── scope-api-reference.md      # Oracle API reference
│   ├── reserve-configs.md          # Reserve configurations
│   └── program-addresses.md        # All program addresses
├── examples/
│   ├── lending/
│   │   ├── deposit-withdraw.md     # Deposit & withdraw examples
│   │   ├── borrow-repay.md         # Borrowing examples
│   │   ├── leverage.md             # Multiply/leverage examples
│   │   └── liquidation.md          # Liquidation bot example
│   ├── liquidity/
│   │   ├── strategy-management.md  # Strategy operations
│   │   ├── deposits-withdrawals.md # LP operations
│   │   └── rebalancing.md          # Rebalance strategies
│   └── oracle/
│       └── price-feeds.md          # Oracle usage examples
├── templates/
│   ├── lending-setup.ts            # Lending starter
│   ├── liquidity-setup.ts          # Liquidity starter
│   └── full-integration.ts         # Complete integration
└── docs/
    ├── troubleshooting.md          # Common issues
    └── advanced-patterns.md        # Complex patterns
kamino/
├── SKILL.md                        # 本文档
├── resources/
│   ├── klend-api-reference.md      # 完整借贷API
│   ├── kliquidity-api-reference.md # 完整流动性API
│   ├── scope-api-reference.md      # 预言机API参考
│   ├── reserve-configs.md          # 储备配置
│   └── program-addresses.md        # 所有程序地址
├── examples/
│   ├── lending/
│   │   ├── deposit-withdraw.md     # 存款与提取示例
│   │   ├── borrow-repay.md         # 借款示例
│   │   ├── leverage.md             # 杠杆/倍数操作示例
│   │   └── liquidation.md          # 清算机器人示例
│   ├── liquidity/
│   │   ├── strategy-management.md  # 策略操作
│   │   ├── deposits-withdrawals.md # 流动性提供者(LP)操作
│   │   └── rebalancing.md          # 再平衡策略
│   └── oracle/
│       └── price-feeds.md          # 预言机使用示例
├── templates/
│   ├── lending-setup.ts            # 借贷入门模板
│   ├── liquidity-setup.ts          # 流动性入门模板
│   └── full-integration.ts         # 完整集成模板
└── docs/
    ├── troubleshooting.md          # 常见问题
    └── advanced-patterns.md        # 复杂模式