Roles - Liquidator

For a user perspective of liquidator actions, visit this page.

Summary

The purpose of a liquidator is to liquidate a Twyne collateral vault. When a vault can be liquidated, the liquidator will take ownership of the collateral vault if the liquidation succeeds. In order for the liquidation to succeed, the collateral vault must be made healthy at the end of the batch of operations. This can be done in two ways:

  1. Repaying debt. The usual approach for just-in-time liquidators is to repay all debt, withdraw all collateral, and empty the position to zero.
  2. Increasing the collateral. This makes sense if a liquidator wants to become a Twyne user or hold the collateral for a certain period of time.

Function Calls

To check whether a collateral vault can be liquidated, call canLiquidate()(bool). If the function returns true, the collateral vault can be liquidated.

To perform the liquidation, repay all debt, and withdraw all collateral, the liquidate and repay actions must happen inside of the same EVC batch in order to make the position healthy (not liquidatable). First liquidate()() must be called to give the liquidator control over the collateral vault, then repay(uint)() must be called to repay the debt that the collateral vault owes to the underlying protocol. The repay(uint)() function requires that the liquidator has approved the target asset to the collateral vault, so if the collateral vault is borrowing USDC from the underlying protocol, the liquidator must approve the collateral vault for USDC before the batch containing repay(uint)() occurs. A maxRepay()(uint) helper function exists to easily return the maximum amount of debt that must be repaid, but passing type(uint).max as the input value to repay(uint)() will automatically use the maxRepay value. An example of this flow is found in the test_e_liquidate_make_healthy_reduce_debt() test in the code repository.

results matching ""

    No results matching ""