From 3f7d913fd43020328c827db4f5e045c9ce59c6b4 Mon Sep 17 00:00:00 2001 From: emilio Date: Thu, 29 Oct 2020 13:43:24 +0100 Subject: [PATCH] Fixed issue on 0 transfer, added check that the caller must be an aToken --- contracts/lendingpool/LendingPool.sol | 4 +++- contracts/libraries/helpers/Errors.sol | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index fde9d760..1684247e 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -742,6 +742,8 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage ) external override { _whenNotPaused(); + require(msg.sender == _reserves[asset].aTokenAddress, Errors.CALLER_MUST_BE_AN_ATOKEN); + ValidationLogic.validateTransfer( from, _reserves, @@ -759,7 +761,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage fromConfig.setUsingAsCollateral(reserveId, false); } - if (balanceToBefore == 0) { + if (balanceToBefore == 0 && amount != 0) { UserConfiguration.Map storage toConfig = _usersConfig[to]; toConfig.setUsingAsCollateral(reserveId, true); } diff --git a/contracts/libraries/helpers/Errors.sol b/contracts/libraries/helpers/Errors.sol index 9ed7b07e..b515603f 100644 --- a/contracts/libraries/helpers/Errors.sol +++ b/contracts/libraries/helpers/Errors.sol @@ -46,6 +46,7 @@ library Errors { string public constant NO_MORE_RESERVES_ALLOWED = '59'; string public constant INVALID_FLASH_LOAN_EXECUTOR_RETURN = '60'; string public constant INCONSISTENT_FLASHLOAN_PARAMS = '69'; + string public constant CALLER_MUST_BE_AN_ATOKEN = '76'; // require error messages - aToken - DebtTokens string public constant CALLER_MUST_BE_LENDING_POOL = '28'; // 'The caller of this function must be a lending pool'