@exponent-labs/kamino-vault-idl

中文文档
0.9.33发布于 2026/11/05AGPL-3.0TypeScriptCommonJS近 30 天下载 1.5万

The package exposes the same args, accounts, programId? instruction builder structure as @exponent-labs/klend-idl. Existing root exports (IDL, the string PROGRAM_ID, and decodeVault) are preserved.

原始使用文档

Kamino Vault instructions

The package exposes the same args, accounts, programId? instruction builder structure as @exponent-labs/klend-idl. Existing root exports (IDL, the string PROGRAM_ID, and decodeVault) are preserved.

  • @exponent-labs/kamino-vault-idl/instructions: deposit, withdraw, and getVaultReserveAccounts, with their argument/account types.
  • @exponent-labs/kamino-vault-idl/accounts: fetchVaultReserves.

The deposit and withdrawal account layouts match the upstream v2.2.2 IDL and the mainnet program's on-chain IDL, checked on 2026-10-06. The bundled IDL's withdrawal entries include the required global_config account. The rest of the bundled IDL retains its existing layout.

Refresh and build instructions

import BN from "bn.js"

import { fetchVaultReserves } from "@exponent-labs/kamino-vault-idl/accounts"
import {
  type DepositAccounts,
  type WithdrawAccounts,
  deposit,
  getVaultReserveAccounts,
  withdraw,
} from "@exponent-labs/kamino-vault-idl/instructions"
import { refreshReservesBatch } from "@exponent-labs/klend-idl/instructions"

// connection, vaultAddress, depositAccounts, and withdrawAccounts are caller inputs.
const reserves = await fetchVaultReserves(connection, vaultAddress)
const refreshIx = refreshReservesBatch({ skipPriceUpdates: true })
refreshIx.keys.push(
  ...reserves.flatMap(({ reserveAddress, marketAddress }) => [
    { pubkey: reserveAddress, isSigner: false, isWritable: true },
    { pubkey: marketAddress, isSigner: false, isWritable: false },
  ]),
)

const remainingAccounts = getVaultReserveAccounts(reserves)
const depositIx = deposit(
  { maxAmount: new BN("1000000") }, // 1 USDC, including crank fees
  { ...depositAccounts, remainingAccounts } satisfies DepositAccounts,
)
const withdrawIx = withdraw(
  { sharesAmount: new BN("936761") }, // Raw vault shares, not a USDC amount
  { ...withdrawAccounts, remainingAccounts } satisfies WithdrawAccounts,
)

Send [refreshIx, depositIx] or [refreshIx, withdrawIx] in one transaction, after any needed token account creation instructions. Refresh and the vault instruction need to execute in the same slot. skipPriceUpdates: true accrues reserve interest without fetching oracle updates.

KLend refresh accounts alternate reserve, market. KVault's remaining accounts contain all reserves, then all markets, in allocation order. Repeated markets must be retained.

fetchVaultReserves validates account ownership and discriminators and returns reserveAddress, marketAddress, ctokenVault, and the decoded KLend account. It skips unused allocation slots and throws if an active reserve is missing.

Withdrawal takes the IDL's nested withdrawFromAvailable and withdrawFromReserveAccounts account groups. Select a reserve with sufficient withdrawable liquidity; the decoded reserve exposes its collateral mint and liquidity supply. Derive the lending market authority with seeds [Buffer.from("lma"), marketAddress.toBuffer()] under the KLend program. Derive globalConfig with [Buffer.from("global_config")] under the KVault program. These builders return individual instructions; reserve selection, ATA creation, and any farm unstaking are handled by the caller. If a vault requires a permissioning authority, append its signer meta after the reserve/market blocks.

Run yarn workspace @exponent-labs/kamino-vault-idl build and yarn workspace @exponent-labs/kamino-vault-idl test to validate the bindings.

版本与发布记录

@exponent-labs/kamino-vault-idl 共发布 38 个版本,首次发布于 2025/09/10;过去 12 个月发布了 35 个版本。

版本发布日期距今
0.9.33latest2026/11/058 天前
0.9.322026/10/2816 天前
0.9.312026/10/2717 天前
0.9.302026/10/1530 天前
0.9.292026/09/231 个月前
0.9.282026/09/221 个月前

关于 @exponent-labs/kamino-vault-idl 的常见问题

@exponent-labs/kamino-vault-idl 是什么?

The package exposes the same args, accounts, programId? instruction builder structure as @exponent-labs/klend-idl. Existing root exports (IDL, the string PROGRAM_ID, and decodeVault) are preserved.

如何安装 @exponent-labs/kamino-vault-idl?

在项目目录运行 npm install @exponent-labs/kamino-vault-idl,或使用 pnpm add / yarn add / bun add。

@exponent-labs/kamino-vault-idl 支持 TypeScript 吗?

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

@exponent-labs/kamino-vault-idl 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@exponent-labs/kamino-vault-idl 可以商用吗?

@exponent-labs/kamino-vault-idl 使用 AGPL-3.0 许可。最严格的 Copyleft:除分发外,通过网络向用户提供基于它的服务也需要开源对应源码。闭源 SaaS 使用前务必评估。以上为概括,不构成法律意见,请以许可原文为准。

@exponent-labs/kamino-vault-idl 的下载量有多少?

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

@exponent-labs/kamino-vault-idl 还在维护吗?

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