Fund Allocation

This guide explains how to use the Ranger SDK to deposit and withdraw funds between the vault's idle account and strategies.

Setup

Import the required dependencies:

import { Connection, Keypair, PublicKey, TransactionInstruction } from "@solana/web3.js";
import { VoltrClient, LENDING_ADAPTOR_PROGRAM_ID, SEEDS } from "@voltr/vault-sdk";
import { BN } from "@coral-xyz/anchor";
import {
  createAssociatedTokenAccountInstruction,
  getAssociatedTokenAddressSync,
  getAccount,
  TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import fs from "fs";

Initialize the client and configuration:

// Load manager keypair
const managerKp = Keypair.fromSecretKey(
  Uint8Array.from(JSON.parse(fs.readFileSync("/path/to/manager.json", "utf-8")))
);
const manager = managerKp.publicKey;

// Initialize connection and client
const connection = new Connection("your-rpc-url");
const client = new VoltrClient(connection);

// Reference vault and asset
const vault = new PublicKey("your-vault-address");
const vaultAssetMint = new PublicKey("your-asset-mint");

Depositing Funds to Strategies

Accounts required for deposit is protocol-specific. Each protocol requires different accounts and configuration. Use the protocol-specific scripts from the Ranger team:

1. Account Setup

Note: ATA behavior: ATAs created for strategy operations are not closed between deposit/withdraw cycles. The rent cost (~0.002 SOL per ATA) is a one-time cost paid by the manager.

2. Create Deposit Instruction

3. Send Transaction

Withdrawing Funds from Strategies

Accounts required for withdraw is protocol-specific. Each protocol requires different accounts and configuration. Use the protocol-specific scripts from the Ranger team:

1. Account Setup

2. Create Withdrawal Instruction

3. Send Transaction

Best Practices

  • Keep idle reserves: Don't deploy 100% of funds — leave a buffer for user withdrawals

  • Batch operations: Combine ATA creation and allocation in a single transaction

  • Monitor allocations: Track how funds are distributed across strategies

  • Automate: Use bots/scripts for regular rebalancing (see Running Bots & Scripts)

Troubleshooting

Issue
Solution

Transaction too large

Use Lookup Tables

Insufficient funds

Check idle balance, ensure enough SOL for gas

Authority error

Verify manager keypair matches vault's manager

ATA not found

Create the ATA before the allocation instruction

For additional support, refer to the Ranger SDK documentationarrow-up-right.

Last updated