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.
Dynamic Vault performs accounting in smallest token units using checked integer arithmetic. Display decimals are a UI concern. Division rounds down unless a strategy handler explicitly requests rounded-up collateral conversion.
The formulas below describe the on-chain accounting model. Strategy-specific conversions, such as JupLend collateral-to-liquidity exchange-rate math, are handled by the strategy handler.
Core Values
| Value | Meaning |
|---|
total_amount | Vault liquidity tracked by the program, including the token vault and strategy liquidity. |
token_vault.amount | Underlying token amount currently in the vault reserve. |
strategy.current_liquidity | Underlying liquidity value last recorded for a strategy. |
lp_mint.supply | Total supply of vault LP tokens. |
last_updated_locked_profit | Locked profit after the latest locked-profit update. |
last_report | Timestamp of the latest locked-profit update. |
locked_profit_degradation | Per-second unlock rate. |
Locked Profit
Dynamic Vault uses a denominator of:
LOCKED_PROFIT_DEGRADATION_DENOMINATOR=1,000,000,000,000
The default degradation rate fully unlocks locked profit over 6 hours:
defaultDegradation=⌊6×3,6001,000,000,000,000⌋
For a current timestamp:
duration=currentTime−lastReport
lockedFundRatio=duration×lockedProfitDegradation
If lockedFundRatio is greater than the denominator, locked profit is zero. Otherwise:
lockedProfit=⌊1,000,000,000,000lastUpdatedLockedProfit×(1,000,000,000,000−lockedFundRatio)⌋
Unlocked Amount
The unlocked amount is used for deposit and withdrawal share calculations.
unlockedAmount=totalAmount−lockedProfit
Deposit LP Tokens
For a non-empty LP supply:
lpTokensMinted=⌊unlockedAmountdepositAmount×lpSupply⌋
The program then increases total_amount by depositAmount.
For zero LP supply, the program first adds the deposit to total_amount, then mints the current unlocked amount:
lpTokensMinted=unlockedAmountAfterDeposit
This also covers the edge case where all LP tokens were previously burned but some profit remains locked.
Withdrawal Amount
For a direct LP-token withdrawal:
withdrawAmount=⌊lpSupplylpTokensBurned×unlockedAmount⌋
The program subtracts withdrawAmount from total_amount, transfers that amount from the token vault, and burns the user’s LP tokens.
For strategy-backed direct withdrawals, the program may refine the LP amount if the strategy cannot return the full desired amount:
refinedLpBurn=⌊unlockedAmountactualOutAmount×lpSupply⌋
Precision loss in this path must be at most 1.
Strategy Total Amount Update
After a strategy action, the program updates vault total liquidity from before and after values:
newTotalAmount=oldTotalAmount+tokenVaultAfter+strategyLiquidityAfter−tokenVaultBefore−strategyLiquidityBefore
Gain and loss are derived by comparing total amount before and after:
gain=max(newTotalAmount−oldTotalAmount,0)
loss=max(oldTotalAmount−newTotalAmount,0)
Locked Profit Update
The program first calculates remaining locked profit at the current timestamp. Loss reduces remaining locked profit first:
lockedAfterLoss=max(remainingLockedProfit−loss,0)
Gain is then added:
newLockedProfit=lockedAfterLoss+gain
last_report is updated to the current timestamp.
The performance-fee constants are:
PERFORMANCE_FEE_NUMERATOR=500
PERFORMANCE_FEE_DENOMINATOR=10,000
So the fee is 5% of positive strategy gain:
f=⌊10,000gain×500⌋
The program does not transfer this fee as underlying tokens. It mints LP tokens to the configured fee vault.
Let:
p be the gain
u be the unlocked amount before the rebalance accounting update
s be the LP supply before fee minting
f be the fee amount above
The amount of newly unlocked value attributed to the fee mint is:
x=⌊p+u−ff×u⌋
The LP tokens minted to the fee vault are:
feeLpTokens=⌊ux×s⌋
If fee LP tokens are minted, x is subtracted from last_updated_locked_profit. This keeps the virtual price stable at the moment the performance fee is minted, while future locked profit continues to unlock over time.
If gain is zero, or the unlocked amount is zero, no performance-fee LP tokens are minted.