Skip to content

Commit

Permalink
fix: reentrancy in liquidationCall
Browse files Browse the repository at this point in the history
  • Loading branch information
The-3D committed Aug 8, 2022
1 parent e8c5b64 commit cd508a7
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions contracts/protocol/libraries/logic/LiquidationLogic.sol
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,13 @@ library LiquidationLogic {
if (vars.userTotalDebt == vars.actualDebtToLiquidate) {
userConfig.setBorrowing(debtReserve.id, false);
}

// 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) {
userConfig.setUsingAsCollateral(collateralReserve.id, false);
emit ReserveUsedAsCollateralDisabled(params.collateralAsset, params.user);
}

_burnDebtTokens(params, vars);

Expand Down Expand Up @@ -198,13 +205,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.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 cd508a7

Please sign in to comment.