liquidationCall()
to the Pool
or L2Pool (in case of Arbitrum/Optimism) contract, pay back part of the debt owed and receive discounted collateral in return (also known as the liquidation bonus). MAX_LIQUIDATION_CLOSE_FACTOR
) to be liquidated in single liquidationCall()
if:
HF < CLOSE_FACTOR_HF_THRESHOLD
liquidationCall()
, you must:user
) whose health factor is below 1.debtToCover
& debtAsset
)CLOSE_FACTOR_HF_THRESHOLD
, then only a maximum of 50% (i.e. DEFAULT_LIQUIDATION_CLOSE_FACTOR
) of the debt can be liquidated per valid liquidationCall()
CLOSE_FACTOR_HF_THRESHOLD
, then 100% (i.e. MAX_LIQUIDATION_CLOSE_FACTOR
) of the debt can be liquidated in single valid liquidationCall()
debtToCover
to uint(-1)
and the protocol will proceed with the highest possible liquidation allowed by the close factor.liquidationCall
to pay back the debt. You can use flashLoan
for liquidations 😉collateralAsset
you closing, i.e. the asset that the user has backing
their outstanding loan that you will receive as a bonus
.liquidationCall()
.getUserAccountData()
, to read the user's current healthFactor. If the HF < 1, then the account can be liquidated.healthFactor,
you will need to compute this locally. The easiest way is to use the Aave-utilities sdk, which has methods to compute user summary data.DEFAULT_LIQUIDATION_CLOSE_FACTOR
(when CLOSE_FACTOR_HF_THRESHOLD < HF < 1
) or MAX_LIQUIDATION_CLOSE_FACTOR
(when HF < CLOSE_FACTOR_HF_THRESHOLD
)debtToCover = (userStableDebt + userVariableDebt) * LiquidationCloseFactor
uint(-1)
, i.e. MAX_UINT
, as the debtToCover
to liquidate the maximum amount allowed.usageAsCollateralEnabled
as true.maxAmountOfCollateralToLiquidate = (debtAssetPrice * debtToCover * liquidationBonus)/ collateralPrice
maxAmountOfCollateralToLiquidate * (1 - liquidationBonus) * collateralAssetPriceEth
estimateGas
via your web3 provider.usageAsCollateral
is enabled, balance (in ETH) multiplied by the liquidation threshold percentage for all the user's outstanding assets, divided by the user's total borrow balance across all reserves (in ETH).