> ## Documentation Index
> Fetch the complete documentation index at: https://docs.voltr.xyz/llms.txt
> Use this file to discover all available pages before exploring further.

# SDK Reference

> TypeScript reference for the Voltr Vault SDK v2 (`@voltr/vault-sdk`)

`@voltr/vault-sdk` `2.1.1` is a generated client built around instruction builders, PDA helpers, account fetchers, and extension helpers. The default Solana client stack is now `@solana/kit`.

## Installation

```bash theme={null}
npm install @voltr/vault-sdk @solana/kit
```

Use `@solana/web3.js` only when an external dependency still requires it.

## Core Model

The v2 SDK does not revolve around a `VoltrClient` class. Instead you compose:

* `get*InstructionAsync(...)` builders for writes
* `find*Pda(...)` helpers for PDAs
* `fetch*` loaders for on-chain accounts
* extension helpers for fees, LP economics, positions, and withdrawals

## Minimal Setup

```typescript theme={null}
import {
  createKeyPairSignerFromBytes,
  generateKeyPairSigner,
} from "@solana/kit";
import { findAssociatedTokenPda } from "@solana-program/token";
import {
  findVaultAssetIdleAuthPda,
  getInitializeVaultInstructionAsync,
} from "@voltr/vault-sdk";

const adminSigner = await createKeyPairSignerFromBytes(
  Uint8Array.from(JSON.parse(process.env.ADMIN_SECRET_KEY_JSON!))
);
const vaultSigner = await generateKeyPairSigner();

const managerAddress = "MANAGER_ADDRESS" as const;
const assetMint = "ASSET_MINT_ADDRESS" as const;
const assetTokenProgram = "TOKEN_PROGRAM_ADDRESS" as const;

const [vaultAssetIdleAuth] = await findVaultAssetIdleAuthPda({
  vault: vaultSigner.address,
});
const [vaultAssetIdleAta] = await findAssociatedTokenPda({
  owner: vaultAssetIdleAuth,
  mint: assetMint,
  tokenProgram: assetTokenProgram,
});

const initializeVaultIx = await getInitializeVaultInstructionAsync({
  payer: adminSigner,
  admin: adminSigner.address,
  manager: managerAddress,
  vault: vaultSigner,
  vaultAssetMint: assetMint,
  vaultAssetIdleAta,
  assetTokenProgram,
  maxCap: 18_446_744_073_709_551_615n,
  startAtTs: 0n,
  lockedProfitDegradationDuration: 86_400n,
  managerPerformanceFee: 1_000,
  adminPerformanceFee: 500,
  managerManagementFee: 50,
  adminManagementFee: 25,
  redemptionFee: 10,
  issuanceFee: 10,
  withdrawalWaitingPeriod: 0n,
  name: "My Voltr Vault",
  description: "Short vault strategy description",
});
```

## Common Instruction Builders

### Vault lifecycle

* `getInitializeVaultInstructionAsync`
* `getUpdateVaultConfigInstructionAsync`
* `getCreateLpMetadataInstructionAsync`

### User flows

* `getDepositVaultInstructionAsync`
* `getRequestWithdrawVaultInstructionAsync`
* `getCancelRequestWithdrawVaultInstructionAsync`
* `getWithdrawVaultInstructionAsync`
* `getInstantWithdrawVaultInstructionAsync`

### Manager and admin flows

* `getAddAdaptorInstructionAsync`
* `getInitializeStrategyInstructionAsync`
* `getDepositStrategyInstructionAsync`
* `getWithdrawStrategyInstructionAsync`
* `getDirectWithdrawStrategyInstructionAsync`
* `getHarvestFeeInstructionAsync`
* `getCalibrateHighWaterMarkInstructionAsync`

## PDA Helpers

Most integrations need some combination of:

* `findVaultLpMintPda({ vault })`
* `findVaultAssetIdleAuthPda({ vault })`
* `findVaultStrategyAuthPda({ vault, strategy })`
* `findStrategyInitReceiptPda({ vault, strategy })`
* `findRequestWithdrawVaultReceiptPda({ vault, userTransferAuthority })`
* `findLpMetadataPda({ vault })`
* `findAdaptorAddReceiptPda({ vault, adaptorProgram })`

## Reads And Extensions

Use a kit RPC client plus explicit helpers:

```typescript theme={null}
import { createSolanaRpc } from "@solana/kit";
import {
  fetchVault,
  getAccumulatedAdminFeesForVault,
  getAccumulatedManagerFeesForVault,
  getCurrentAssetPerLpForVault,
  getHighWaterMarkForVault,
  getPositionAndTotalValuesForVault,
  getVaultLpSupplyBreakdown,
} from "@voltr/vault-sdk";

const rpc = createSolanaRpc(process.env.HELIUS_RPC_URL!);
const vaultAccount = await fetchVault(rpc, vaultAddress);
const currentAssetPerLp = await getCurrentAssetPerLpForVault(rpc, vaultAddress);
```

Useful read helpers:

* `fetchVault`
* `fetchRequestWithdrawVaultReceipt`
* `fetchAllStrategyInitReceiptAccountsOfVault`
* `getPositionAndTotalValuesForVault`
* `getAccumulatedAdminFeesForVault`
* `getAccumulatedManagerFeesForVault`
* `getHighWaterMarkForVault`
* `getCurrentAssetPerLpForVault`
* `getVaultLpSupplyBreakdown`
* `getPendingWithdrawalForUser`

## Updating Vault Config

`getUpdateVaultConfigInstructionAsync` updates one field at a time, and the payload must already be serialized.

```typescript theme={null}
import {
  getUpdateVaultConfigInstructionAsync,
  VaultConfigField,
} from "@voltr/vault-sdk";

const data = new Uint8Array(Buffer.alloc(2));
Buffer.from(data).writeUInt16LE(1_500, 0);

const updateVaultConfigIx = await getUpdateVaultConfigInstructionAsync({
  admin: adminSigner,
  vault: vaultAddress,
  field: VaultConfigField.ManagerPerformanceFee,
  data,
});
```

For management-fee fields, append the vault LP mint account to the final instruction accounts:

```typescript theme={null}
const [vaultLpMint] = await findVaultLpMintPda({ vault: vaultAddress });
```

`VaultConfigField` includes:

* `MaxCap`
* `StartAtTs`
* `LockedProfitDegradationDuration`
* `WithdrawalWaitingPeriod`
* `ManagerPerformanceFee`
* `AdminPerformanceFee`
* `ManagerManagementFee`
* `AdminManagementFee`
* `RedemptionFee`
* `IssuanceFee`
* `Manager`
* `PendingAdmin`
* `DisabledOperations`

## Migration From `VoltrClient`

When upgrading older scripts:

* replace `new VoltrClient(connection)` with `createSolanaRpc(...)` plus direct imports
* replace `client.create*Ix(...)` with `get*InstructionAsync(...)`
* replace `client.find*...` with `find*Pda(...)`
* replace convenience query methods with `fetchVault(...)` and extension helpers
* replace `BN` arguments with `bigint`

## Reference Implementations

For maintained end-to-end examples that build on top of this SDK, use the unified [`sdk-scripts`](https://github.com/voltrxyz/sdk-scripts) repository:

* the **CLI** (`apps/cli`) — every vault and strategy operation as a `<group>:<action>` command
* the **programmatic examples** ([`examples/`](https://github.com/voltrxyz/sdk-scripts/tree/main/examples)) — one runnable file per action (vault, Kamino, Spot, Trustful) showing the operation builders in use

See [CLI & Scripts](/vault-owners/operations/cli-and-scripts) for an overview.
