π Boa Tutorial 9: Partial Liquidation π
Understanding the effect of the LLAMMA "Liquidation Discount"
LLAMMA users in bad health can be partially liquidated. The process works similar to other liquidations, except a "liquidation discount" is applied.
It's straightforward to imagine the cases where you might find it preferable to run a partial liquidation as opposed to a full liquidation.
For example, if you're trying to liquidate a whale, what if a full liquidation would impact the price too much?
In this unit, we rerun the scenario from prior units, but only liquidate 10% of the user's position.
We recommend to review the prior two units to better follow this lesson.
Lesson 7: Pure Liquidation
Lesson 8: Extended Liquidation
In LLAMMA controllers, a partial liquidation proceeds as before, except a value for "frac" is passed, representing the % to liquidate (100% == 10**18)
This triggers the _get_f_remove() function to calculate the amount to withdraw, because it may not be 1:1
The controller's comments explain:
"When frac is set - we withdraw a bit less for the same debt fraction"
That is, depending on if the vault applies a liquidation discount, a 10% liquidation means the liquidator gets <10% in return, as calculated in _get_f_remove()
The formula is a function of frac, the % you want to liquidate, and h, a health limit factor running from 0-1
Note from the formula chosen so if h = 0, the whole parentheses simply reduces to 1 and the penalty disappears: f_remove == frac
Similarly, if frac approaches 0 or frac approaches 1, f_remove approaches 0. Plotting different scenarios helps to visualize the liquidation discount.
When h=0 (blue) the line is linear with slope of 1.
As h approaches 1 (red), a slight discount is applied, which shows up in the graph as a slight arc.
Plotting this discount relative to h=0, you see the formula has the nice property where any penalty is maximized for a 50% liquidation, about 6% at the most.
The penalty reduces evenly as the liquidation fraction approaches 0% or 100%.
The example we run through in the associated Jupyter Notebook sees a 10% liquidation receive 9.84% of collateral.
This slight difference ends up improving the user's health, which could be considered as another potential reason to run a partial liquidation.
After the partial liquidation of 10% the user_state improves proportionally.
Understanding partial liquidations and the liquidation discount is important to understand LLAMMA!