diff --git a/contracts/protocol/libraries/logic/LiquidationLogic.sol b/contracts/protocol/libraries/logic/LiquidationLogic.sol index f03edbbce..aea7040b0 100644 --- a/contracts/protocol/libraries/logic/LiquidationLogic.sol +++ b/contracts/protocol/libraries/logic/LiquidationLogic.sol @@ -168,7 +168,10 @@ library LiquidationLogic { // If the collateral being liquidated is equal to the user balance, // we set the currency as not being used as collateral anymore - if (vars.actualCollateralToLiquidate == vars.userCollateralBalance) { + if ( + vars.actualCollateralToLiquidate + vars.liquidationProtocolFeeAmount == + vars.userCollateralBalance + ) { userConfig.setUsingAsCollateral(collateralReserve.id, false); emit ReserveUsedAsCollateralDisabled(params.collateralAsset, params.user); } @@ -214,13 +217,6 @@ library LiquidationLogic { ); } - // If the collateral being liquidated is equal to the user balance, - // we set the currency as not being used as collateral anymore - if (vars.actualCollateralToLiquidate + vars.liquidationProtocolFeeAmount == vars.userCollateralBalance) { - userConfig.setUsingAsCollateral(collateralReserve.id, false); - emit ReserveUsedAsCollateralDisabled(params.collateralAsset, params.user); - } - // Transfers the debt asset being repaid to the aToken, where the liquidity is kept IERC20(params.debtAsset).safeTransferFrom( msg.sender,