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.

The vault program exposes user liquidity instructions, strategy rebalance instructions, and admin/operator instructions. Apps should normally use the TypeScript SDK for transaction construction. Programs using CPI should generate bindings from the IDL and cross-check account order against the current source.
The current mercurial-vault/programs/vault source includes initialize_idle_vault and JupLend strategy support. The checked-in TypeScript IDL in vault-sdk is older in a few places, so this page follows the current program handlers.

User Liquidity

InstructionTypeScript SDKAccountsArgsUse
depositvault.deposit(owner, amount)vault, token_vault, lp_mint, user_token, user_lp, user, token_programtoken_amount, minimum_lp_token_amountTransfer underlying tokens into the vault and mint LP tokens to the user.
withdrawvault.withdraw(owner, lpAmount) when reserve liquidity is enoughSame as depositunmint_amount, min_out_amountBurn vault LP tokens and withdraw underlying tokens from the vault reserve.
withdraw_directly_from_strategyvault.withdraw(owner, lpAmount) when strategy liquidity is neededvault, strategy, reserve, strategy_program, collateral_vault, token_vault, lp_mint, fee_vault, user_token, user_lp, user, token_programunmint_amount, min_out_amountWithdraw from a selected strategy first when vault reserves cannot satisfy the desired withdrawal.
deposit rejects zero amounts and rejects deposits when vault.enabled == 0. withdraw does not check enabled, so users can still exit a disabled vault.

Deposit Accounting

StepBehavior
Check amounttoken_amount must be greater than zero.
Check vault statusDeposits fail with VaultIsDisabled when enabled == 0.
Calculate LPUses unlocked vault amount and current LP supply. Empty vaults mint based on unlocked amount after adding the deposit.
Slippage checkFails with ExceededSlippage if minted LP is below minimum_lp_token_amount.
Emit eventEmits AddLiquidity.
Token movementTransfers underlying tokens from user_token to token_vault, then mints LP to user_lp.

Withdrawal Accounting

StepBehavior
Calculate outputUses unmint_amount / lp_supply over the current unlocked amount.
Slippage checkFails with ExceededSlippage if output is below min_out_amount.
Reserve withdrawalTransfers underlying tokens from token_vault to user_token.
LP burnBurns unmint_amount from user_lp.
Strategy withdrawalwithdraw_directly_from_strategy can pull from a strategy first, then refines the burned LP amount if available liquidity is lower than requested.

Vault Initialization

InstructionAccountsArgsUse
initializevault, payer, token_vault, token_mint, lp_mint, rent, token_program, system_programnoneCreate a rebalance vault PDA for a token mint using get_base_address().
initialize_idle_vaultSame as initializenoneCreate an idle vault PDA for a token mint using the default pubkey as base.
Initialization sets admin and operator from the configured program admin, initializes the token vault and LP mint PDAs, clears all strategy slots, initializes locked profit, and enables the vault.

Strategy Management

InstructionAccountsArgsAuthorityUse
initialize_strategyvault, strategy_program, strategy, reserve, collateral_vault, collateral_mint, admin, system_program, rent, token_programbumps, strategy_typeAdminInitialize a strategy account, collateral vault, downstream strategy state, and add it to vault.strategies.
add_strategyvault, strategy, adminnoneAdminRe-add an initialized, non-disabled strategy to a vault slot.
remove_strategyvault, strategy, strategy_program, collateral_vault, reserve, token_vault, fee_vault, lp_mint, token_program, adminnoneAdminWithdraw all liquidity from a strategy and remove it from the vault strategy list.
remove_strategy2Same as remove_strategy plus advance-payment token accountsmax_admin_pay_amountAdminRemove a strategy using vault/admin advance payment instead of a normal strategy withdrawal, then mark it disabled.
initialize_strategy requires vault.fee_vault to be set. The handler validates the strategy bump layout and fails with InvalidBump if other_bumps[0] or other_bumps[1] do not match the expected strategy index and PDA bump.

Rebalancing And Rewards

InstructionAccountsArgsAuthorityUse
deposit_strategyvault, strategy, token_vault, fee_vault, lp_mint, strategy_program, collateral_vault, reserve, token_program, operatoramountAdmin or operatorMove vault reserve liquidity into a strategy.
withdraw_strategySame as deposit_strategyamountAdmin or operatorMove liquidity from a strategy back into the vault reserve.
claim_rewardsvault, strategy, token_program, token_reward_acc, operatornoneAdmin or operatorClaim strategy rewards to a treasury-owned reward token account.
Strategy instructions pass protocol-specific remaining accounts to the active strategy handler. The current source-backed external handler is JupLend.

Rebalance Wrapper Behavior

deposit_strategy, withdraw_strategy, remove_strategy, remove_strategy2, and withdraw_directly_from_strategy run through shared rebalance accounting.
StepBehavior
Validate strategyFails with StrategyIsNotExisted if the strategy is not registered in the vault.
Snapshot liquidityReads vault reserve amount and strategy.current_liquidity before the strategy call.
Execute handlerCalls the strategy-specific deposit, withdraw, reward, or compatibility path.
Reload accountsReloads token and collateral vaults after CPI.
Update totalUpdates vault.total_amount from reserve and strategy liquidity changes.
Report lossEmits ReportLoss when total amount decreases.
Lock profitUpdates locked_profit_tracker when total amount changes.
Mint feeOn profit, mints performance-fee LP tokens to fee_vault and emits PerformanceFee.

Admin And Operator Controls

InstructionAccountsArgsAuthorityUse
enable_vaultvault, adminenabledAdminSet vault.enabled.
set_operatorvault, operator, adminnoneAdminReplace the vault operator.
update_locked_profit_degradationvault, adminlocked_profit_degradationAdminUpdate locked-profit release rate after refreshing current locked profit.
transfer_adminvault, admin, new_adminnoneCurrent admin and new admin signerTransfer vault admin authority.
transfer_fee_vaultvault, admin, new_fee_vaultnoneAdminSet a treasury-owned LP token account as the fee vault.
get_unlocked_amountvaultnonenoneSimulate or invoke to emit TotalAmount with current unlocked amount.
All admin and operator controls except get_unlocked_amount require a rebalance vault.

TypeScript SDK Mapping

SDK methodProgram behavior
VaultImpl.createPermissionlessVaultInstruction(...)Builds initialize.
VaultImpl.create(...)Derives the vault PDA from token mint and fetches vault, token mint, and LP mint state.
vault.deposit(...)Builds deposit, or affiliate wrapper deposit when affiliateId is configured.
vault.withdraw(...)Builds reserve withdraw or strategy-backed withdrawal depending on vault reserve liquidity.
vault.getWithdrawableAmount()Computes the same locked-profit unlock formula client-side from vault state and on-chain time.
vault.getStrategiesState()Fetches strategy accounts from non-default vault.strategies entries.

Low-Level Gotchas

GotchaDetail
LP amount nameswithdraw takes LP tokens to burn as unmint_amount, not an underlying-token amount. The SDK parameter is named baseTokenAmount, but the source uses it as the LP amount to burn.
Strategy remaining accountsStrategy handlers validate downstream accounts. Account metas vary by strategy type and must match the handler.
Fee vault setupRebalance and strategy flows with has_one = fee_vault require the vault’s fee vault to be configured.
Disabled strategiesremove_strategy2 calls strategy.disable(). A disabled strategy cannot be re-added.
Precision lossDirect strategy withdrawal fails with InvalidPrecisionLoss if the precision loss is greater than one underlying unit.
Older IDL entriesThe public TS IDL includes older entries such as collectDust and withdraw2. They are not present in the current mercurial-vault program source handlers and are not documented as current handlers here.