Poolor 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).
liquidationCall(), you must:
user) whose health factor is below 1.
CLOSE_FACTOR_HF_THRESHOLD, then only a maximum of 50% (i.e.
DEFAULT_LIQUIDATION_CLOSE_FACTOR) of the debt can be liquidated per valid
CLOSE_FACTOR_HF_THRESHOLD, then 100% (i.e.
MAX_LIQUIDATION_CLOSE_FACTOR) of the debt can be liquidated in single valid
uint(-1)and the protocol will proceed with the highest possible liquidation allowed by the close factor.
liquidationCallto pay back the debt. You can use
flashLoanfor liquidations 😉
collateralAssetyou closing, i.e. the asset that the user has
backingtheir outstanding loan that you will receive as a
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.
CLOSE_FACTOR_HF_THRESHOLD < HF < 1) or
HF < CLOSE_FACTOR_HF_THRESHOLD)
debtToCover = (userStableDebt + userVariableDebt) * LiquidationCloseFactor
MAX_UINT, as the
debtToCoverto liquidate the maximum amount allowed.
maxAmountOfCollateralToLiquidate = (debtAssetPrice * debtToCover * liquidationBonus)/ collateralPrice
maxAmountOfCollateralToLiquidate * (1 - liquidationBonus) * collateralAssetPriceEth
estimateGasvia your web3 provider.
usageAsCollateralis 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).