Operation fee calculation

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

Fee is collected to the fee_vault every time the operator sends a rebalance crank. This fee is shown in the fee_vault address as vault LP SPL tokens.

We are currently charging 5% of profit as the operation (performance) fee. Before jumping into the formula, we define some variables:

Before rebalance:

  • vault.total_amount : t1

  • lp_mint.total_supply: p1

  • virtual_price (value of lp token): v1 =t1/p1

After rebalance:

  • vault.total_amount : t2

  • lp_mint.total_supply: p1

  • virtual_price: v2 =t2/p1

We charge operation fee:

fee=0.05(t2t1)fee = 0.05* (t2-t1)

Virtual price after fee:

v21=(t2fee)/p1v21= (t_2-fee)/p_1

Vault doesn't send the token directly to the treasury token account (because vault may not have enough liquidity), so vault mint more lp tokens for fee_vault. Assuming vault mints more delta lp tokens, then the new virtual price:

v22=t2/(p1+delta)v22= t2/(p1+delta)

We still ensure the virtual price in (1) and (2) are the same v21=v22, so


Then we can calculate how many lp tokens is minted more for each rebalance crank:

delta=(p1fee)/(t2fee)delta = (p_1*fee)/(t_2-fee)


delta=p1(t2t1)/(9t2+t1)delta=p_1*(t_2-t_1) / (9*t_2+t_1)

Last updated