diff --git a/contracts/configuration/LendingPoolAddressesProvider.sol b/contracts/configuration/LendingPoolAddressesProvider.sol index fed14236..15b37635 100644 --- a/contracts/configuration/LendingPoolAddressesProvider.sol +++ b/contracts/configuration/LendingPoolAddressesProvider.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; +import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; import { InitializableImmutableAdminUpgradeabilityProxy } from '../libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol'; @@ -153,9 +153,9 @@ contract LendingPoolAddressesProvider is Ownable, ILendingPoolAddressesProvider function _updateImpl(bytes32 id, address newAddress) internal { address payable proxyAddress = payable(_addresses[id]); - InitializableImmutableAdminUpgradeabilityProxy proxy = InitializableImmutableAdminUpgradeabilityProxy( - proxyAddress - ); + + InitializableImmutableAdminUpgradeabilityProxy proxy + = InitializableImmutableAdminUpgradeabilityProxy(proxyAddress); bytes memory params = abi.encodeWithSignature('initialize(address)', address(this)); if (proxyAddress == address(0)) { diff --git a/contracts/configuration/LendingPoolAddressesProviderRegistry.sol b/contracts/configuration/LendingPoolAddressesProviderRegistry.sol index edc719ef..f8dfb629 100644 --- a/contracts/configuration/LendingPoolAddressesProviderRegistry.sol +++ b/contracts/configuration/LendingPoolAddressesProviderRegistry.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import {Ownable} from '@openzeppelin/contracts/access/Ownable.sol'; +import {Ownable} from '../dependencies/openzeppelin/contracts/Ownable.sol'; import { ILendingPoolAddressesProviderRegistry } from '../interfaces/ILendingPoolAddressesProviderRegistry.sol'; diff --git a/contracts/libraries/external/openzeppelin/contracts/Address.sol b/contracts/dependencies/openzeppelin/contracts/Address.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/contracts/Address.sol rename to contracts/dependencies/openzeppelin/contracts/Address.sol diff --git a/contracts/libraries/external/openzeppelin/contracts/Context.sol b/contracts/dependencies/openzeppelin/contracts/Context.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/contracts/Context.sol rename to contracts/dependencies/openzeppelin/contracts/Context.sol diff --git a/contracts/libraries/external/openzeppelin/contracts/IERC20.sol b/contracts/dependencies/openzeppelin/contracts/IERC20.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/contracts/IERC20.sol rename to contracts/dependencies/openzeppelin/contracts/IERC20.sol diff --git a/contracts/libraries/external/openzeppelin/contracts/IERC20Detailed.sol b/contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/contracts/IERC20Detailed.sol rename to contracts/dependencies/openzeppelin/contracts/IERC20Detailed.sol diff --git a/contracts/dependencies/openzeppelin/contracts/Ownable.sol b/contracts/dependencies/openzeppelin/contracts/Ownable.sol new file mode 100644 index 00000000..c503fe5f --- /dev/null +++ b/contracts/dependencies/openzeppelin/contracts/Ownable.sol @@ -0,0 +1,69 @@ +// SPDX-License-Identifier: MIT + +pragma solidity ^0.6.0; + +import './Context.sol'; + +/** + * @dev Contract module which provides a basic access control mechanism, where + * there is an account (an owner) that can be granted exclusive access to + * specific functions. + * + * By default, the owner account will be the one that deploys the contract. This + * can later be changed with {transferOwnership}. + * + * This module is used through inheritance. It will make available the modifier + * `onlyOwner`, which can be applied to your functions to restrict their use to + * the owner. + */ +contract Ownable is Context { + address private _owner; + + event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); + + /** + * @dev Initializes the contract setting the deployer as the initial owner. + */ + constructor() internal { + address msgSender = _msgSender(); + _owner = msgSender; + emit OwnershipTransferred(address(0), msgSender); + } + + /** + * @dev Returns the address of the current owner. + */ + function owner() public view returns (address) { + return _owner; + } + + /** + * @dev Throws if called by any account other than the owner. + */ + modifier onlyOwner() { + require(_owner == _msgSender(), 'Ownable: caller is not the owner'); + _; + } + + /** + * @dev Leaves the contract without owner. It will not be possible to call + * `onlyOwner` functions anymore. Can only be called by the current owner. + * + * NOTE: Renouncing ownership will leave the contract without an owner, + * thereby removing any functionality that is only available to the owner. + */ + function renounceOwnership() public virtual onlyOwner { + emit OwnershipTransferred(_owner, address(0)); + _owner = address(0); + } + + /** + * @dev Transfers ownership of the contract to a new account (`newOwner`). + * Can only be called by the current owner. + */ + function transferOwnership(address newOwner) public virtual onlyOwner { + require(newOwner != address(0), 'Ownable: new owner is the zero address'); + emit OwnershipTransferred(_owner, newOwner); + _owner = newOwner; + } +} diff --git a/contracts/libraries/external/openzeppelin/contracts/SafeERC20.sol b/contracts/dependencies/openzeppelin/contracts/SafeERC20.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/contracts/SafeERC20.sol rename to contracts/dependencies/openzeppelin/contracts/SafeERC20.sol diff --git a/contracts/libraries/external/openzeppelin/contracts/SafeMath.sol b/contracts/dependencies/openzeppelin/contracts/SafeMath.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/contracts/SafeMath.sol rename to contracts/dependencies/openzeppelin/contracts/SafeMath.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol b/contracts/dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol rename to contracts/dependencies/openzeppelin/upgradeability/AdminUpgradeabilityProxy.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol b/contracts/dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol rename to contracts/dependencies/openzeppelin/upgradeability/BaseAdminUpgradeabilityProxy.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol b/contracts/dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol rename to contracts/dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/Initializable.sol b/contracts/dependencies/openzeppelin/upgradeability/Initializable.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/Initializable.sol rename to contracts/dependencies/openzeppelin/upgradeability/Initializable.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol b/contracts/dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol rename to contracts/dependencies/openzeppelin/upgradeability/InitializableAdminUpgradeabilityProxy.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol b/contracts/dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol rename to contracts/dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/Proxy.sol b/contracts/dependencies/openzeppelin/upgradeability/Proxy.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/Proxy.sol rename to contracts/dependencies/openzeppelin/upgradeability/Proxy.sol diff --git a/contracts/libraries/external/openzeppelin/upgradeability/UpgradeabilityProxy.sol b/contracts/dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol similarity index 100% rename from contracts/libraries/external/openzeppelin/upgradeability/UpgradeabilityProxy.sol rename to contracts/dependencies/openzeppelin/upgradeability/UpgradeabilityProxy.sol diff --git a/contracts/flashloan/base/FlashLoanReceiverBase.sol b/contracts/flashloan/base/FlashLoanReceiverBase.sol index a9b3e2a9..01cfb3fc 100644 --- a/contracts/flashloan/base/FlashLoanReceiverBase.sol +++ b/contracts/flashloan/base/FlashLoanReceiverBase.sol @@ -1,11 +1,11 @@ // 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 {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {IFlashLoanReceiver} from '../interfaces/IFlashLoanReceiver.sol'; import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; -import {SafeERC20} from '@openzeppelin/contracts/token/ERC20/SafeERC20.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; abstract contract FlashLoanReceiverBase is IFlashLoanReceiver { using SafeERC20 for IERC20; diff --git a/contracts/lendingpool/LendingPoolCollateralManager.sol b/contracts/lendingpool/LendingPoolCollateralManager.sol index eacd480a..736eadf9 100644 --- a/contracts/lendingpool/LendingPoolCollateralManager.sol +++ b/contracts/lendingpool/LendingPoolCollateralManager.sol @@ -1,8 +1,8 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import {SafeMath} from '../libraries/external/openzeppelin/contracts//SafeMath.sol'; -import {IERC20} from '../libraries/external/openzeppelin/contracts//IERC20.sol'; +import {SafeMath} from '../dependencies/openzeppelin/contracts//SafeMath.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts//IERC20.sol'; import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; import {IAToken} from '../tokenization/interfaces/IAToken.sol'; import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol'; @@ -14,7 +14,7 @@ import {UserConfiguration} from '../libraries/configuration/UserConfiguration.so import {Helpers} from '../libraries/helpers/Helpers.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {PercentageMath} from '../libraries/math/PercentageMath.sol'; -import {SafeERC20} from '../libraries/external/openzeppelin/contracts/SafeERC20.sol'; +import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {ISwapAdapter} from '../interfaces/ISwapAdapter.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {ValidationLogic} from '../libraries/logic/ValidationLogic.sol'; diff --git a/contracts/lendingpool/LendingPoolConfigurator.sol b/contracts/lendingpool/LendingPoolConfigurator.sol index 47764819..8f154e23 100644 --- a/contracts/lendingpool/LendingPoolConfigurator.sol +++ b/contracts/lendingpool/LendingPoolConfigurator.sol @@ -2,7 +2,7 @@ pragma solidity ^0.6.8; pragma experimental ABIEncoderV2; -import {SafeMath} from '../libraries/external/openzeppelin/contracts/SafeMath.sol'; +import {SafeMath} from '../dependencies/openzeppelin/contracts/SafeMath.sol'; import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; import { InitializableImmutableAdminUpgradeabilityProxy @@ -10,7 +10,7 @@ import { import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol'; import {ILendingPool} from '../interfaces/ILendingPool.sol'; -import {IERC20Detailed} from '../libraries/external/openzeppelin/contracts/IERC20Detailed.sol'; +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; diff --git a/contracts/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol b/contracts/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol index aaf7d98b..d953dc06 100644 --- a/contracts/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol +++ b/contracts/libraries/aave-upgradeability/BaseImmutableAdminUpgradeabilityProxy.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import '../external/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol'; +import '../../dependencies/openzeppelin/upgradeability/BaseUpgradeabilityProxy.sol'; /** * @title BaseImmutableAdminUpgradeabilityProxy diff --git a/contracts/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol b/contracts/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol index 723e5a4b..64036408 100644 --- a/contracts/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol +++ b/contracts/libraries/aave-upgradeability/InitializableImmutableAdminUpgradeabilityProxy.sol @@ -2,7 +2,7 @@ pragma solidity ^0.6.8; import './BaseImmutableAdminUpgradeabilityProxy.sol'; -import '../external/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol'; +import '../../dependencies/openzeppelin/upgradeability/InitializableUpgradeabilityProxy.sol'; /** * @title InitializableAdminUpgradeabilityProxy diff --git a/contracts/misc/AaveProtocolTestHelpers.sol b/contracts/misc/AaveProtocolTestHelpers.sol index e00f3674..37732e07 100644 --- a/contracts/misc/AaveProtocolTestHelpers.sol +++ b/contracts/misc/AaveProtocolTestHelpers.sol @@ -3,7 +3,7 @@ pragma solidity ^0.6.8; pragma experimental ABIEncoderV2; import {ILendingPoolAddressesProvider} from '../interfaces/ILendingPoolAddressesProvider.sol'; -import {IERC20Detailed} from '../libraries/external/openzeppelin/contracts/IERC20Detailed.sol'; +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; import {ILendingPool} from '../interfaces/ILendingPool.sol'; import {ReserveLogic} from '../libraries/logic/ReserveLogic.sol'; import {ReserveConfiguration} from '../libraries/configuration/ReserveConfiguration.sol'; diff --git a/contracts/mocks/flashloan/MockFlashLoanReceiver.sol b/contracts/mocks/flashloan/MockFlashLoanReceiver.sol index 64b49ca0..0a767712 100644 --- a/contracts/mocks/flashloan/MockFlashLoanReceiver.sol +++ b/contracts/mocks/flashloan/MockFlashLoanReceiver.sol @@ -1,12 +1,12 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import {SafeMath} from '../../libraries/external/openzeppelin/contracts/SafeMath.sol'; -import {IERC20} from '../../libraries/external/openzeppelin/contracts/IERC20.sol'; +import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {FlashLoanReceiverBase} from '../../flashloan/base/FlashLoanReceiverBase.sol'; import {MintableERC20} from '../tokens/MintableERC20.sol'; -import {SafeERC20} from '../../libraries/external/openzeppelin/contracts/SafeERC20.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; contract MockFlashLoanReceiver is FlashLoanReceiverBase { diff --git a/contracts/tokenization/AToken.sol b/contracts/tokenization/AToken.sol index 752cae5a..b1ddbd03 100644 --- a/contracts/tokenization/AToken.sol +++ b/contracts/tokenization/AToken.sol @@ -7,8 +7,8 @@ import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {Errors} from '../libraries/helpers/Errors.sol'; import {VersionedInitializable} from '../libraries/aave-upgradeability/VersionedInitializable.sol'; import {IAToken} from './interfaces/IAToken.sol'; -import {IERC20} from '../libraries/external/openzeppelin/contracts/IERC20.sol'; -import {SafeERC20} from '../libraries/external/openzeppelin/contracts/SafeERC20.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; +import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol'; /** * @title Aave ERC20 AToken diff --git a/contracts/tokenization/IncentivizedERC20.sol b/contracts/tokenization/IncentivizedERC20.sol index cd253d36..771a8202 100644 --- a/contracts/tokenization/IncentivizedERC20.sol +++ b/contracts/tokenization/IncentivizedERC20.sol @@ -1,10 +1,10 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.8; -import {Context} from '../libraries/external/openzeppelin/contracts/Context.sol'; -import {IERC20} from '../libraries/external/openzeppelin/contracts/IERC20.sol'; -import {IERC20Detailed} from '../libraries/external/openzeppelin/contracts/IERC20Detailed.sol'; -import {SafeMath} from '../libraries/external/openzeppelin/contracts/SafeMath.sol'; +import {Context} from '../dependencies/openzeppelin/contracts/Context.sol'; +import {IERC20} from '../dependencies/openzeppelin/contracts/IERC20.sol'; +import {IERC20Detailed} from '../dependencies/openzeppelin/contracts/IERC20Detailed.sol'; +import {SafeMath} from '../dependencies/openzeppelin/contracts/SafeMath.sol'; import {IAaveIncentivesController} from '../interfaces/IAaveIncentivesController.sol'; /** diff --git a/contracts/tokenization/interfaces/IAToken.sol b/contracts/tokenization/interfaces/IAToken.sol index d30ec403..00f63b20 100644 --- a/contracts/tokenization/interfaces/IAToken.sol +++ b/contracts/tokenization/interfaces/IAToken.sol @@ -1,7 +1,7 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity ^0.6.8; -import {IERC20} from '../../libraries/external/openzeppelin/contracts/IERC20.sol'; +import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; import {IScaledBalanceToken} from './IScaledBalanceToken.sol'; interface IAToken is IERC20, IScaledBalanceToken {