@anywalletkit/protocol-lending-kamino-solana

中文文档
0.4.0发布于 2026/11/05Apache-2.0TypeScriptESM + CJS构建来源已验证近 30 天下载 2144

Kamino for @anywalletkit/wallet-solana accounts: Kamino Earn vaults (kVaults: deposit / withdraw, shares, APY) and Kamino Lend markets (supply, withdraw, borrow, repay against an obligation) as LendingProtocols. Transactions come from Kamino's official AP

原始使用文档
文档目录5 节
  1. Install
  2. How a transaction is trusted
  3. Usage
  4. Config
  5. Verify

@anywalletkit/protocol-lending-kamino-solana

npm

Kamino for @anywalletkit/wallet-solana accounts, two LendingProtocols in one package:

Install

npm install @anywalletkit/protocol-lending-kamino-solana @anywalletkit/core
# or: pnpm add @anywalletkit/protocol-lending-kamino-solana @anywalletkit/core  ·  yarn add @anywalletkit/protocol-lending-kamino-solana @anywalletkit/core

On npm: @anywalletkit/protocol-lending-kamino-solana, published from the release workflow with provenance.

  • KaminoVaultProtocolSolana — one Kamino Earn vault (kVault): supply deposits the vault's asset for shares (kept in the wallet, where the guard proves they arrive; skipFarm: false stakes them in the vault farm as the Kamino app does — the guard then pins the stake to this vault's farm and the wallet's farm state, but cannot count the shares), withdraw redeems shares for the asset. The simplest Earn product; borrow / repay reject.
  • KaminoMarketProtocolSolana — one Kamino Lend market (the Main Market by default): supply / withdraw post and take collateral on the wallet's obligation, borrow / repay take and return a reserve's liquidity against it. Tokens are named by mint.

How a transaction is trusted

Kamino's official API builds every transaction (POST /ktx/… — the same builder the Kamino app and SDK use: farms, lookup tables, obligation setup). The module never signs it as-is. The wallet's serialized-transaction guard (wallet-solana's checkSerialized / sendSerialized) proves it first:

  1. every program it invokes is on the Kamino allowlist — Kamino Lend, kVault, Farms, the address-lookup-table program and the token / system / compute budget / memo programs, nothing else;
  2. every instruction is one the operation takes (marketRules / vaultRules), with the accounts that decide where value goes pinned: the wallet, its vanilla obligation, the configured market or vault, the reserve and mint the call names, the wallet's own token accounts, this vault's farm. A deposit carries refreshes, set-up and the deposit; a withdrawal inside it, a borrow inside a repay, a token transfer, an invest or a reward harvest is refused (unexpected-instruction);
  3. the compiled-transaction checks pass (this wallet is the fee payer, no foreign co-signers, no authority or delegate changes);
  4. a simulation with post-state accounts shows exactly the balance changes the module declared: on a deposit the amount out and at most rent in SOL on top, on a withdrawal / borrow the asset in at the minimum (slippageBps, default 0.5 %) — a borrow at most what was asked — no other token account of ours touched.

Only after all four does the account sign. A first Lend deposit also pays the rent of the obligation, user metadata and a per-user lookup table (firstDepositAllowanceLamports, default 0.045 SOL); later ones only the usual rentAllowanceLamports (0.01 SOL). Whether it is a first deposit is read from the chain (does the vanilla obligation's account exist).

The bounds come from the chain, read through the account (getAccountInfos, @anywalletkit/wallet-solana 0.4+): a vault's share price from its state and the reserves it invests in, the wallet's shares from its shares account and farm stake, a Lend 'max' from the obligation (debt with the reserve's accrued interest), and the reserve the API names must be this market's and lend that token. An API figure that disagrees — a tokensPerShare more than 1 % off, a reported deposit or debt that is not the obligation's (the API's per-token legs, or the cTokens and scaled debt in its raw obligation state, valued at the reserves' on-chain rates), any negative figure — is refused, never used. A Lend market's getPosition reads the wallet's obligations from the chain too: the API only names them (each must be the wallet's on this market; the vanilla one is read even when the API leaves it out), and every leg is what it redeems for, or owes, at its reserve's on-chain rate. Other reads (getVault, a vault's getPosition, APY, TVL, LTVs, USD values) stay the API's; mint decimals are read when the account has an RPC, else taken from a table of Kamino's listed mints.

Usage

import WalletManagerSolana from '@anywalletkit/wallet-solana'
import { KaminoApi, KaminoVaultProtocolSolana, KaminoMarketProtocolSolana } from '@anywalletkit/protocol-lending-kamino-solana'

const account = await new WalletManagerSolana(seed, { provider: 'https://…' }).getAccount(0)
const USDC = 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v'

// Discovery: the USDC Earn vaults, biggest first
const api = new KaminoApi()
const vaults = (await api.listVaults()).filter((v) => v.tokenMint === USDC).sort((a, b) => Number(b.sharesIssued - a.sharesIssued))

// Earn vault
// `asset`: the API's answer must name it, and deposits need it (or a `token` per call). The vault's
// address, program and shares mint (the PDA ["shares", vault]) are checked too, before anything is built.
const vault = new KaminoVaultProtocolSolana(account, { vault: vaults[0].address, asset: USDC })
await vault.getVault()                       // asset, shares, APY (net, %), fees, TVL, minimums, allocations
await vault.quoteSupply({ amount: 5_000_000n })   // { fee, expectedShares } — built, proven, not signed
await vault.supply({ amount: 5_000_000n })        // { hash, fee }
await vault.getPosition()                    // { shares, stakedShares, unstakedShares, assets }
await vault.withdraw({ amount: 'max' })      // every share → asset, min = assets × (1 − slippage)

// Lend market
const market = new KaminoMarketProtocolSolana(account)          // Main Market
await market.getReserves()                   // symbol, mint, supply / borrow APY (%), max LTV, TVL, utilization
await market.supply({ token: USDC, amount: 5_000_000n })        // collateral on the wallet's obligation
await market.borrow({ token: USDC, amount: 1_000_000n })
await market.getPosition()                   // { obligations, supplied: {mint: units}, borrowed } — from the chain
await market.repay({ token: USDC, amount: 'max' })
await market.withdraw({ token: USDC, amount: 'max' })

A mint with several reserves in a market (the Main Market has four USDC reserves) resolves to the deepest one by supplied value; pin another with reserves: { [mint]: reserveAddress }.

Config

optiondefault
apihttps://api.kamino.financeendpoint or a KaminoApi
slippageBps50floor on what the wallet must receive (withdraw, borrow); ceiling on a repay
rentAllowanceLamports0.01 SOLSOL a transaction may spend beyond the amount
memo—SPL memo the API adds
vault: vault, asset, skipFarm— / — / truethe kVault; the asset it must take; keep shares in the wallet (false: stake them in this vault's farm; the guard then proves the spend and pins the stake to the wallet's farm state)
market: market, reserves, firstDepositAllowanceLamportsMain Market / — / 0.045 SOL

Verify

pnpm test (fixtures copied from live API responses). pnpm verify:live [address] [rpcUrl] [lendAddress] reads markets, reserves and vaults from the API, then builds a vault deposit and a Lend deposit for the address, and a Lend withdraw for a wallet with USDC supplied on the main market, and runs each through the guard as a read-only account (no keys, no writes); that wallet's getPosition must match its obligation on chain. A holder whose USDC account is frozen is named and refused before anything is built; one without USDC skips the deposits and still runs the withdraw.

Program ids: Kamino Lend KLend2g3cP87fffoy8q1mQqGKjrxjC8boSyAYavgmjD, kVault KvauGMspG5k6rtzrqqn7WNn3oZdyKqLKwK2XWQ8FLjd, Farms FarmsPZpWu9i7Kky8tPN37rs2TpmMrAZrC7S7vJa91Hr. instructionName() names the Anchor instructions the API's transactions carry, for review screens; decodeVault / decodeReserve / decodeObligation / decodeFarmUser read the accounts the bounds come from, and vaultTokensPerShareWad / debtNow compute from them what the module does.

版本与发布记录

@anywalletkit/protocol-lending-kamino-solana 共发布 13 个版本,首次发布于 2026/10/25;过去 12 个月发布了 13 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
0.4.0latest2026/11/052 天前
0.3.22026/11/035 天前
0.3.12026/10/309 天前
0.3.02026/10/2910 天前
0.2.22026/10/2811 天前
0.2.12026/10/2712 天前

关于 @anywalletkit/protocol-lending-kamino-solana 的常见问题

@anywalletkit/protocol-lending-kamino-solana 是什么?

Kamino for @anywalletkit/wallet-solana accounts: Kamino Earn vaults (kVaults: deposit / withdraw, shares, APY) and Kamino Lend markets (supply, withdraw, borrow, repay against an obligation) as LendingProtocols. Transactions come from Kamino's official AP

如何安装 @anywalletkit/protocol-lending-kamino-solana?

在项目目录运行 npm install @anywalletkit/protocol-lending-kamino-solana,或使用 pnpm add / yarn add / bun add。它还需要宿主项目提供 peer 依赖:@anywalletkit/core(0.8.0)。npm 7 及以上与 pnpm 8 及以上默认会自动安装必需的 peer 依赖,Yarn 需要手动安装。

@anywalletkit/protocol-lending-kamino-solana 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@anywalletkit/protocol-lending-kamino-solana 支持 ESM 还是 CommonJS?

同时提供 ES Module 与 CommonJS 入口,import 和 require() 都可以使用,打包工具会自动选择合适的版本。

@anywalletkit/protocol-lending-kamino-solana 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js >=22。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@anywalletkit/protocol-lending-kamino-solana 可以商用吗?

@anywalletkit/protocol-lending-kamino-solana 使用 Apache-2.0 许可。宽松许可:允许商业使用、修改和再分发,并附带明确的专利授权;分发时需保留许可与 NOTICE 文件,修改过的文件要注明改动。以上为概括,不构成法律意见,请以许可原文为准。

@anywalletkit/protocol-lending-kamino-solana 的下载量有多少?

根据 npm 官方下载统计,@anywalletkit/protocol-lending-kamino-solana 在 2026/10/06 – 2026/11/04 这 30 天内被下载 2,144 次,日均约 71 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@anywalletkit/protocol-lending-kamino-solana 还在维护吗?

最新版本 0.4.0 发布于 2026/11/05(2 天前);至今共发布 13 个版本,其中过去 12 个月发布了 13 个;首次发布于 2026/10/25。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。