liquidate/burn collateral

Overview

Execution flow

liquidate/burn collateral

Drawing

If liquidator has opted to receive aTokens in payment (params.receiveAToken == true)

  • _liquidateATokens will be executed

  • Else: _burnCollatearlATokens will be executed

_liquidateATokens

Transfers aTokens from the target user to the liquidator.

  • Amount transferred: debtRepaid + liquidation penalty (in collateral terms)

  • If the liquidator did not have aTokens of this kind previously,

    • validateUseAsCollateral

    • setUsingAsCollateral

validateUseAsCollateral ensures that liquidator is not in isolation mode and the incoming asset is not an isolation mode asset.

If these conditions are met, the reserve transferred to the liquidator is set to be used as collateral.

transferOnLiquidiation calls _transfer, which executes the transfer of aTokens.

  • validate is set to false, therefore finalizeTransfer is not executed

For explanations on validateUseAsCollateral and setUsingAsCollateral, please see the supply section on the following segments:

Where possible, Aave opts to set supplied assets as collateral automatically. The exception to this are isolated assets.

_burnCollateralATokens

If the liquidator does not wish to receive ATokens, the alternative would be to transfer the underlying asset to them (instead of aDAI, transfer DAI).

To enact a transfer of the underlying asset, its corresponding aTokens must be "redeemed". Effectively, this means that liquidity is being removed from the system. This would therefore impact interest rates, and they have to be updated.

Hence, updateInterestRates is executed with parameters:

  • liquidityAdded = 0

  • liquidityRemoved = actualCollateralToLiquidate

Lastly, burn is executed.

  • _burnScaled: burn scaledAmount and update user balances

  • safeTransfer underlying asset from target user to liquidator

Last updated

Was this helpful?