From ae94f8ba4939477fdbb72400e7fdcdcb563676b6 Mon Sep 17 00:00:00 2001 From: eboado Date: Fri, 27 Nov 2020 15:15:05 +0100 Subject: [PATCH] - Added initialization of _lendingPool to FlashLoanReceiverBase and getters. --- contracts/flashloan/base/FlashLoanReceiverBase.sol | 13 ++++++++++++- .../flashloan/interfaces/IFlashLoanReceiver.sol | 7 +++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/contracts/flashloan/base/FlashLoanReceiverBase.sol b/contracts/flashloan/base/FlashLoanReceiverBase.sol index 27e82ee2..71c5d9dc 100644 --- a/contracts/flashloan/base/FlashLoanReceiverBase.sol +++ b/contracts/flashloan/base/FlashLoanReceiverBase.sol @@ -3,18 +3,29 @@ pragma solidity 0.6.12; import {SafeMath} from '../../dependencies/openzeppelin/contracts/SafeMath.sol'; import {IERC20} from '../../dependencies/openzeppelin/contracts/IERC20.sol'; +import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; import {IFlashLoanReceiver} from '../interfaces/IFlashLoanReceiver.sol'; import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; -import {SafeERC20} from '../../dependencies/openzeppelin/contracts/SafeERC20.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; abstract contract FlashLoanReceiverBase is IFlashLoanReceiver { using SafeERC20 for IERC20; using SafeMath for uint256; ILendingPoolAddressesProvider internal _addressesProvider; + ILendingPool internal _lendingPool; constructor(ILendingPoolAddressesProvider provider) public { _addressesProvider = provider; + _lendingPool = ILendingPool(provider.getLendingPool()); + } + + function getAddressesProvider() external view override returns (ILendingPoolAddressesProvider) { + return _addressesProvider; + } + + function getLendingPool() external view override returns (ILendingPool) { + return _lendingPool; } receive() external payable {} diff --git a/contracts/flashloan/interfaces/IFlashLoanReceiver.sol b/contracts/flashloan/interfaces/IFlashLoanReceiver.sol index 19618eac..0ffa6a05 100644 --- a/contracts/flashloan/interfaces/IFlashLoanReceiver.sol +++ b/contracts/flashloan/interfaces/IFlashLoanReceiver.sol @@ -1,6 +1,9 @@ // SPDX-License-Identifier: agpl-3.0 pragma solidity 0.6.12; +import {ILendingPoolAddressesProvider} from '../../interfaces/ILendingPoolAddressesProvider.sol'; +import {ILendingPool} from '../../interfaces/ILendingPool.sol'; + /** * @title IFlashLoanReceiver interface * @notice Interface for the Aave fee IFlashLoanReceiver. @@ -15,4 +18,8 @@ interface IFlashLoanReceiver { address initiator, bytes calldata params ) external returns (bool); + + function getAddressesProvider() external view returns (ILendingPoolAddressesProvider); + + function getLendingPool() external view returns (ILendingPool); }