From e4dc22e50ed2864787f06fd8154b1bc46483f571 Mon Sep 17 00:00:00 2001 From: emilio Date: Thu, 29 Oct 2020 18:03:19 +0100 Subject: [PATCH 1/3] Fixed events, removed unused constants in addressesProvider --- .../LendingPoolAddressesProvider.sol | 5 ----- contracts/interfaces/ILendingPool.sol | 2 +- contracts/lendingpool/LendingPool.sol | 2 +- .../lendingpool/LendingPoolConfigurator.sol | 20 +++++++++---------- deployed-contracts.json | 9 +++++---- 5 files changed, 17 insertions(+), 21 deletions(-) diff --git a/contracts/configuration/LendingPoolAddressesProvider.sol b/contracts/configuration/LendingPoolAddressesProvider.sol index 15b37635..38aa1280 100644 --- a/contracts/configuration/LendingPoolAddressesProvider.sol +++ b/contracts/configuration/LendingPoolAddressesProvider.sol @@ -19,16 +19,11 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider mapping(bytes32 => address) private _addresses; bytes32 private constant LENDING_POOL = 'LENDING_POOL'; - bytes32 private constant LENDING_POOL_CORE = 'LENDING_POOL_CORE'; bytes32 private constant LENDING_POOL_CONFIGURATOR = 'LENDING_POOL_CONFIGURATOR'; bytes32 private constant AAVE_ADMIN = 'AAVE_ADMIN'; bytes32 private constant LENDING_POOL_COLLATERAL_MANAGER = 'COLLATERAL_MANAGER'; - bytes32 private constant LENDING_POOL_FLASHLOAN_PROVIDER = 'FLASHLOAN_PROVIDER'; - bytes32 private constant DATA_PROVIDER = 'DATA_PROVIDER'; - bytes32 private constant ETHEREUM_ADDRESS = 'ETHEREUM_ADDRESS'; bytes32 private constant PRICE_ORACLE = 'PRICE_ORACLE'; bytes32 private constant LENDING_RATE_ORACLE = 'LENDING_RATE_ORACLE'; - bytes32 private constant WALLET_BALANCE_PROVIDER = 'WALLET_BALANCE_PROVIDER'; /** * @dev Sets an address for an id, allowing to cover it or not with a proxy diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index 450def2d..2e4e2d94 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -74,7 +74,7 @@ interface ILendingPool { * @param reserve the address of the reserve * @param user the address of the user executing the swap **/ - event Swap(address indexed reserve, address indexed user); + event Swap(address indexed reserve, address indexed user, uint256 rateMode); /** * @dev emitted when a user enables a reserve as collateral diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 539b6ac6..2aa45f84 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -352,7 +352,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage reserve.updateInterestRates(asset, reserve.aTokenAddress, 0, 0); - emit Swap(asset, msg.sender); + emit Swap(asset, msg.sender, rateMode); } /** diff --git a/contracts/lendingpool/LendingPoolConfigurator.sol b/contracts/lendingpool/LendingPoolConfigurator.sol index c3da634c..1428805e 100644 --- a/contracts/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/lendingpool/LendingPoolConfigurator.sol @@ -47,7 +47,7 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param asset the address of the reserve * @param stableRateEnabled true if stable rate borrowing is enabled, false otherwise **/ - event BorrowingEnabledOnReserve(address asset, bool stableRateEnabled); + event BorrowingEnabledOnReserve(address indexed asset, bool stableRateEnabled); /** * @dev emitted when borrowing is disabled on a reserve @@ -116,42 +116,42 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param asset the address of the reserve * @param ltv the new value for the loan to value **/ - event ReserveBaseLtvChanged(address asset, uint256 ltv); + event ReserveBaseLtvChanged(address indexed asset, uint256 ltv); /** * @dev emitted when a reserve factor is updated * @param asset the address of the reserve * @param factor the new reserve factor **/ - event ReserveFactorChanged(address asset, uint256 factor); + event ReserveFactorChanged(address indexed asset, uint256 factor); /** * @dev emitted when a reserve liquidation threshold is updated * @param asset the address of the reserve * @param threshold the new value for the liquidation threshold **/ - event ReserveLiquidationThresholdChanged(address asset, uint256 threshold); + event ReserveLiquidationThresholdChanged(address indexed asset, uint256 threshold); /** * @dev emitted when a reserve liquidation bonus is updated * @param asset the address of the reserve * @param bonus the new value for the liquidation bonus **/ - event ReserveLiquidationBonusChanged(address asset, uint256 bonus); + event ReserveLiquidationBonusChanged(address indexed asset, uint256 bonus); /** * @dev emitted when the reserve decimals are updated * @param asset the address of the reserve * @param decimals the new decimals **/ - event ReserveDecimalsChanged(address asset, uint256 decimals); + event ReserveDecimalsChanged(address indexed asset, uint256 decimals); /** * @dev emitted when a reserve interest strategy contract is updated * @param asset the address of the reserve * @param strategy the new address of the interest strategy contract **/ - event ReserveInterestRateStrategyChanged(address asset, address strategy); + event ReserveInterestRateStrategyChanged(address indexed asset, address strategy); /** * @dev emitted when an aToken implementation is upgraded @@ -159,7 +159,7 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param proxy the aToken proxy address * @param implementation the new aToken implementation **/ - event ATokenUpgraded(address asset, address proxy, address implementation); + event ATokenUpgraded(address indexed asset, address indexed proxy, address indexed implementation); /** * @dev emitted when the implementation of a stable debt token is upgraded @@ -167,7 +167,7 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param proxy the stable debt token proxy address * @param implementation the new aToken implementation **/ - event StableDebtTokenUpgraded(address asset, address proxy, address implementation); + event StableDebtTokenUpgraded(address indexed asset, address indexed proxy, address indexed implementation); /** * @dev emitted when the implementation of a variable debt token is upgraded @@ -175,7 +175,7 @@ contract LendingPoolConfigurator is VersionedInitializable { * @param proxy the variable debt token proxy address * @param implementation the new aToken implementation **/ - event VariableDebtTokenUpgraded(address asset, address proxy, address implementation); + event VariableDebtTokenUpgraded(address indexed asset, address indexed proxy, address indexed implementation); ILendingPoolAddressesProvider internal addressesProvider; ILendingPool internal pool; diff --git a/deployed-contracts.json b/deployed-contracts.json index 9690522a..401a2694 100644 --- a/deployed-contracts.json +++ b/deployed-contracts.json @@ -163,25 +163,26 @@ }, "ReserveLogic": { "buidlerevm": { - "address": "0xFAe0fd738dAbc8a0426F47437322b6d026A9FD95", + "address": "0x78Ee8Fb9fE5abD5e347Fc94c2fb85596d1f60e3c", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "GenericLogic": { "buidlerevm": { - "address": "0x6082731fdAba4761277Fb31299ebC782AD3bCf24", + "address": "0x920d847fE49E54C19047ba8bc236C45A8068Bca7", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "ValidationLogic": { "buidlerevm": { - "address": "0x8456161947DFc1fC159A0B26c025cD2b4bba0c3e", + "address": "0xA4765Ff72A9F3CfE73089bb2c3a41B838DF71574", "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "LendingPool": { "buidlerevm": { - "address": "0xD9273d497eDBC967F39d419461CfcF382a0A822e" + "address": "0x35c1419Da7cf0Ff885B8Ef8EA9242FEF6800c99b", + "deployer": "0xc783df8a850f42e7F7e57013759C285caa701eB6" } }, "LendingPoolConfigurator": { From 7ae9a2df8f6acd99f25ac02f3a0020e5d9b04782 Mon Sep 17 00:00:00 2001 From: emilio Date: Fri, 30 Oct 2020 11:36:53 +0100 Subject: [PATCH 2/3] Updated variable names --- contracts/libraries/logic/ValidationLogic.sol | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/contracts/libraries/logic/ValidationLogic.sol b/contracts/libraries/logic/ValidationLogic.sol index 78f74154..d9824835 100644 --- a/contracts/libraries/logic/ValidationLogic.sol +++ b/contracts/libraries/logic/ValidationLogic.sol @@ -258,8 +258,8 @@ library ValidationLogic { function validateSwapRateMode( ReserveLogic.ReserveData storage reserve, UserConfiguration.Map storage userConfig, - uint256 stableBorrowBalance, - uint256 variableBorrowBalance, + uint256 stableDebt, + uint256 variableDebt, ReserveLogic.InterestRateMode currentRateMode ) external view { (bool isActive, bool isFreezed, , bool stableRateEnabled) = reserve.configuration.getFlags(); @@ -268,9 +268,9 @@ library ValidationLogic { require(!isFreezed, Errors.NO_UNFREEZED_RESERVE); if (currentRateMode == ReserveLogic.InterestRateMode.STABLE) { - require(stableBorrowBalance > 0, Errors.NO_STABLE_RATE_LOAN_IN_RESERVE); + require(stableDebt > 0, Errors.NO_STABLE_RATE_LOAN_IN_RESERVE); } else if (currentRateMode == ReserveLogic.InterestRateMode.VARIABLE) { - require(variableBorrowBalance > 0, Errors.NO_VARIABLE_RATE_LOAN_IN_RESERVE); + require(variableDebt > 0, Errors.NO_VARIABLE_RATE_LOAN_IN_RESERVE); /** * user wants to swap to stable, before swapping we need to ensure that * 1. stable borrow rate is enabled on the reserve @@ -283,7 +283,7 @@ library ValidationLogic { require( !userConfig.isUsingAsCollateral(reserve.id) || reserve.configuration.getLtv() == 0 || - stableBorrowBalance.add(variableBorrowBalance) > + stableDebt.add(variableDebt) > IERC20(reserve.aTokenAddress).balanceOf(msg.sender), Errors.CALLATERAL_SAME_AS_BORROWING_CURRENCY ); From a49f2744ee888f16e88ed79c6f9893d64249e6c2 Mon Sep 17 00:00:00 2001 From: emilio Date: Fri, 30 Oct 2020 11:38:49 +0100 Subject: [PATCH 3/3] Updated comments --- contracts/libraries/logic/ValidationLogic.sol | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/contracts/libraries/logic/ValidationLogic.sol b/contracts/libraries/logic/ValidationLogic.sol index d9824835..adbfdfc7 100644 --- a/contracts/libraries/logic/ValidationLogic.sol +++ b/contracts/libraries/logic/ValidationLogic.sol @@ -251,8 +251,8 @@ library ValidationLogic { * @dev validates a swap of borrow rate mode. * @param reserve the reserve state on which the user is swapping the rate * @param userConfig the user reserves configuration - * @param stableBorrowBalance the stable borrow balance of the user - * @param variableBorrowBalance the stable borrow balance of the user + * @param stableDebt the stable debt of the user + * @param variableDebt the variable debt of the user * @param currentRateMode the rate mode of the borrow */ function validateSwapRateMode(