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:
Virtual price after fee:
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:
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:
Or
Last updated