Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.meteora.ag/llms.txt

Use this file to discover all available pages before exploring further.

Use CPI when your Solana program must call Dynamic Vault directly, for example to deposit user funds into a vault, withdraw vault LP, or compose vault withdrawals as part of a larger protocol instruction.
Prefer generated Anchor bindings from the IDL and compare account metas against SDK-built instructions. Most CPI failures come from wrong PDA seeds, a stale LP mint, a missing fee vault, or strategy-specific remaining accounts in the wrong order.

Program ID

pub const VAULT_PROGRAM_ID: Pubkey =
    pubkey!("24Uqj9JCLxUeoC3hGfh5W3s9FM9uCHDS2SG3LYwBpyTi");
The public program ID is the same on mainnet and devnet.

CPI Scope

FlowCPI suitability
depositSuitable for simple integrations that hold or receive user tokens and mint vault LP.
withdrawSuitable when the vault reserve can satisfy the withdrawal. Burns LP and transfers underlying tokens.
withdraw_directly_from_strategyAdvanced. Requires selecting a strategy and forwarding strategy-specific remaining accounts.
Strategy rebalance instructionsKeeper/admin style only. Requires admin/operator authorization and strategy handler accounts.
Admin controlsUsually not part of public partner CPI. Requires vault admin signer.
For off-chain apps, use the TypeScript SDK. For on-chain CPI, your program owns the outer validation, signer seeds, and slippage thresholds.

Deposit CPI Accounts

deposit uses DepositWithdrawLiquidity.
AccountMutabilitySignerNotes
vaultwritablenoMust match token_vault and lp_mint.
token_vaultwritablenoVault reserve token account.
lp_mintwritablenoVault LP mint.
user_tokenwritablenoSource underlying token account.
user_lpwritablenoDestination LP token account.
userreadonlyyesAuthority for user_token.
token_programreadonlynoSPL Token program.
Arguments:
ArgTypeMeaning
token_amountu64Underlying token amount to deposit. Must be greater than zero.
minimum_lp_token_amountu64Minimum LP tokens to receive.

Withdraw CPI Accounts

withdraw uses the same DepositWithdrawLiquidity accounts.
ArgTypeMeaning
unmint_amountu64LP token amount to burn.
min_out_amountu64Minimum underlying tokens to receive.
Your program should calculate or validate unmint_amount in LP units. To withdraw a target underlying amount, convert using current unlocked amount and LP supply.

Direct Strategy Withdrawal CPI

withdraw_directly_from_strategy is used when vault reserve liquidity is not enough and the transaction should pull from a strategy first.
AccountNotes
vaultWritable rebalance vault with token_vault, lp_mint, and fee_vault relationships.
strategyWritable strategy account registered in vault.strategies.
reserveWritable strategy reserve, must match strategy.reserve.
strategy_programDownstream strategy program.
collateral_vaultWritable strategy collateral account, must match strategy.collateral_vault.
token_vaultWritable vault reserve account.
lp_mintWritable vault LP mint.
fee_vaultWritable fee vault account.
user_tokenWritable destination underlying token account.
user_lpWritable source LP token account.
userLP token owner signer.
token_programSPL Token program.
Remaining accountsStrategy-handler-specific accounts, currently relevant for JupLend.
Direct strategy withdrawal can refine the LP burn amount if the strategy cannot return the full desired amount. It rejects precision loss greater than one underlying unit.

Vault Signer Seeds

The vault signs token transfers and LP minting with:
let vault_seeds: &[&[u8]] = &[
    b"vault",
    vault_state.token_mint.as_ref(),
    vault_state.base.as_ref(),
    &[vault_state.bumps.vault_bump],
];
If your program signs for a PDA-owned user token account in the outer CPI, pass your own signer seeds to the outer token account authority as well. The vault program only signs for vault-owned accounts.

Account Planning

CheckDetail
Derive from stateRead vault.token_vault and vault.lp_mint from vault state instead of recomputing them from user input alone.
Use fresh LP supplyWithdrawal math depends on current LP supply and unlocked amount.
Validate ATAsUser token and LP accounts must match the expected mint and authority for your integration.
Pass slippage thresholdsDo not pass zero thresholds in production CPI unless the outer program has its own protection.
Detect disabled depositsDeposits fail when vault.enabled == 0; withdrawals remain available.
Plan computeStrategy-backed withdrawals and rebalance flows can require more compute than reserve-only withdrawals.

Rebalance CPI Notes

Strategy rebalance instructions are admin/operator flows and require vault.admin == operator or vault.operator == operator.
InstructionExtra planning
deposit_strategyStrategy handler deposit accounts, writable collateral vault, reserve, fee vault, LP mint, and operator signer.
withdraw_strategySame account set, plus sufficient collateral and strategy liquidity.
claim_rewardsTreasury-owned reward token account and strategy-specific remaining accounts.
initialize_strategyFee vault must already be set, and StrategyBumps must match the derived strategy PDA.
remove_strategyWithdraws all strategy liquidity and fails if residual lending liquidity is greater than the allowed precision residue.

Common CPI Failures

ErrorLikely cause
ConstraintHasOnetoken_vault, lp_mint, fee_vault, admin, or strategy fields do not match vault or strategy state.
ConstraintSeedsVault, LP mint, token vault, strategy, or collateral vault PDA was derived with the wrong base or index.
AccountNotSigneruser, admin, or operator was not a signer, or PDA signer seeds were not forwarded by the outer program.
VaultIsDisabledDeposit attempted while the vault is disabled.
ExceededSlippageLP minted or underlying output was below threshold.
StrategyIsNotExistedStrategy account is not present in vault.strategies.
InvalidAccountsForStrategyFee vault or strategy remaining accounts do not match expected state.
FeeVaultIsNotSetStrategy initialization attempted before transfer_fee_vault.
InvalidBumpStrategyBumps does not match the strategy PDA.
InvalidPrecisionLossDirect strategy withdrawal precision loss exceeded one underlying unit.

Testing

LayerRecommendation
Unit and account testsUse Anchor or solana-program-test with local vault fixtures.
Transaction constructionCompare account metas against @meteora-ag/vault-sdk built transactions.
Strategy pathsTest with the exact downstream program fixtures and remaining accounts used by the target strategy.
Devnet rehearsalSimulate and send small devnet transactions before mainnet CPI rollout.
For public partner integrations, keep the CPI surface narrow: deposit, reserve withdrawal, and carefully audited direct strategy withdrawal only when your protocol truly needs it.