Insurance and rebalancing
Closing account
When user closes account or his account is liquidated:
PnL - is result of repaying:
Updating total borrowed amount:
PnL>=0:
This case means that return value > borrowed amount + expected interest accrued. Interest accrued is already included in expected liquidity. At this point, the protocol keeps all funds in the pool and mint diesel tokens to treasury fund.
PnL<0:
This case means, that returned value < borrowed amount + expected interest rate. At this cases, pool uses treasury fund as insurance and burn tokens to keep diesel rate on the same level.
Insurance example
In some rare cases, the remaining funds after paying liquidation premium could be less than borrowed amount + interest rate + fee. In this case, the protocol uses treasury to compensate for the shortage by burning diesel tokens to keep the diesel rate as it should be.
Let's consider an example:
1) LP adds 1000 DAI to the pool. Diesel rate =1, he got 1000 dDAI (diesel DAI tokens). Total liquidity = 2000, and diesel supply = 2000.
2) Trader borrowed 1000 DAI and used them for some period. Let's assume that interest accrued is 100DAI. So, at time of return: total liquidity = 2100, diesel rate= 2100 / 2000 = 1.05
3) LP earns on diesel rate, so their interest rate income is already accounted in 1.05 rate.
4) Trader's account was liquidated, and the remaining funds are 1000 DAI only. So, if there is no insurance fund was there, the diesel rate should return to 1 which means that LP earns nothing. However, in this case, protocol burns treasure's tokens to keep the diesel rate on the same level:
5) Let's check that burning 95.23 will keep diesel rate as it was before this accident:
So, in this case, the treasury was used to cover some losses and behave like an insurance fund.