deposit_strategy
or withdraw_strategy
transaction, we call this the rebalance crank.

vault.total_amount
:token_vault.amount
:strategy.current_liquidity
:
vault.total_amount
:token_vault.amount
:strategy.current_liquidity
:

Sandwich Attack Prevention
To prevent sandwich attacks, the system does not distribute 100% of the yield generated by lending platforms to LPs immediately after each rebalance. Instead, the yield is “dripped” (released gradually) to LPs over a pre-determined period.Key State Variables
-
total_amount
:
The total liquidity in the vault (vault balance + all strategy balances). -
last_updated_locked_profit
:
The total profit that is currently locked, updated at every rebalance. -
last_report
:
The timestamp of the last rebalance. -
locked_profit_degradation
:
The rate at which locked profit is released, expressed as a percentage per second (e.g., 0.1% of locked profits released per second).
How Yield Unlocking Works
When a user adds or removes liquidity, the system uses the unlocked amount (not the fullvault.total_amount
) to calculate how many LP tokens to mint or burn. This is done via the get_unlock_amount
function.
Calculation Steps
- Calculate Duration Since Last Rebalance:
- Calculate Locked Fund Ratio:
- Calculate Unlocked Amount:
In summary:
Only the unlocked portion of profits is available to LPs at any given time, mitigating the risk of sandwich attacks by preventing instant profit extraction after a rebalance.
Example: Drip duration ~ 5 minutes
