Health factor and liquidation

At present, liquidations are handled automatically with manual liquidations coming in the future.

Health factor

For liquidation, the health factor is calculated instead of collateralization ratio.

Health factor=(LTV ratioi×Collateral Value in USDi)Borrowing Value in USDi\text{Health factor} = \frac{\sum (\text{LTV ratio}_i \times \text{Collateral Value in USD}_i)}{\sum \text{Borrowing Value in USD}_i}

The health factor is always bigger than or equal to the collateralization ratio because we take the liquidation threshold out, which always deflates the result of the equation. When they are equal, they will always be at the positive infinity.

Using the information from the table above, the health factor would be:

Health factor=(0.9×5)+(0.9×1)2+0.3=(4.5)+(0.9)2.3=5.42.3=2.347\text{Health factor} = \frac{(0.9 \times 5) + (0.9 \times 1)}{2 + 0.3} = \frac{(4.5) + (0.9)}{2.3} = \frac{5.4}{2.3} = 2.347

As shown, the health factor is greater than the collateralization ratio. The difference between the health factor and the collateralization ratio is a buffer for the borrowers. When the health factor goes below 1, a portion of debt may be liquidated to bring the user's health ratio back to 1.

Amount to liquidate

The liquidation must happen before the health factor drops 'too much' below 1. What would be 'too much'?: When the value of the collateral is so little that the health factor cannot be recovered back to 1 even after being liquidated. How do we derive the equation? We can use the same health factor equation we have above.

Let's give an example using the variables below, and let's say we are repaying Asset 2's debt and taking away Asset 1 collateral during liquidation:

Parameter
Asset 1
Asset 2

LTV ratio

80%

85%

Deposited amount in USD

5.4 USD

0.1 USD

Borrowed amount in USD

0.1 USD

5 USD

Liquidation bonus

6%

7%

Let's expand:

Health factor=(LTV ratioi×Collateral Value in USDi)Borrowing Value in USDi\text{Health factor} = \frac{\sum (\text{LTV ratio}_i \times \text{Collateral Value in USD}_i)}{\sum \text{Borrowing Value in USD}_i}

into

HFafter liquidation=LTVAsset1×(CVAsset1RVAsset2(1+LFAsset2))+LTVAsset2×CVAsset2DVAsset1+DVAsset2RVAsset2\text{HF}_{\text{after liquidation}} = \frac{LTV_{Asset1} \times (CV_{Asset1} - RV_{Asset2}(1 + LF_{Asset2})) + LTV_{Asset2} \times CV_{Asset2}}{DV_{Asset1} + DV_{Asset2} - RV_{Asset2}}

where

  • HFafter liquidation\text{HF}_{\text{after liquidation}} is the health factor after liquidation takes place.

  • LTVasset\text{LTV}_{asset} is the LTV ratio of an asset.

  • CVasset\text{CV}_{asset} is the value of an asset deposited as a collateral in USD.

  • RVasset\text{RV}_{asset} is the value of repayment on the debt of an asset in USD.

  • DVasset\text{DV}_{asset} is the value of the debt of an asset in USD.

  • LFasset\text{LF}_{asset} is the liquidation bonus factor of an asset.

Notice that the equation is just an equation for the health factor in the post-liquidation state. LTVAsset1×(CVAsset1RVAsset2(1+LFAsset1))LTV_{Asset1} \times (CV_{Asset1} - RV_{Asset2}(1 + LF_{Asset1})) represents the discounted collateral left after a part of Asset 1 collateral including the liquidation bonus is captured in exchange for the Asset 2 debt repayment by the liquidator. LTVAsset2×CVAsset2LTV_{Asset2} \times CV_{Asset2} represents the discounted Asset 2 collateral. DVAsset1+DVAsset2RVAsset2DV_{Asset1} + DV_{Asset2} - RV_{Asset2} represents total debt after the Asset 2 debt repayment.

Let's rearrange the equation so we can solve for RVAsset2\text{RV}_{Asset2}:

HFafter liquidation=LTVAsset1×(CVAsset1RVAsset2(1+LFAsset1))+LTVAsset2×CVAsset2DVAsset1+DVAsset2RVAsset2\text{HF}_{\text{after liquidation}} = \frac{LTV_{Asset1} \times (CV_{Asset1} - RV_{Asset2}(1 + LF_{Asset1})) + LTV_{Asset2} \times CV_{Asset2}}{DV_{Asset1} + DV_{Asset2} - RV_{Asset2}}
    HFafter liquidation(DVAsset1)+HFafter liquidation(DVAsset2)HFafter liquidation(RVAsset2)\implies \text{HF}_{\text{after liquidation}}(DV_{Asset1}) + \text{HF}_{\text{after liquidation}}(DV_{Asset2}) - \text{HF}_{\text{after liquidation}}(RV_{Asset2})
=(LTVAsset1)(CVAsset1)(RVAsset2)(LTVAsset1)(1+LFAsset1))+(LTVAsset2)(CVAsset2)= (LTV_{Asset1})(CV_{Asset1}) - (RV_{Asset2})(LTV_{Asset1})(1 + LF_{Asset1})) + (LTV_{Asset2})(CV_{Asset2})
    (RVAsset2)(LTVAsset1)(1+LFAsset1))HFafter liquidation(RVAsset2)\implies (RV_{Asset2})(LTV_{Asset1})(1 + LF_{Asset1})) - \text{HF}_{\text{after liquidation}}(RV_{Asset2})
=HFafter liquidation(DVAsset1)HFafter liquidation(DVAsset2)+(LTVAsset1)(CVAsset1)+(LTVAsset2)(CVAsset2)= -\text{HF}_{\text{after liquidation}}(DV_{Asset1}) -\text{HF}_{\text{after liquidation}}(DV_{Asset2}) + (LTV_{Asset1})(CV_{Asset1}) + (LTV_{Asset2})(CV_{Asset2})
    (RVAsset2)((LTVAsset1)(1+LFAsset1))HFafter liquidation)\implies (RV_{Asset2})((LTV_{Asset1})(1 + LF_{Asset1})) - \text{HF}_{\text{after liquidation}})
=HFafter liquidation(DVAsset1+DVAsset2)+i(LTVi×CVi)= -\text{HF}_{\text{after liquidation}}(DV_{Asset1} + DV_{Asset2}) + \sum\limits_{i}{(LTV_i \times CV_i)}
    (RVAsset2)((LTVAsset1)(1+LFAsset1))HFafter liquidation)\implies (RV_{Asset2})((LTV_{Asset1})(1 + LF_{Asset1})) - \text{HF}_{\text{after liquidation}})
=HFafter liquidation(iDVi)+i(LTVi×CVi)= -\text{HF}_{\text{after liquidation}}(\sum\limits_{i}{DV_i}) + \sum\limits_{i}{(LTV_i \times CV_i)}
    RVAsset2=HFafter liquidation(iDVi)+i(LTVi×CVi)((LTVAsset1)(1+LFAsset1))HFafter liquidation\implies RV_{Asset2} = \frac{-\text{HF}_{\text{after liquidation}}(\sum\limits_{i}{DV_i}) + \sum\limits_{i}{(LTV_i \times CV_i)}}{((LTV_{Asset1})(1 + LF_{Asset1})) - \text{HF}_{\text{after liquidation}}}

Now that we have the equation ready, substitute the variables. We know that:

HFafter liquidation1\text{HF}_{\text{after liquidation}} \le 1

so let's substitute:

HFafter liquidation=1\text{HF}_{\text{after liquidation}} = 1

in this equation below:

RVAsset2=(1)(5+0.1)+(0.8×5.4+0.85×0.1)((0.8)(1+0.06))1RV_{Asset2} = \frac{-(1)(5 + 0.1) + (0.8 \times 5.4 + 0.85 \times 0.1)}{((0.8)(1 + 0.06)) - 1}

We can run this Python script to confirm the result:

RV_Asset2_NUMERATOR = (-1 * (0.1 + 5) + (0.8 * 5.4 + 0.85 * 0.1))
RV_Asset2_DENOMINATOR = ((0.8) * (1 + 0.06) - 1)
RV_Asset2 = RV_Asset2_NUMERATOR / RV_Asset2_DENOMINATOR

print(RV_Asset2_NUMERATOR)
print(RV_Asset2_DENOMINATOR)
print(RV_Asset2)

HF_CHECK_NUMERATOR = 0.8 * (5.4 - RV_Asset2 * (1 + 0.06)) + 0.85 * 0.1
HF_CHECK_DENOMINATOR = 5.1 - RV_Asset2
HF = HF_CHECK_NUMERATOR/HF_CHECK_DENOMINATOR

print(HF_CHECK_NUMERATOR)
print(HF_CHECK_DENOMINATOR)
print(HF)

The console will print:

-0.6949999999999994 # RV_Asset2_NUMERATOR
-0.1519999999999999 # RV_Asset2_DENOMINATOR
4.57236842105263 # RV_Asset2
0.5276315789473698 # HF_CHECK_NUMERATOR
0.5276315789473696 # HF_CHECK_DENOMINATOR
1.0000000000000004 # HF

Disregarding the floating point number errors, we can confirm that we deduced the correct RVAsset2RV_{Asset2}.

We can now generalize the equation further, from:

RVAsset2=HFafter liquidation(iDVi)+i(LTVi×CVi)((LTVAsset1)(1+LFAsset1))HFafter liquidationRV_{Asset2} = \frac{-\text{HF}_{\text{after liquidation}}(\sum\limits_{i}{DV_i}) + \sum\limits_{i}{(LTV_i \times CV_i)}}{((LTV_{Asset1})(1 + LF_{Asset1})) - \text{HF}_{\text{after liquidation}}}

to:

RVrepaid asset=HFafter liquidation(iDVi)+i(LTVi×CVi)(LTVliquidated asset)(1+LF_liquidated asset)HFafter liquidationRV_{\text{repaid asset}} = \frac{-\text{HF}_{\text{after liquidation}}(\sum\limits_{i}{DV_i}) + \sum\limits_{i}{(LTV_i \times CV_i)}}{(LTV_{\text{liquidated asset}})(1 + LF\_{\text{liquidated asset}}) - \text{HF}_{\text{after liquidation}}}

However, in some cases where more than two assets are borrowed or deposited as collaterals, RVrepaid assetRV_{\text{repaid asset}} can exceed DVrepaid assetDV_{\text{repaid asset}} or CVliquidated assetCV_{\text{liquidated asset}}. In either case, repayment is not valid because repayment amount must be smaller than the debt and must be smaller than the captured collateral amount plus liquidation bonus in order for the liquidation to work.

In such cases, Final Repaid Amountrepaid asset\text{Final Repaid Amount}_{\text{repaid asset}} needs to be reduced down to min(RVrepaid asset,min(DVrepaid asset,CVliquidated asset1+LFliquidated asset))min(RV_{\text{repaid asset}}, min(DV_{\text{repaid asset}}, \frac{CV_{\text{liquidated asset}}}{1 + LF_{\text{liquidated asset}}})).

Below, we review all of the different possibilities for liquidation. We use Asset2=repaid asset\text{Asset2} = \text{repaid asset}, and Asset1=liquidated asset\text{Asset1} = \text{liquidated asset}.

  1. HF1\text{HF} \ge 1

Parameter
Asset 1
Asset 2

LTV ratio

80%

85%

Deposited amount in USD

5.4 USD

0.1 USD

Borrowed amount in USD

0.1 USD

0 USD

Liquidation bonus

6%

7%

In this case, there can't be a liquidation on this account, because the user's position is healthy:

HF=0.8×5.4+0.85×0.10.11\text{HF} = \frac{0.8 \times 5.4 + 0.85 \times 0.1}{0.1} \ge 1
  1. HF1\text{HF} \le 1 and RVrepaid asset=min(RVrepaid asset,min(DVrepaid asset,CVliquidated asset1+LFliquidated asset))RV_{\text{repaid asset}} = min(RV_{\text{repaid asset}}, min(DV_{\text{repaid asset}}, \frac{CV_{\text{liquidated asset}}}{1 + LF_{\text{liquidated asset}}}))

Parameter
Asset 1
Asset 2

LTV ratio

80%

85%

Deposited amount in USD

5.4 USD

0.1 USD

Borrowed amount in USD

0.1 USD

5 USD

Liquidation bonus

6%

7%

This is the example we used previously. HF is smaller than 1:

HF=0.8×5.4+0.85×0.10.1+5=4.4055.11\text{HF} = \frac{0.8 \times 5.4 + 0.85 \times 0.1}{0.1 + 5} = \frac{4.405}{5.1} \le 1

and RVrepaid asset=min(RVrepaid asset,min(DVrepaid asset,CVliquidated asset1+LFliquidated asset)RV_{\text{repaid asset}} = min(RV_{\text{repaid asset}}, min(DV_{\text{repaid asset}}, \frac{CV_{\text{liquidated asset}}}{1 + LF_{\text{liquidated asset}}}):

RVrepaid asset=HFafter liquidation(iDVi)+i(LTVi×CVi)((LTVliquidated asset)(1+LFliquidated asset))HFafter liquidationRV_{\text{repaid asset}} = \frac{-\text{HF}_{\text{after liquidation}}(\sum\limits_{i}{DV_i}) + \sum\limits_{i}{(LTV_i \times CV_i)}}{((LTV_{\text{liquidated asset}})(1 + LF_{\text{liquidated asset}})) - \text{HF}_{\text{after liquidation}}}
    RVAsset2=(1)(5+0.1)+(0.8×5.4+0.85×0.1)((0.8)(1+0.06))1\implies RV_{\text{Asset2}} = \frac{-(1)(5 + 0.1) + (0.8 \times 5.4 + 0.85 \times 0.1)}{((0.8)(1 + 0.06)) - 1}
    RVAsset2=4.57236842105263...\implies RV_{\text{Asset2}} = 4.57236842105263...
  1. HF1\text{HF} \le 1 and Final Repaid Amountrepaid asset=CVliquidated asset1+LFliquidated asset=min(RVrepaid asset,min(DVrepaid asset,CVliquidated asset1+LFliquidated asset)\text{Final Repaid Amount}_{\text{repaid asset}} = \frac{CV_{\text{liquidated asset}}}{1 + LF_{\text{liquidated asset}}} = min(RV_{\text{repaid asset}}, min(DV_{\text{repaid asset}}, \frac{CV_{\text{liquidated asset}}}{1 + LF_{\text{liquidated asset}}})

Put simply, this is when the amount of collateral to be liquidated isn't enough to bring HF back to 1, because the user has multiple collaterals.

Parameter
Asset 1
Asset 2

LTV ratio

80%

85%

Deposited amount in USD

3 USD

2.5 USD

Borrowed amount in USD

0.1 USD

5 USD

Liquidation bonus

6%

7%

Calculate HF first:

HF=0.8×3+0.85×2.50.1+5=4.5255.11\text{HF} = \frac{0.8 \times 3 + 0.85 \times 2.5}{0.1 + 5} = \frac{4.525}{5.1} \le 1
RVAsset2=(1)(5+0.1)+(0.8×3+0.85×2.5)((0.8)(1+0.06))1=3.7828947368421026...RV_{\text{Asset2}} = \frac{-(1)(5 + 0.1) + (0.8 \times 3 + 0.85 \times 2.5)}{((0.8)(1 + 0.06)) - 1} = 3.7828947368421026...
3.7828947368421026...CVAsset1CVAsset1=33.7828947368421026... \ge CV_{Asset1} \because CV_{Asset1} = 3
3.7828947368421026...DVAsset2DVAsset2=53.7828947368421026... \le DV_{Asset2} \because DV_{Asset2} = 5
    Final Repaid AmountAsset2=CVAsset11+LFAsset1=min(RVrepaid asset,min(DVrepaid asset,CVAsset11+LFAsset1)\implies \text{Final Repaid Amount}_{Asset2} = \frac{CV_{\text{Asset1}}}{1 + LF_{\text{Asset1}}} = min(RV_{\text{repaid asset}}, min(DV_{\text{repaid asset}}, \frac{CV_{\text{Asset1}}}{1 + LF_{\text{Asset1}}})

Therefore, we can only repay 31+LFAsset1=31.06=2.830188679....\frac{3}{1 + LF_{\text{Asset1}}} = \frac{3}{1.06} = 2.830188679.... in this scenario. HF will not be fully restored back to 1. The denominator exists to account for the liquidation bonus, so that we can get 3 USD as the value of captured collateral plus liquidation bonus, which is the maximum we can get from the deposited Asset 2 collateral. But liquidation should still run regardless.

Here's HFafter liquidation\text{HF}_{\text{after liquidation}}:

HFafter liquidation=LTVAsset1×(CVAsset1(Final Repaid AmountAsset2)(1+LFAsset1))+LTVAsset2×CVAsset2DVAsset1+DVAsset2Final Repaid AmountAsset2\text{HF}_{\text{after liquidation}} = \frac{LTV_{Asset1} \times (CV_{Asset1} - (\text{Final Repaid Amount}_{Asset2})(1 + LF_{\text{Asset1}})) + LTV_{Asset2} \times CV_{Asset2}}{DV_{Asset1} + DV_{Asset2} - \text{Final Repaid Amount}_{Asset2}}
=0+LTVAsset2×CVAsset2DVAsset1+DVAsset2Final Repaid AmountAsset2= \frac{0 + LTV_{Asset2} \times CV_{Asset2}}{DV_{Asset1} + DV_{Asset2} - \text{Final Repaid Amount}_{Asset2}}
=0+2.5×0.855.12.5=2.1252.6=0.81730769....= \frac{0 + 2.5 \times 0.85}{5.1 - 2.5} = \frac{2.125}{2.6} = 0.81730769....

Notice that we will need to liquidate the other collateral to fully recover the health factor back to 1.

  1. DVrepaid asset=min(RVrepaid asset,min(DVrepaid asset,CVliquidated asset1+LFliquidated asset)DV_{\text{repaid asset}} = min(RV_{\text{repaid asset}}, min(DV_{\text{repaid asset}}, \frac{CV_{\text{liquidated asset}}}{1 + LF_{\text{liquidated asset}}})

This is when the amount of debt to be repaid isn't enough to bring HF back to 1 because the user has multiple assets in debt, and this amount is smaller than the collateral that can be captured.

Parameter
Asset 1
Asset 2

LTV ratio

80%

85%

Deposited amount in USD

5.4 USD

0.1 USD

Borrowed amount in USD

2.5 USD

2.6 USD

Liquidation bonus

6%

7%

Again, we are repaying Asset 2 and liquidating Asset 1:

RVAsset 2=(1)(2.5+2.6)+(0.8×5.4+0.85×0.1)((0.8)(1+0.06))1RV_{\text{Asset 2}} = \frac{-(1)(2.5 + 2.6) + (0.8 \times 5.4 + 0.85 \times 0.1)}{((0.8)(1 + 0.06)) - 1}
=4.57236842105263...= 4.57236842105263...

This means we want to liquidate 4.57236842105263 USD equivalent of Asset 2, but we cannot because the user only has 2.6 USD worth of Asset 2 in debt, thus:

Final repaid amountAsset2=min(4.57236842105263,min(2.6,5.41.06))\text{Final repaid amount}_{Asset2} = min(4.57236842105263, min(2.6, \frac{5.4}{1.06}))
=2.6= 2.6

This won't recover HF back to 1. It will require another liquidation to be run to repay Asset 2 and liquidate Asset 1.

Last updated