diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 95af83b1..6afb3eed 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -575,7 +575,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage vars.amountPlusPremium = amount.add(vars.premium); if (debtMode == ReserveLogic.InterestRateMode.NONE) { - IERC20(asset).transferFrom(receiverAddress, vars.aTokenAddress, vars.amountPlusPremium); + IERC20(asset).safeTransferFrom(receiverAddress, vars.aTokenAddress, vars.amountPlusPremium); reserve.updateState(); reserve.cumulateToLiquidityIndex(IERC20(vars.aTokenAddress).totalSupply(), vars.premium); @@ -583,7 +583,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage emit FlashLoan(receiverAddress, asset, amount, vars.premium, referralCode); } else { - // If the transfer didn't succeed, the receiver either didn't return the funds, or didn't approve the transfer. + //if the user didn't choose to return the funds, the system checks if there + //is enough collateral and eventually open a position _executeBorrow( ExecuteBorrowParams( asset, diff --git a/contracts/lendingpool/LendingPoolCollateralManager.sol b/contracts/lendingpool/LendingPoolCollateralManager.sol index fab8b71f..fad590be 100644 --- a/contracts/lendingpool/LendingPoolCollateralManager.sol +++ b/contracts/lendingpool/LendingPoolCollateralManager.sol @@ -404,7 +404,7 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor vars.actualAmountToLiquidate, 0 ); - IERC20(principal).transferFrom(receiver, vars.principalAToken, vars.actualAmountToLiquidate); + IERC20(principal).safeTransferFrom(receiver, vars.principalAToken, vars.actualAmountToLiquidate); if (vars.userVariableDebt >= vars.actualAmountToLiquidate) { IVariableDebtToken(debtReserve.variableDebtTokenAddress).burn( @@ -504,7 +504,7 @@ contract LendingPoolCollateralManager is VersionedInitializable, LendingPoolStor vars.amountToReceive = IERC20(toAsset).balanceOf(receiverAddress); if (vars.amountToReceive != 0) { - IERC20(toAsset).transferFrom( + IERC20(toAsset).safeTransferFrom( receiverAddress, address(vars.toReserveAToken), vars.amountToReceive