Core Functions
createPermissionlessVaultInstruction
Creates an instruction to initialize a new permissionless vault. Function- Creates all necessary PDAs for the vault including vault account, token vault, and LP mint
- The vault will be permissionless, allowing anyone to deposit and withdraw
- Payer will cover the rent costs for the new accounts
fetchMultipleUserBalance
Fetches LP token balances for multiple vaults for a specific user. Function- Returns 0 for vaults where the user has no LP tokens
- Efficiently fetches multiple balances in a single call
- Useful for portfolio overview displays
createMultiple
Creates multiple vault instances from token mint addresses. FunctionVaultImpl
instances for the specified token mints.
Example
- Efficiently creates multiple vault instances in parallel
- All vaults must already exist on-chain
- Useful for initializing a portfolio of vaults
createMultipleWithPda
Creates multiple vault instances from vault PDA addresses. FunctionVaultImpl
instances for the specified vault PDAs.
Example
- Use this when you already have the vault PDA addresses
- More direct than
createMultiple
when PDAs are known - Supports affiliate integration for revenue sharing
create
Creates a single vault instance from a token mint address. FunctionVaultImpl
instance for the specified token.
Example
- Use this for creating a single vault instance
- The vault must already exist on-chain
- Automatically fetches and caches vault state information
getUserBalance
Gets the user’s LP token balance for this vault. Function- Returns 0 if the user has no LP tokens
- Handles both direct deposits and affiliate deposits
- Balance represents share of the vault’s total assets
getVaultSupply
Gets the total LP token supply for the vault. Function- Refetches the latest LP mint supply from the blockchain
- Updates the cached
tokenLpMint
property - Use the cached
vault.tokenLpMint.supply
for performance if recent data is sufficient
getWithdrawableAmount
Gets the amount of assets that can be immediately withdrawn from the vault. Function- Amount may be less than total vault assets due to strategy allocations
- Uses current on-chain time for calculations
- Does not account for user’s specific LP token balance
refreshVaultState
Refreshes the cached vault state and token mint information. FunctionvaultState
and tokenMint
properties.
Example
- Call this before deposit/withdraw operations to ensure latest state
- Updates both vault state and token mint data
- Essential for accurate calculations in dynamic environments
deposit
Deposits tokens into the vault and receives LP tokens in return. FunctionTransaction
ready to be signed and sent.
Example
- Automatically handles SOL wrapping for native SOL vaults
- Creates necessary token accounts if they don’t exist
- Supports affiliate revenue sharing if configured
- The transaction includes all necessary pre-instructions
- LP tokens are minted proportional to the deposit amount
withdraw
Withdraws tokens from the vault by burning LP tokens. FunctionTransaction
ready to be signed and sent.
Example
- Automatically handles SOL unwrapping for native SOL vaults
- May withdraw from vault reserves or underlying strategies
- Supports affiliate revenue sharing if configured
- The
baseTokenAmount
parameter refers to LP tokens to burn, not underlying tokens to receive - Automatically selects the optimal withdrawal strategy based on liquidity availability
getStrategiesState
Gets the state of all strategies associated with the vault. FunctionStrategyState
objects representing the vault’s strategies.
Example
- Excludes the vault’s internal strategy (VAULT_STRATEGY_ADDRESS)
- Useful for understanding vault composition and performance
- Each strategy represents a different yield farming or liquidity provision approach
getAffiliateInfo
Gets affiliate partnership information for the vault. FunctionAffiliateInfo
object containing partnership details.
Example
- Only available when vault is created with an
affiliateId
- Throws an error if no affiliate program is configured
- Contains fee rates, total fees earned, and partnership terms
State Functions
getAllVaultState
Fetches state information for multiple vaults by token mint addresses. FunctiontokensAddress
: Array of token mint addressesprogram
: The vault program instanceseedBaseKey
: Optional seed for deterministic PDAs
getAllVaultStateByPda
Fetches state information for multiple vaults by their PDA addresses. FunctionvaultsPda
: Array of vault PDA addressesprogram
: The vault program instance
getVaultState
Fetches state information for a single vault by token mint address. FunctiontokenAddress
: Token mint addressprogram
: The vault program instanceseedBaseKey
: Optional seed for deterministic PDAs
getVaultStateByPda
Fetches state information for a single vault by its PDA address. FunctionvaultPda
: Vault PDA addressprogram
: The vault program instance
getVaultLiquidity
Gets the current liquidity amount in the vault’s token account. Functionconnection
: Solana connection instancetokenVaultPda
: The vault’s token account PDA
Helper Functions
calculateWithdrawableAmount
Calculates the amount that can be withdrawn based on current time and vault state. FunctioncurrentTime
: Current blockchain timestampvaultState
: The vault’s current state
- Accounts for time-based withdrawal restrictions
- Used internally by the
getWithdrawableAmount
method - Essential for implementing withdrawal limits and unlock schedules