Following the post on Delta and the liquidation logic, we think a full example of liquidation calculations is useful. Suppose that the initial conditions of the position taken by the user are:
Following the calculations before we have the following conditions for liquidation
In this case nothing needs to be done, the user is in a healthy position and there isn't any liquidation.
Here we start from the same initial conditions as the example above, however different market conditions pushed LP Market price to $1.01 and Fair Price to $0.85.
The current market conditions are such that:
Then the amount to repay to be safe can be easily calculated:
At the end of this repayment process the borrower goes back to a healthier position where:
Here the same conditions as the example above are given, but the borrower didn't repay any of their debt within the 3 epochs of time given as a buffer before liquidation occurs.
In this case the ratio between Market Price and Fair Price has dropped considerably and the position of the user needs to be liquidated
In this example, at current market conditions the borrower's debt is now under-collateralized, therefore, the position needs to be readjusted. For this particular example this readjustment is: