From b68bb992fb6bb718790f35ec9c43e4340e68e1c1 Mon Sep 17 00:00:00 2001 From: The3D Date: Wed, 19 Aug 2020 16:36:58 +0200 Subject: [PATCH 1/5] Cleaned up reserveLogic --- contracts/libraries/ReserveLogic.sol | 148 +++++++-------------------- 1 file changed, 35 insertions(+), 113 deletions(-) diff --git a/contracts/libraries/ReserveLogic.sol b/contracts/libraries/ReserveLogic.sol index 47cd897e..bc0fe15e 100644 --- a/contracts/libraries/ReserveLogic.sol +++ b/contracts/libraries/ReserveLogic.sol @@ -5,7 +5,7 @@ import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {MathUtils} from './MathUtils.sol'; import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; -import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; +import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; import {ReserveConfiguration} from './ReserveConfiguration.sol'; @@ -25,16 +25,35 @@ library ReserveLogic { using SafeMath for uint256; using WadRayMath for uint256; using SafeERC20 for IERC20; - using Address for address; + + /** + * @dev Emitted when the state of a reserve is updated + * @dev NOTE: This event replaces the Deprecated ReserveUpdated() event, which didn't emit the average stable borrow rate + * @param reserve the address of the reserve + * @param liquidityRate the new liquidity rate + * @param stableBorrowRate the new stable borrow rate + * @param averageStableBorrowRate the new average stable borrow rate + * @param variableBorrowRate the new variable borrow rate + * @param liquidityIndex the new liquidity index + * @param variableBorrowIndex the new variable borrow index + **/ + event ReserveDataUpdated( + address indexed reserve, + uint256 liquidityRate, + uint256 stableBorrowRate, + uint256 averageStableBorrowRate, + uint256 variableBorrowRate, + uint256 liquidityIndex, + uint256 variableBorrowIndex + ); + using ReserveLogic for ReserveLogic.ReserveData; using ReserveConfiguration for ReserveConfiguration.Map; enum InterestRateMode {NONE, STABLE, VARIABLE} + // refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. struct ReserveData { - /** - * @dev refer to the whitepaper, section 1.1 basic concepts for a formal description of these properties. - **/ //the liquidity index. Expressed in ray uint256 lastLiquidityCumulativeIndex; //the current supply rate. Expressed in ray @@ -45,27 +64,21 @@ library ReserveLogic { uint256 currentStableBorrowRate; //variable borrow index. Expressed in ray uint256 lastVariableBorrowCumulativeIndex; + //stores the reserve configuration ReserveConfiguration.Map configuration; - /** - * @dev address of the aToken representing the asset - **/ address payable aTokenAddress; address stableDebtTokenAddress; address variableDebtTokenAddress; - /** - * @dev address of the interest rate strategy contract - **/ address interestRateStrategyAddress; uint40 lastUpdateTimestamp; - // isStableBorrowRateEnabled = true means users can borrow at a stable rate - bool isStableBorrowRateEnabled; + //the index of the reserve in the list of the active reserves uint8 index; } /** * @dev returns the ongoing normalized income for the reserve. * a value of 1e27 means there is no income. As time passes, the income is accrued. - * A value of 2*1e27 means that the income of the reserve is double the initial amount. + * A value of 2*1e27 means for each unit of assset two units of income have been accrued. * @param _reserve the reserve object * @return the normalized income. expressed in ray **/ @@ -114,10 +127,11 @@ library ReserveLogic { * @param _self the reserve object **/ function updateCumulativeIndexesAndTimestamp(ReserveData storage _self) internal { - uint256 totalBorrows = getTotalBorrows(_self); - - if (totalBorrows > 0) { - //only cumulating if there is any income being produced + //only cumulating if there is any income being produced + if ( + IERC20(_self.variableDebtTokenAddress).totalSupply() > 0 || + IERC20(_self.stableDebtTokenAddress).totalSupply() > 0 + ) { uint256 cumulatedLiquidityInterest = MathUtils.calculateLinearInterest( _self.currentLiquidityRate, _self.lastUpdateTimestamp @@ -190,34 +204,6 @@ library ReserveLogic { _self.interestRateStrategyAddress = _interestRateStrategyAddress; } - function getTotalBorrows(ReserveData storage _self) internal view returns (uint256) { - return - IERC20(_self.stableDebtTokenAddress).totalSupply().add( - IERC20(_self.variableDebtTokenAddress).totalSupply() - ); - } - - /** - * @dev Emitted when the state of a reserve is updated - * @dev NOTE: This event replaces the Deprecated ReserveUpdated() event, which didn't emit the average stable borrow rate - * @param reserve the address of the reserve - * @param liquidityRate the new liquidity rate - * @param stableBorrowRate the new stable borrow rate - * @param averageStableBorrowRate the new average stable borrow rate - * @param variableBorrowRate the new variable borrow rate - * @param liquidityIndex the new liquidity index - * @param variableBorrowIndex the new variable borrow index - **/ - event ReserveDataUpdated( - address indexed reserve, - uint256 liquidityRate, - uint256 stableBorrowRate, - uint256 averageStableBorrowRate, - uint256 variableBorrowRate, - uint256 liquidityIndex, - uint256 variableBorrowIndex - ); - /** * @dev updates the state of the core as a result of a flashloan action * @param _reserve the address of the reserve in which the flashloan is happening @@ -233,7 +219,9 @@ library ReserveLogic { //compounding the cumulated interest _reserve.updateCumulativeIndexesAndTimestamp(); - uint256 totalLiquidityBefore = _availableLiquidityBefore.add(_reserve.getTotalBorrows()); + uint256 totalLiquidityBefore = _availableLiquidityBefore + .add(IERC20(_reserve.variableDebtTokenAddress).totalSupply()) + .add(IERC20(_reserve.stableDebtTokenAddress).totalSupply()); //compounding the received fee into the reserve _reserve.cumulateToLiquidityIndex(totalLiquidityBefore, _income); @@ -242,20 +230,6 @@ library ReserveLogic { updateInterestRates(_reserve, _reserveAddress, _income, 0); } - /** - * @dev gets the total liquidity in the reserve. The total liquidity is the balance of the core contract + total borrows - * @param _reserve the reserve address - * @return the total liquidity - **/ - function getTotalLiquidity(ReserveData storage _reserve, address _reserveAddress) - public - view - returns (uint256) - { - return - IERC20(_reserveAddress).balanceOf(address(this)).add(_reserve.getTotalBorrows()); - } - /** * @dev Updates the reserve current stable borrow rate Rf, the current variable borrow rate Rv and the current liquidity rate Rl. * Also updates the lastUpdateTimestamp value. Please refer to the whitepaper for further information. @@ -300,56 +274,4 @@ library ReserveLogic { _reserve.lastVariableBorrowCumulativeIndex ); } - - /** - * @dev gets the reserve current variable borrow rate. Is the base variable borrow rate if the reserve is empty - * @param _reserve the reserve address - * @return the reserve current variable borrow rate - **/ - function getReserveCurrentVariableBorrowRate(ReserveData storage _reserve) - external - view - returns (uint256) - { - if (_reserve.currentVariableBorrowRate == 0) { - return - IReserveInterestRateStrategy(_reserve.interestRateStrategyAddress) - .getBaseVariableBorrowRate(); - } - return _reserve.currentVariableBorrowRate; - } - - /** - * @dev gets the reserve current stable borrow rate. Is the market rate if the reserve is empty - * @param _reserve the reserve address - * @return the reserve current stable borrow rate - **/ - function getReserveCurrentStableBorrowRate(ReserveData storage _reserve, uint256 _baseRate) - public - view - returns (uint256) - { - return _reserve.currentStableBorrowRate == 0 ? _baseRate : _reserve.currentStableBorrowRate; - } - - /** - * @dev returns the utilization rate U of a specific reserve - * @param _reserve the reserve for which the information is needed - * @return the utilization rate in ray - **/ - function getUtilizationRate(ReserveData storage _reserve, address _reserveAddress) - public - view - returns (uint256) - { - uint256 totalBorrows = _reserve.getTotalBorrows(); - - if (totalBorrows == 0) { - return 0; - } - - uint256 availableLiquidity = IERC20(_reserveAddress).balanceOf(address(this)); - - return totalBorrows.rayDiv(availableLiquidity.add(totalBorrows)); - } } From a419ca90143a6a54a3598bd2ec3596954552791b Mon Sep 17 00:00:00 2001 From: The3D Date: Wed, 19 Aug 2020 16:39:04 +0200 Subject: [PATCH 2/5] Further cleaned up reserveLogic --- contracts/libraries/ReserveLogic.sol | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/contracts/libraries/ReserveLogic.sol b/contracts/libraries/ReserveLogic.sol index bc0fe15e..a5bde585 100644 --- a/contracts/libraries/ReserveLogic.sol +++ b/contracts/libraries/ReserveLogic.sol @@ -9,12 +9,8 @@ import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; import {ReserveConfiguration} from './ReserveConfiguration.sol'; -import '../configuration/LendingPoolAddressesProvider.sol'; -import '../interfaces/ILendingRateOracle.sol'; -import '../interfaces/IReserveInterestRateStrategy.sol'; -import '../tokenization/AToken.sol'; -import './WadRayMath.sol'; -import '@nomiclabs/buidler/console.sol'; +import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol'; +import {WadRayMath} from './WadRayMath.sol'; /** * @title ReserveLogic library From 926d25dba8b074675e679d252f0b8f59f5fb873b Mon Sep 17 00:00:00 2001 From: The3D Date: Wed, 19 Aug 2020 16:57:49 +0200 Subject: [PATCH 3/5] Cleaned up validation logic --- contracts/libraries/ReserveLogic.sol | 1 - contracts/libraries/ValidationLogic.sol | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/contracts/libraries/ReserveLogic.sol b/contracts/libraries/ReserveLogic.sol index a5bde585..4d49b114 100644 --- a/contracts/libraries/ReserveLogic.sol +++ b/contracts/libraries/ReserveLogic.sol @@ -8,7 +8,6 @@ import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; import {ReserveConfiguration} from './ReserveConfiguration.sol'; - import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol'; import {WadRayMath} from './WadRayMath.sol'; diff --git a/contracts/libraries/ValidationLogic.sol b/contracts/libraries/ValidationLogic.sol index 696f3eb7..16170de7 100644 --- a/contracts/libraries/ValidationLogic.sol +++ b/contracts/libraries/ValidationLogic.sol @@ -36,12 +36,14 @@ library ValidationLogic { * @param _amount the amount to be deposited */ function validateDeposit(ReserveLogic.ReserveData storage _reserve, uint256 _amount) - external + internal view { (bool isActive, bool isFreezed, , ) = _reserve.configuration.getFlags(); require(_amount > 0, 'Amount must be greater than 0'); + require(isActive, 'Action requires an active reserve'); + require(!isFreezed, 'Action requires an unfreezed reserve'); } /** From 76fcb20b4429db1c28142f774c627e3839115dd0 Mon Sep 17 00:00:00 2001 From: The3D Date: Thu, 20 Aug 2020 09:51:21 +0200 Subject: [PATCH 4/5] Code cleanup --- contracts/fees/FeeProvider.sol | 2 +- contracts/fees/TokenDistributor.sol | 6 +- .../DefaultReserveInterestRateStrategy.sol | 11 +- contracts/lendingpool/LendingPool.sol | 65 +++++----- .../lendingpool/LendingPoolConfigurator.sol | 16 +-- .../LendingPoolLiquidationManager.sol | 41 +++---- contracts/libraries/UserConfiguration.sol | 109 ----------------- .../ReserveConfiguration.sol | 10 +- .../configuration/UserConfiguration.sol | 113 ++++++++++++++++++ contracts/libraries/{ => helpers}/Helpers.sol | 11 +- .../libraries/{ => logic}/GenericLogic.sol | 20 ++-- .../libraries/{ => logic}/ReserveLogic.sol | 12 +- .../libraries/{ => logic}/ValidationLogic.sol | 14 +-- contracts/libraries/{ => math}/MathUtils.sol | 21 ++-- .../libraries/{ => math}/PercentageMath.sol | 0 contracts/libraries/{ => math}/WadRayMath.sol | 3 +- contracts/tokenization/AToken.sol | 4 +- contracts/tokenization/StableDebtToken.sol | 4 +- contracts/tokenization/VariableDebtToken.sol | 11 +- 19 files changed, 229 insertions(+), 244 deletions(-) delete mode 100644 contracts/libraries/UserConfiguration.sol rename contracts/libraries/{ => configuration}/ReserveConfiguration.sol (96%) create mode 100644 contracts/libraries/configuration/UserConfiguration.sol rename contracts/libraries/{ => helpers}/Helpers.sol (79%) rename contracts/libraries/{ => logic}/GenericLogic.sol (94%) rename contracts/libraries/{ => logic}/ReserveLogic.sol (95%) rename contracts/libraries/{ => logic}/ValidationLogic.sol (96%) rename contracts/libraries/{ => math}/MathUtils.sol (83%) rename contracts/libraries/{ => math}/PercentageMath.sol (100%) rename contracts/libraries/{ => math}/WadRayMath.sol (97%) diff --git a/contracts/fees/FeeProvider.sol b/contracts/fees/FeeProvider.sol index bf5342e9..65bf53b8 100644 --- a/contracts/fees/FeeProvider.sol +++ b/contracts/fees/FeeProvider.sol @@ -3,7 +3,7 @@ pragma solidity ^0.6.8; import '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; import '../interfaces/IFeeProvider.sol'; -import '../libraries/WadRayMath.sol'; +import '../libraries/math/WadRayMath.sol'; /** * @title FeeProvider contract diff --git a/contracts/fees/TokenDistributor.sol b/contracts/fees/TokenDistributor.sol index 4b322ac1..8adaf3b7 100644 --- a/contracts/fees/TokenDistributor.sol +++ b/contracts/fees/TokenDistributor.sol @@ -9,7 +9,7 @@ import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; import '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; import '../interfaces/IExchangeAdapter.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; -import {PercentageMath} from '../libraries/PercentageMath.sol'; +import {PercentageMath} from '../libraries/math/PercentageMath.sol'; /// @title TokenDistributor /// @author Aave @@ -128,9 +128,7 @@ contract TokenDistributor is ReentrancyGuard, VersionedInitializable { public { for (uint256 i = 0; i < _tokens.length; i++) { - uint256 _amountToDistribute = _tokens[i].balanceOf(address(this)).percentMul( - _percentages[i] - ); + uint256 _amountToDistribute = _tokens[i].balanceOf(address(this)).percentMul(_percentages[i]); if (_amountToDistribute <= 0) { continue; diff --git a/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol b/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol index c8b9d9ec..224dd5d4 100644 --- a/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol +++ b/contracts/lendingpool/DefaultReserveInterestRateStrategy.sol @@ -1,12 +1,11 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import '../interfaces/IReserveInterestRateStrategy.sol'; -import '../libraries/WadRayMath.sol'; -import '../configuration/LendingPoolAddressesProvider.sol'; -import '../interfaces/ILendingRateOracle.sol'; - -import '@openzeppelin/contracts/math/SafeMath.sol'; +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; +import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; +import {ILendingRateOracle} from '../interfaces/ILendingRateOracle.sol'; /** * @title DefaultReserveInterestRateStrategy contract diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 5dc5a93e..a5a3bd38 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -2,30 +2,29 @@ pragma solidity ^0.6.8; pragma experimental ABIEncoderV2; -import '@openzeppelin/contracts/math/SafeMath.sol'; -import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; -import '@openzeppelin/contracts/utils/Address.sol'; -import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; -import '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; - -import '../configuration/LendingPoolAddressesProvider.sol'; -import '../tokenization/AToken.sol'; -import '../libraries/WadRayMath.sol'; -import '../libraries/ReserveLogic.sol'; -import '../libraries/Helpers.sol'; -import '../libraries/GenericLogic.sol'; -import '../libraries/ValidationLogic.sol'; -import '../libraries/ReserveConfiguration.sol'; -import '../libraries/UserConfiguration.sol'; -import '../tokenization/interfaces/IStableDebtToken.sol'; -import '../tokenization/interfaces/IVariableDebtToken.sol'; - -import '../interfaces/IFeeProvider.sol'; -import '../flashloan/interfaces/IFlashLoanReceiver.sol'; -import './LendingPoolLiquidationManager.sol'; -import '../interfaces/IPriceOracleGetter.sol'; +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; +import {ReentrancyGuard} from '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; +import {Address} from '@openzeppelin/contracts/utils/Address.sol'; +import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; +import { + VersionedInitializable +} from '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; +import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; +import {AToken} from '../tokenization/AToken.sol'; +import {Helpers} from '../libraries/helpers/Helpers.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; +import {GenericLogic} from '../libraries/logic/GenericLogic.sol'; +import {ValidationLogic} from '../libraries/logic/ValidationLogic.sol'; +import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol'; +import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; +import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol'; +import {IFeeProvider} from '../interfaces/IFeeProvider.sol'; +import {IFlashLoanReceiver} from '../flashloan/interfaces/IFlashLoanReceiver.sol'; +import {LendingPoolLiquidationManager} from './LendingPoolLiquidationManager.sol'; +import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; -import '@nomiclabs/buidler/console.sol'; /** * @title LendingPool contract @@ -400,15 +399,6 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { ); } - /** - * @notice repays a borrow on the specific reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). - * @dev the target user is defined by _onBehalfOf. If there is no repayment on behalf of another account, - * _onBehalfOf must be equal to msg.sender. - * @param _reserve the address of the reserve on which the user borrowed - * @param _amount the amount to repay, or uint256(-1) if the user wants to repay everything - * @param _onBehalfOf the address for which msg.sender is repaying. - **/ - struct RepayLocalVars { uint256 stableDebt; uint256 variableDebt; @@ -417,6 +407,14 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { uint256 totalDebt; } + /** + * @notice repays a borrow on the specific reserve, for the specified amount (or for the whole amount, if uint256(-1) is specified). + * @dev the target user is defined by _onBehalfOf. If there is no repayment on behalf of another account, + * _onBehalfOf must be equal to msg.sender. + * @param _reserve the address of the reserve on which the user borrowed + * @param _amount the amount to repay, or uint256(-1) if the user wants to repay everything + * @param _onBehalfOf the address for which msg.sender is repaying. + **/ function repay( address _reserve, uint256 _amount, @@ -882,8 +880,7 @@ contract LendingPool is ReentrancyGuard, VersionedInitializable { } receive() external payable { - //only contracts can send ETH to the core - require(msg.sender.isContract(), '22'); + revert(); } /** diff --git a/contracts/lendingpool/LendingPoolConfigurator.sol b/contracts/lendingpool/LendingPoolConfigurator.sol index 2a7c0f7e..1846551b 100644 --- a/contracts/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/lendingpool/LendingPoolConfigurator.sol @@ -2,15 +2,17 @@ pragma solidity ^0.6.8; pragma experimental ABIEncoderV2; -import '@openzeppelin/contracts/math/SafeMath.sol'; - -import '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; -import '../libraries/ReserveConfiguration.sol'; -import '../configuration/LendingPoolAddressesProvider.sol'; -import '../libraries/openzeppelin-upgradeability/InitializableAdminUpgradeabilityProxy.sol'; +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; +import { + VersionedInitializable +} from '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; +import { + InitializableAdminUpgradeabilityProxy +} from '../libraries/openzeppelin-upgradeability/InitializableAdminUpgradeabilityProxy.sol'; +import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; import {LendingPool} from './LendingPool.sol'; import {IERC20Detailed} from '../interfaces/IERC20Detailed.sol'; -import '@nomiclabs/buidler/console.sol'; /** * @title LendingPoolConfigurator contract diff --git a/contracts/lendingpool/LendingPoolLiquidationManager.sol b/contracts/lendingpool/LendingPoolLiquidationManager.sol index ff0da778..45047dd8 100644 --- a/contracts/lendingpool/LendingPoolLiquidationManager.sol +++ b/contracts/lendingpool/LendingPoolLiquidationManager.sol @@ -1,27 +1,28 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import '@openzeppelin/contracts/math/SafeMath.sol'; -import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; -import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; -import '@openzeppelin/contracts/utils/Address.sol'; -import '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; - -import '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; - -import '../configuration/LendingPoolAddressesProvider.sol'; -import '../tokenization/AToken.sol'; -import '../tokenization/interfaces/IStableDebtToken.sol'; -import '../tokenization/interfaces/IVariableDebtToken.sol'; -import '../libraries/WadRayMath.sol'; -import '../interfaces/IPriceOracleGetter.sol'; -import '../libraries/GenericLogic.sol'; -import '../libraries/Helpers.sol'; -import '../libraries/ReserveLogic.sol'; -import '../libraries/ReserveConfiguration.sol'; -import '../libraries/UserConfiguration.sol'; -import {PercentageMath} from '../libraries/PercentageMath.sol'; +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; +import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; +import {ReentrancyGuard} from '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; +import {Address} from '@openzeppelin/contracts/utils/Address.sol'; +import {ReentrancyGuard} from '@openzeppelin/contracts/utils/ReentrancyGuard.sol'; +import { + VersionedInitializable +} from '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; +import {LendingPoolAddressesProvider} from '../configuration/LendingPoolAddressesProvider.sol'; +import {AToken} from '../tokenization/AToken.sol'; +import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; +import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol'; +import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; +import {GenericLogic} from '../libraries/logic/GenericLogic.sol'; +import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; +import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../libraries/configuration/UserConfiguration.sol'; +import {Helpers} from '../libraries/helpers/Helpers.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; +import {PercentageMath} from '../libraries/math/PercentageMath.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; +import {IFeeProvider} from '../interfaces/IFeeProvider.sol'; /** * @title LendingPoolLiquidationManager contract diff --git a/contracts/libraries/UserConfiguration.sol b/contracts/libraries/UserConfiguration.sol deleted file mode 100644 index 9f7c1531..00000000 --- a/contracts/libraries/UserConfiguration.sol +++ /dev/null @@ -1,109 +0,0 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity ^0.6.8; - -import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; -import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; -import {WadRayMath} from './WadRayMath.sol'; -import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; -import {IFeeProvider} from '../interfaces/IFeeProvider.sol'; - -/** - * @title UserConfiguration library - * @author Aave - * @notice Implements the bitmap logic to handle the user configuration - */ -library UserConfiguration { - uint256 internal constant BORROWING_MASK = 0x5555555555555555555555555555555555555555555555555555555555555555; - - struct Map { - uint256 data; - } - - /** - * @dev sets if the user is borrowing the reserve identified by _reserveIndex - * @param _self the configuration object - * @param _reserveIndex the index of the reserve in the bitmap - * @param _borrowing true if the user is borrowing the reserve, false otherwise - **/ - function setBorrowing( - UserConfiguration.Map storage _self, - uint256 _reserveIndex, - bool _borrowing - ) internal { - _self.data = (_self.data & ~(1 << _reserveIndex*2)) | uint256(_borrowing ? 1 : 0) << (_reserveIndex * 2); - } - - /** - * @dev sets if the user is using as collateral the reserve identified by _reserveIndex - * @param _self the configuration object - * @param _reserveIndex the index of the reserve in the bitmap - * @param _usingAsCollateral true if the user is usin the reserve as collateral, false otherwise - **/ - function setUsingAsCollateral( - UserConfiguration.Map storage _self, - uint256 _reserveIndex, - bool _usingAsCollateral - ) internal { - _self.data = (_self.data & ~(1 << _reserveIndex*2+1)) | uint256(_usingAsCollateral ? 1 : 0) << (_reserveIndex * 2 + 1); - } - - /** - * @dev used to validate if a user has been using the reserve for borrowing or as collateral - * @param _self the configuration object - * @param _reserveIndex the index of the reserve in the bitmap - * @return true if the user has been using a reserve for borrowing or as collateral, false otherwise - **/ - function isUsingAsCollateralOrBorrowing(UserConfiguration.Map memory _self, uint256 _reserveIndex) - internal - view - returns (bool) - { - return (_self.data >> (_reserveIndex * 2)) & 3 != 0; - } - - /** - * @dev used to validate if a user has been using the reserve for borrowing - * @param _self the configuration object - * @param _reserveIndex the index of the reserve in the bitmap - * @return true if the user has been using a reserve for borrowing, false otherwise - **/ - function isBorrowing(UserConfiguration.Map memory _self, uint256 _reserveIndex) - internal - view - returns (bool) - { - return (_self.data >> (_reserveIndex * 2)) & 1 != 0; - } - - /** - * @dev used to validate if a user has been using the reserve as collateral - * @param _self the configuration object - * @param _reserveIndex the index of the reserve in the bitmap - * @return true if the user has been using a reserve as collateral, false otherwise - **/ - function isUsingAsCollateral(UserConfiguration.Map memory _self, uint256 _reserveIndex) - internal - view - returns (bool) - { - return (_self.data >> (_reserveIndex * 2 + 1)) & 1 != 0; - } - - /** - * @dev used to validate if a user has been borrowing from any reserve - * @param _self the configuration object - * @return true if the user has been borrowing any reserve, false otherwise - **/ - function isBorrowingAny(UserConfiguration.Map memory _self) internal view returns (bool) { - return _self.data & BORROWING_MASK != 0; - } - - /** - * @dev used to validate if a user has not been using any reserve - * @param _self the configuration object - * @return true if the user has been borrowing any reserve, false otherwise - **/ - function isEmpty(UserConfiguration.Map memory _self) internal view returns(bool) { - return _self.data == 0; - } -} diff --git a/contracts/libraries/ReserveConfiguration.sol b/contracts/libraries/configuration/ReserveConfiguration.sol similarity index 96% rename from contracts/libraries/ReserveConfiguration.sol rename to contracts/libraries/configuration/ReserveConfiguration.sol index 92811fa9..4a833556 100644 --- a/contracts/libraries/ReserveConfiguration.sol +++ b/contracts/libraries/configuration/ReserveConfiguration.sol @@ -3,12 +3,10 @@ pragma solidity ^0.6.8; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; - -import {ReserveLogic} from './ReserveLogic.sol'; -import {WadRayMath} from './WadRayMath.sol'; - -import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; -import {IFeeProvider} from '../interfaces/IFeeProvider.sol'; +import {ReserveLogic} from '../logic/ReserveLogic.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; +import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; +import {IFeeProvider} from '../../interfaces/IFeeProvider.sol'; /** * @title ReserveConfiguration library diff --git a/contracts/libraries/configuration/UserConfiguration.sol b/contracts/libraries/configuration/UserConfiguration.sol new file mode 100644 index 00000000..0bac500a --- /dev/null +++ b/contracts/libraries/configuration/UserConfiguration.sol @@ -0,0 +1,113 @@ +// SPDX-License-Identifier: agpl-3.0 +pragma solidity ^0.6.8; + +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; +import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; +import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; +import {IFeeProvider} from '../../interfaces/IFeeProvider.sol'; + +/** + * @title UserConfiguration library + * @author Aave + * @notice Implements the bitmap logic to handle the user configuration + */ +library UserConfiguration { + uint256 internal constant BORROWING_MASK = 0x5555555555555555555555555555555555555555555555555555555555555555; + + struct Map { + uint256 data; + } + + /** + * @dev sets if the user is borrowing the reserve identified by _reserveIndex + * @param _self the configuration object + * @param _reserveIndex the index of the reserve in the bitmap + * @param _borrowing true if the user is borrowing the reserve, false otherwise + **/ + function setBorrowing( + UserConfiguration.Map storage _self, + uint256 _reserveIndex, + bool _borrowing + ) internal { + _self.data = + (_self.data & ~(1 << (_reserveIndex * 2))) | + (uint256(_borrowing ? 1 : 0) << (_reserveIndex * 2)); + } + + /** + * @dev sets if the user is using as collateral the reserve identified by _reserveIndex + * @param _self the configuration object + * @param _reserveIndex the index of the reserve in the bitmap + * @param _usingAsCollateral true if the user is usin the reserve as collateral, false otherwise + **/ + function setUsingAsCollateral( + UserConfiguration.Map storage _self, + uint256 _reserveIndex, + bool _usingAsCollateral + ) internal { + _self.data = + (_self.data & ~(1 << (_reserveIndex * 2 + 1))) | + (uint256(_usingAsCollateral ? 1 : 0) << (_reserveIndex * 2 + 1)); + } + + /** + * @dev used to validate if a user has been using the reserve for borrowing or as collateral + * @param _self the configuration object + * @param _reserveIndex the index of the reserve in the bitmap + * @return true if the user has been using a reserve for borrowing or as collateral, false otherwise + **/ + function isUsingAsCollateralOrBorrowing(UserConfiguration.Map memory _self, uint256 _reserveIndex) + internal + view + returns (bool) + { + return (_self.data >> (_reserveIndex * 2)) & 3 != 0; + } + + /** + * @dev used to validate if a user has been using the reserve for borrowing + * @param _self the configuration object + * @param _reserveIndex the index of the reserve in the bitmap + * @return true if the user has been using a reserve for borrowing, false otherwise + **/ + function isBorrowing(UserConfiguration.Map memory _self, uint256 _reserveIndex) + internal + view + returns (bool) + { + return (_self.data >> (_reserveIndex * 2)) & 1 != 0; + } + + /** + * @dev used to validate if a user has been using the reserve as collateral + * @param _self the configuration object + * @param _reserveIndex the index of the reserve in the bitmap + * @return true if the user has been using a reserve as collateral, false otherwise + **/ + function isUsingAsCollateral(UserConfiguration.Map memory _self, uint256 _reserveIndex) + internal + view + returns (bool) + { + return (_self.data >> (_reserveIndex * 2 + 1)) & 1 != 0; + } + + /** + * @dev used to validate if a user has been borrowing from any reserve + * @param _self the configuration object + * @return true if the user has been borrowing any reserve, false otherwise + **/ + function isBorrowingAny(UserConfiguration.Map memory _self) internal view returns (bool) { + return _self.data & BORROWING_MASK != 0; + } + + /** + * @dev used to validate if a user has not been using any reserve + * @param _self the configuration object + * @return true if the user has been borrowing any reserve, false otherwise + **/ + function isEmpty(UserConfiguration.Map memory _self) internal view returns (bool) { + return _self.data == 0; + } +} diff --git a/contracts/libraries/Helpers.sol b/contracts/libraries/helpers/Helpers.sol similarity index 79% rename from contracts/libraries/Helpers.sol rename to contracts/libraries/helpers/Helpers.sol index de71cfa1..8f0b2db2 100644 --- a/contracts/libraries/Helpers.sol +++ b/contracts/libraries/helpers/Helpers.sol @@ -1,10 +1,8 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; -import '../tokenization/base/DebtTokenBase.sol'; -import './ReserveLogic.sol'; - +import {DebtTokenBase} from '../../tokenization/base/DebtTokenBase.sol'; +import {ReserveLogic} from '../logic/ReserveLogic.sol'; /** * @title Helpers library @@ -12,7 +10,6 @@ import './ReserveLogic.sol'; * @notice Implements calculation helpers. */ library Helpers { - /** * @dev fetches the user current stable and variable debt balances * @param _user the user @@ -25,8 +22,8 @@ library Helpers { returns (uint256, uint256) { return ( - IERC20(_reserve.stableDebtTokenAddress).balanceOf(_user), - IERC20(_reserve.variableDebtTokenAddress).balanceOf(_user) + DebtTokenBase(_reserve.stableDebtTokenAddress).balanceOf(_user), + DebtTokenBase(_reserve.variableDebtTokenAddress).balanceOf(_user) ); } diff --git a/contracts/libraries/GenericLogic.sol b/contracts/libraries/logic/GenericLogic.sol similarity index 94% rename from contracts/libraries/GenericLogic.sol rename to contracts/libraries/logic/GenericLogic.sol index a25d7805..5811fe76 100644 --- a/contracts/libraries/GenericLogic.sol +++ b/contracts/libraries/logic/GenericLogic.sol @@ -4,15 +4,13 @@ pragma experimental ABIEncoderV2; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; - import {ReserveLogic} from './ReserveLogic.sol'; -import {ReserveConfiguration} from './ReserveConfiguration.sol'; -import {UserConfiguration} from './UserConfiguration.sol'; -import {WadRayMath} from './WadRayMath.sol'; -import {PercentageMath} from './PercentageMath.sol'; -import '../interfaces/IPriceOracleGetter.sol'; -import {IFeeProvider} from '../interfaces/IFeeProvider.sol'; -import '@nomiclabs/buidler/console.sol'; +import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../configuration/UserConfiguration.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; +import {PercentageMath} from '../math/PercentageMath.sol'; +import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; +import {IFeeProvider} from '../../interfaces/IFeeProvider.sol'; /** * @title GenericLogic library @@ -60,8 +58,10 @@ library GenericLogic { address[] calldata _reserves, address _oracle ) external view returns (bool) { - - if (!_userConfig.isBorrowingAny() || !_userConfig.isUsingAsCollateral(_reservesData[_reserve].index)) { + if ( + !_userConfig.isBorrowingAny() || + !_userConfig.isUsingAsCollateral(_reservesData[_reserve].index) + ) { return true; } diff --git a/contracts/libraries/ReserveLogic.sol b/contracts/libraries/logic/ReserveLogic.sol similarity index 95% rename from contracts/libraries/ReserveLogic.sol rename to contracts/libraries/logic/ReserveLogic.sol index 4d49b114..e637c0d1 100644 --- a/contracts/libraries/ReserveLogic.sol +++ b/contracts/libraries/logic/ReserveLogic.sol @@ -3,13 +3,13 @@ pragma solidity ^0.6.8; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; -import {MathUtils} from './MathUtils.sol'; -import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; +import {MathUtils} from '../math/MathUtils.sol'; +import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; -import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; -import {ReserveConfiguration} from './ReserveConfiguration.sol'; -import {IReserveInterestRateStrategy} from '../interfaces/IReserveInterestRateStrategy.sol'; -import {WadRayMath} from './WadRayMath.sol'; +import {IStableDebtToken} from '../../tokenization/interfaces/IStableDebtToken.sol'; +import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; +import {IReserveInterestRateStrategy} from '../../interfaces/IReserveInterestRateStrategy.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; /** * @title ReserveLogic library diff --git a/contracts/libraries/ValidationLogic.sol b/contracts/libraries/logic/ValidationLogic.sol similarity index 96% rename from contracts/libraries/ValidationLogic.sol rename to contracts/libraries/logic/ValidationLogic.sol index 16170de7..071eab5a 100644 --- a/contracts/libraries/ValidationLogic.sol +++ b/contracts/libraries/logic/ValidationLogic.sol @@ -4,17 +4,15 @@ pragma experimental ABIEncoderV2; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; - import {ReserveLogic} from './ReserveLogic.sol'; import {GenericLogic} from './GenericLogic.sol'; -import {WadRayMath} from './WadRayMath.sol'; -import {PercentageMath} from './PercentageMath.sol'; +import {WadRayMath} from '../math/WadRayMath.sol'; +import {PercentageMath} from '../math/PercentageMath.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; -import {ReserveConfiguration} from './ReserveConfiguration.sol'; -import {UserConfiguration} from './UserConfiguration.sol'; -import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; -import {IFeeProvider} from '../interfaces/IFeeProvider.sol'; -import '@nomiclabs/buidler/console.sol'; +import {ReserveConfiguration} from '../configuration/ReserveConfiguration.sol'; +import {UserConfiguration} from '../configuration/UserConfiguration.sol'; +import {IPriceOracleGetter} from '../../interfaces/IPriceOracleGetter.sol'; +import {IFeeProvider} from '../../interfaces/IFeeProvider.sol'; /** * @title ReserveLogic library diff --git a/contracts/libraries/MathUtils.sol b/contracts/libraries/math/MathUtils.sol similarity index 83% rename from contracts/libraries/MathUtils.sol rename to contracts/libraries/math/MathUtils.sol index 1e26366d..e8d1dcbe 100644 --- a/contracts/libraries/MathUtils.sol +++ b/contracts/libraries/math/MathUtils.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import '@openzeppelin/contracts/math/SafeMath.sol'; -import './WadRayMath.sol'; +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; +import {WadRayMath} from './WadRayMath.sol'; library MathUtils { using SafeMath for uint256; @@ -34,7 +34,7 @@ library MathUtils { * @dev function to calculate the interest using a compounded interest rate formula. * To avoid expensive exponentiation, the calculation is performed using a binomial approximation: * - * (1+x)^n = 1+n*x+[n/2*(n-1)]*x^2+[n/6*(n-1)*(n-2)*x^3... + * (1+x)^n = 1+n*x+[n/2*(n-1)]*x^2+[n/6*(n-1)*(n-2)*x^3... * * The approximation slightly underpays liquidity providers, with the advantage of great gas cost reductions. * The whitepaper contains reference to the approximation and a table showing the margin of error per different time periods. @@ -48,30 +48,25 @@ library MathUtils { view returns (uint256) { - //solium-disable-next-line uint256 exp = block.timestamp.sub(uint256(_lastUpdateTimestamp)); - if(exp == 0){ + if (exp == 0) { return WadRayMath.ray(); } - uint256 expMinusOne = exp.sub(1); + uint256 expMinusOne = exp.sub(1); - uint256 expMinusTwo = exp > 2 ? exp.sub(2) : 0; + uint256 expMinusTwo = exp > 2 ? exp.sub(2) : 0; uint256 ratePerSecond = _rate.div(31536000); - - uint basePowerTwo = ratePerSecond.rayMul(ratePerSecond); - uint basePowerThree = basePowerTwo.rayMul(ratePerSecond); + uint256 basePowerTwo = ratePerSecond.rayMul(ratePerSecond); + uint256 basePowerThree = basePowerTwo.rayMul(ratePerSecond); - uint256 secondTerm = exp.mul(expMinusOne).mul(basePowerTwo).div(2); uint256 thirdTerm = exp.mul(expMinusOne).mul(expMinusTwo).mul(basePowerThree).div(6); - return WadRayMath.ray().add(ratePerSecond.mul(exp)).add(secondTerm).add(thirdTerm); - } } diff --git a/contracts/libraries/PercentageMath.sol b/contracts/libraries/math/PercentageMath.sol similarity index 100% rename from contracts/libraries/PercentageMath.sol rename to contracts/libraries/math/PercentageMath.sol diff --git a/contracts/libraries/WadRayMath.sol b/contracts/libraries/math/WadRayMath.sol similarity index 97% rename from contracts/libraries/WadRayMath.sol rename to contracts/libraries/math/WadRayMath.sol index 0dc29657..becf3d75 100644 --- a/contracts/libraries/WadRayMath.sol +++ b/contracts/libraries/math/WadRayMath.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import '@openzeppelin/contracts/math/SafeMath.sol'; +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; /** * @title WadRayMath library @@ -112,5 +112,4 @@ library WadRayMath { function wadToRay(uint256 a) internal pure returns (uint256) { return a.mul(WAD_RAY_RATIO); } - } diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index c30a07e9..0745e452 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -3,14 +3,12 @@ pragma solidity ^0.6.8; import {ERC20} from './ERC20.sol'; import {LendingPool} from '../lendingpool/LendingPool.sol'; -import {WadRayMath} from '../libraries/WadRayMath.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; import { VersionedInitializable } from '../libraries/openzeppelin-upgradeability/VersionedInitializable.sol'; -import '@nomiclabs/buidler/console.sol'; - /** * @title Aave ERC20 AToken * diff --git a/contracts/tokenization/StableDebtToken.sol b/contracts/tokenization/StableDebtToken.sol index 6fc51b6f..796d4215 100644 --- a/contracts/tokenization/StableDebtToken.sol +++ b/contracts/tokenization/StableDebtToken.sol @@ -5,8 +5,8 @@ import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {DebtTokenBase} from './base/DebtTokenBase.sol'; -import {MathUtils} from '../libraries/MathUtils.sol'; -import {WadRayMath} from '../libraries/WadRayMath.sol'; +import {MathUtils} from '../libraries/math/MathUtils.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {IStableDebtToken} from './interfaces/IStableDebtToken.sol'; /** diff --git a/contracts/tokenization/VariableDebtToken.sol b/contracts/tokenization/VariableDebtToken.sol index 1e25ebfe..d75630b5 100644 --- a/contracts/tokenization/VariableDebtToken.sol +++ b/contracts/tokenization/VariableDebtToken.sol @@ -1,12 +1,11 @@ pragma solidity ^0.6.0; -import '@openzeppelin/contracts/GSN/Context.sol'; -import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; -import '@openzeppelin/contracts/math/SafeMath.sol'; -import '@openzeppelin/contracts/utils/Address.sol'; +import {Context} from '@openzeppelin/contracts/GSN/Context.sol'; +import {IERC20} from '@openzeppelin/contracts/token/ERC20/IERC20.sol'; +import {SafeMath} from '@openzeppelin/contracts/math/SafeMath.sol'; +import {Address} from '@openzeppelin/contracts/utils/Address.sol'; import {DebtTokenBase} from './base/DebtTokenBase.sol'; -import {WadRayMath} from '../libraries/WadRayMath.sol'; -import '@nomiclabs/buidler/console.sol'; +import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {IVariableDebtToken} from './interfaces/IVariableDebtToken.sol'; /** From a437512ae919763b9786455695ccdd3ca5c1eecb Mon Sep 17 00:00:00 2001 From: The3D Date: Thu, 20 Aug 2020 09:56:43 +0200 Subject: [PATCH 5/5] Removed origination fee event, variables --- contracts/lendingpool/LendingPoolLiquidationManager.sol | 3 --- 1 file changed, 3 deletions(-) diff --git a/contracts/lendingpool/LendingPoolLiquidationManager.sol b/contracts/lendingpool/LendingPoolLiquidationManager.sol index 45047dd8..0b0b3603 100644 --- a/contracts/lendingpool/LendingPoolLiquidationManager.sol +++ b/contracts/lendingpool/LendingPoolLiquidationManager.sol @@ -88,9 +88,6 @@ contract LendingPoolLiquidationManager is ReentrancyGuard, VersionedInitializabl uint256 actualAmountToLiquidate; uint256 liquidationRatio; uint256 maxAmountCollateralToLiquidate; - uint256 originationFee; - uint256 feeLiquidated; - uint256 liquidatedCollateralForFee; ReserveLogic.InterestRateMode borrowRateMode; uint256 userStableRate; uint256 maxCollateralToLiquidate;