Example
Case 1: User in a healthy position
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:
= 2%
Market Price = $1.02
LP Tokens = 1000
Tolerance = 1.25
Fair Price = $0.98
Debt Taken = 100%
Collateralization Ratio = 130%
= 0.2%
Following the calculations before we have the following conditions for liquidation
Maximum Borrowable USDr = $784.62
Delta = 4.66%
USDr Debt = $784.62
Dynamic CR = 128.15%
Collateral to Debt = 130%
= 0.2%
Health = 1.85%
Liquidate Flag = FALSE
In this case nothing needs to be done, the user is in a healthy position and there isn't any liquidation.
Case 2: User repays to be safe
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.
= 2%
Market Price = $1.01
LP Tokens = 1000
Tolerance = 1.15
Fair Price = $0.85
Debt Taken = 100%
Collateralization Ratio = 130%
= 0.2%
The current market conditions are such that:
Maximum Borrowable USDr = $ 776.92
Delta = -1.15%
USDr Debt = $ 784.62
Dynamic CR = 131.15%
Collateral to Debt = 128.73%
= 0.2%
Health = -2.42%
Liquidate Flag = TRUE
Then the amount to repay to be safe can be easily calculated:
CR - CTD = 1.27%
Repay (%) * 1000 = 12.75
12.75 * $ 1.01 = $ 12.87
At the end of this repayment process the borrower goes back to a healthier position where:
131.23 %
0.08%
Case 3: User getting partially liquidated
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.
= 2%
Market Price = $1.01
LP Tokens = 1000
Tolerance = 1.15
Fair Price = $0.85
Debt Taken = 100%
Collateralization Ratio = 130%
In this case the ratio between Market Price and Fair Price has dropped considerably and the position of the user needs to be liquidated
Maximum Borrowable USDr = $ 776.92
Delta = -1.15%
USDr Debt = $ 784.62
Dynamic CR = 131.15%
Collateral to Debt = 128.73%
Health = -2.42%
Liquidate Flag = TRUE
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:
Minimum Liquidation = 25%
New LP Position = 750
Tokens to be unwound = 250
New LP Nominal = $ 757.50
LP Notional Value = $ 252.66
New USDr Debt = $ 531.95
USDr Burnt = $ 194.35
New Collateral to Debt = 142.40%
New Health = 11.25%
A full calculation of this example can be found in the following link https://docs.google.com/spreadsheets/d/1OIbpjnNHeSDOufd7lC7i6tk8aRZ1VLSEgX4N9yQN5Vc/edit?usp=share_link
Last updated