Skip to content

Latest commit

 

History

History

lesson-09-partial-liquidation

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 

Lesson 9: Extended Liquidation

LLAMMA borrowers in bad health can be "partially" liquidated. The process works similar to other liquidations, except a "liquidation discount" applies.

This is the third in a series of lessons that build atop the curvefi/liquidation-demo repository by Curve team member @Macket. The source script is provided in the demo folder.

LIQUIDATION DISCOUNT

When frac, a liquidation fraction, is passed during a liquidation, the controller calls the _get_f_remove() function to calculate the liquidation discount.

The controller documents it:

    # Withdraw sender's stablecoin and collateral to our contract
    # When frac is set - we withdraw a bit less for the same debt fraction
    # f_remove = ((1 + h/2) / (1 + h) * (1 - frac) + frac) * frac
    # where h is health limit.
    # This is less than full h discount but more than no discount
    xy: uint256[2] = AMM.withdraw(user, self._get_f_remove(frac, health_limit))  # [stable, collateral]

Observe the formula is selected to reduce nicely when h=0 or frac approaches 0 or 1.

image

The effect can be observed when plotted, such that h=0 (blue) reduces to a direct linear relationship between the value of frac and f_remove, the amount received.

image

Plotted relative to the case of h=0, you see the curve is balanced such as to maximize the liquidation penalty at ~6% when frac is set to 0.5 and reducing to no penalty as frac approaches 0 or 1.

image

When the partial liquidation is complete, the liquidator receives 9.84% of collateral for a 10% liquidation, slightly improving the user's health.

image

HELPFUL LINKS