Skip to content

Commit

Permalink
fix: Fix condition of full liquidation of collateral (#753)
Browse files Browse the repository at this point in the history
  • Loading branch information
miguelmtzinf authored Dec 7, 2022
1 parent 43f34c9 commit 56bcf5d
Showing 1 changed file with 4 additions and 8 deletions.
12 changes: 4 additions & 8 deletions contracts/protocol/libraries/logic/LiquidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 56bcf5d

Please sign in to comment.