From 631d6ebfcbcd6fadb0ea11baf5220e9b57863866 Mon Sep 17 00:00:00 2001 From: eboado Date: Fri, 30 Oct 2020 13:32:42 +0100 Subject: [PATCH] - Passed `initiator` param to flashLoan()'s executeOperation() receiver. - Removed unused ISwapAdapter. --- .../interfaces/IFlashLoanReceiver.sol | 1 + contracts/interfaces/ISwapAdapter.sol | 20 ------------------- contracts/lendingpool/LendingPool.sol | 5 ++--- .../LendingPoolCollateralManager.sol | 1 - .../mocks/flashloan/MockFlashLoanReceiver.sol | 2 ++ 5 files changed, 5 insertions(+), 24 deletions(-) delete mode 100644 contracts/interfaces/ISwapAdapter.sol diff --git a/contracts/flashloan/interfaces/IFlashLoanReceiver.sol b/contracts/flashloan/interfaces/IFlashLoanReceiver.sol index 784d0fa3..af9e384f 100644 --- a/contracts/flashloan/interfaces/IFlashLoanReceiver.sol +++ b/contracts/flashloan/interfaces/IFlashLoanReceiver.sol @@ -12,6 +12,7 @@ interface IFlashLoanReceiver { address[] calldata assets, uint256[] calldata amounts, uint256[] calldata premiums, + address initiator, bytes calldata params ) external returns (bool); } diff --git a/contracts/interfaces/ISwapAdapter.sol b/contracts/interfaces/ISwapAdapter.sol deleted file mode 100644 index ed91f95f..00000000 --- a/contracts/interfaces/ISwapAdapter.sol +++ /dev/null @@ -1,20 +0,0 @@ -// SPDX-License-Identifier: agpl-3.0 -pragma solidity ^0.6.8; - -interface ISwapAdapter { - /** - * @dev Swaps an `amountToSwap` of an asset to another, approving a `fundsDestination` to pull the funds - * @param assetToSwapFrom Origin asset - * @param assetToSwapTo Destination asset - * @param amountToSwap How much `assetToSwapFrom` needs to be swapped - * @param fundsDestination Address that will be pulling the swapped funds - * @param params Additional variadic field to include extra params - */ - function executeOperation( - address assetToSwapFrom, - address assetToSwapTo, - uint256 amountToSwap, - address fundsDestination, - bytes calldata params - ) external; -} diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 3c2fcd8a..c6455947 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -20,7 +20,6 @@ import {IStableDebtToken} from '../tokenization/interfaces/IStableDebtToken.sol' import {IVariableDebtToken} from '../tokenization/interfaces/IVariableDebtToken.sol'; import {DebtTokenBase} from '../tokenization/base/DebtTokenBase.sol'; import {IFlashLoanReceiver} from '../flashloan/interfaces/IFlashLoanReceiver.sol'; -import {ISwapAdapter} from '../interfaces/ISwapAdapter.sol'; import {LendingPoolCollateralManager} from './LendingPoolCollateralManager.sol'; import {IPriceOracleGetter} from '../interfaces/IPriceOracleGetter.sol'; import {SafeERC20} from '../dependencies/openzeppelin/contracts/SafeERC20.sol'; @@ -539,7 +538,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage //execute action of the receiver require( - vars.receiver.executeOperation(assets, amounts, premiums, params), + vars.receiver.executeOperation(assets, amounts, premiums, msg.sender, params), Errors.INVALID_FLASH_LOAN_EXECUTOR_RETURN ); @@ -892,7 +891,7 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage //caching the current stable borrow rate uint256 currentStableRate = 0; - + bool isFirstBorrowing = false; if ( ReserveLogic.InterestRateMode(vars.interestRateMode) == ReserveLogic.InterestRateMode.STABLE diff --git a/contracts/lendingpool/LendingPoolCollateralManager.sol b/contracts/lendingpool/LendingPoolCollateralManager.sol index 16abdd10..96f555d3 100644 --- a/contracts/lendingpool/LendingPoolCollateralManager.sol +++ b/contracts/lendingpool/LendingPoolCollateralManager.sol @@ -15,7 +15,6 @@ import {Helpers} from '../libraries/helpers/Helpers.sol'; import {WadRayMath} from '../libraries/math/WadRayMath.sol'; import {PercentageMath} from '../libraries/math/PercentageMath.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'; import {LendingPoolStorage} from './LendingPoolStorage.sol'; diff --git a/contracts/mocks/flashloan/MockFlashLoanReceiver.sol b/contracts/mocks/flashloan/MockFlashLoanReceiver.sol index 7b72c2cb..215746ae 100644 --- a/contracts/mocks/flashloan/MockFlashLoanReceiver.sol +++ b/contracts/mocks/flashloan/MockFlashLoanReceiver.sol @@ -47,9 +47,11 @@ contract MockFlashLoanReceiver is FlashLoanReceiverBase { address[] memory assets, uint256[] memory amounts, uint256[] memory premiums, + address initiator, bytes memory params ) public override returns (bool) { params; + initiator; if (_failExecution) { emit ExecutedWithFail(assets, amounts, premiums);