When an operator submits a deposit_strategy or withdraw_strategy transaction (i.e., when assets are rebalanced between lending protocols), we call this the rebalance crank.

A fee is collected to the fee_vault every time the operator sends a rebalance crank. This fee is paid in vault LP SPL tokens and can be seen at the fee_vault address.

Currently, we charge 5% of profit as the operation (performance) fee.


Variables

Before rebalance:

  • vault.total_amount: t1t_1
  • lp_mint.total_supply: p1p_1
  • Virtual price (value of LP token): v1=t1/p1v_1 = t_1 / p_1

After rebalance:

  • vault.total_amount: t2t_2
  • lp_mint.total_supply: p1p_1
  • Virtual price: v2=t2/p1v_2 = t_2 / p_1

Fee Calculation

We charge an operation fee:

fee=0.05×(t2t1)fee = 0.05 \times (t_2 - t_1)

Adjusting Virtual Price After Fee

After deducting the fee, the virtual price becomes:

v21=(t2fee)/p1v_{21} = (t_2 - fee) / p_1

However, the vault does not send tokens directly to the treasury token account (since it may not have enough liquidity). Instead, the vault mints additional LP tokens for the fee_vault.

Let δ\delta be the number of new LP tokens minted for the fee. The new virtual price is:

v22=t2/(p1+δ)v_{22} = t_2 / (p_1 + \delta)

We want the virtual price after fee to remain the same, so set v21=v22v_{21} = v_{22}:

(t2fee)/p1=t2/(p1+δ)(t_2 - fee) / p_1 = t_2 / (p_1 + \delta)

Solving for δ\delta

Rearranging the equation above, we get:

δ=(p1×fee)/(t2fee)\delta = (p_1 \times fee) / (t_2 - fee)

Or, substituting fee=0.05×(t2t1)fee = 0.05 \times (t_2 - t_1):

δ=(p1×0.05×(t2t1))/(t20.05×(t2t1))\delta = (p_1 \times 0.05 \times (t_2 - t_1)) / (t_2 - 0.05 \times (t_2 - t_1))

Which simplifies to:

δ=(p1×0.05×(t2t1))/(0.95×t2+0.05×t1)\delta = (p_1 \times 0.05 \times (t_2 - t_1)) / (0.95 \times t_2 + 0.05 \times t_1)

Summary:

  • The operation fee is 5% of the profit from each rebalance crank.
  • The fee is paid by minting new LP tokens to the fee_vault, not by transferring underlying assets.
  • The number of LP tokens minted is calculated to ensure the virtual price for LP holders remains consistent after the fee is taken.