Llama Lend Tutorial 7 has been released, covering how to perform a pure liquidation on an insolvent user.
Pure liquidation in LLAMMA is possible when a borrower's health is negative and their collateral has been converted to stablecoin in a quantity that covers the outstanding debt.
For this tutorial and the next two, we diverge somewhat from the prior tutorials in the series. Prior tutorials focused on a hypothetical new market launched using a memecoin, whereas this one builds atop the curvefi/liquidation-demo repository, the result of the hard work of Macket7. This repo provides examples of three types of LLAMMA liquidations. Pure liquidations is covered in this tutorial, and the next two in the pipeline are extended and partial liquidations.
A novel feature of Macketโs script is the ability to trade the market's AMM to bring the simulated borrower right to the point of liquidation.
This trades the AMM pool from the starting price of BTC down to p_down
(aka the bottom price in the collateral range). This is accomplished by looping through a while loop until the borrowerโs health is at this mark, then trading upwards and downwards in ~1% increments until the userโs health is negative and the while loop concludes.
Throughout the process, the userโs health steadily erodes:
To accomplish this perfect decay, the price of BTC undergoes an interesting trajectory, dumped repeatedly then oscillating around the p_down
price.
This leaves the borrower in an unhealthy state and ready for liquidation.
Their loan of $49.3K $crvUSD is collateralized by $WBTC that was converted to $crvUSD, worth $50.8K. They also have a few hundred dollars of $WBTC that was unconverted in the process.
Because the user's debt is covered by stablecoin, the liquidation is a "Pure Liquidation". The liquidator needed no extra steps, other than calling the `controller.liquidate()` function and passing in a pair of parameters.
The easiest possible liquidation to earn $1.8K!
What if the user is in an unhealthy state but their stablecoin collateral does not cover their debt? This requires an extended liquidation, which we cover in the next tutorial video.
Or you can check Macketโs aforementioned curvefi/liquidation-demo repo for details!