<aside> 💡 These equations are not calculated in contract. On the contract, the branching for the three outcomes are done through simpler comparisons. These equations are noted to mathematically define the potential outcomes for analysis and testing purposes.

</aside>

Key

LV - Liability Value

TH - Target Health

CV - Collateral Value

LT - Liquidation threshold

D - Discounted Price

ER - Exchange Rate

CB - Collateral Balance

When does this lead to partial liquidation?

Partial liquidation occurs if

$$ liabilityValue - repayAmount >= dust $$


$$ LV - \frac{TH*LV-CV}{TH-\frac{LT}{1-D}} $$

$$ LV(TH-\frac{LT}{1-D})-(TH*LV-CV)\ge dust(TH-\frac{LT}{1-D}) $$

$$ LVTH-\frac{LVLT}{1-D}-(TH*LV-CV)\ge dust(TH-\frac{LT}{1-D}) $$

$$ CV-\frac{LV*LT}{1-D}\ge dust (TH-\frac{LT}{1-D}) $$

Now, recall discount is just $1 - healthRatio$.

$$ 1-D=(1-(1-H))=H=\frac{CV}{LV} $$

Subsituting the $H$ into the $1 - D$ ,