diff --git a/contracts/interfaces/ILendingPool.sol b/contracts/interfaces/ILendingPool.sol index 2e4e2d94..4848df78 100644 --- a/contracts/interfaces/ILendingPool.sol +++ b/contracts/interfaces/ILendingPool.sol @@ -27,9 +27,10 @@ interface ILendingPool { * @dev emitted during a withdraw action. * @param reserve the address of the reserve * @param user the address of the user + * @param to address that will receive the underlying * @param amount the amount to be withdrawn **/ - event Withdraw(address indexed reserve, address indexed user, uint256 amount); + event Withdraw(address indexed reserve, address indexed user, address indexed to, uint256 amount); event BorrowAllowanceDelegated( address indexed asset, @@ -188,8 +189,13 @@ interface ILendingPool { * @dev withdraws the assets of user. * @param reserve the address of the reserve * @param amount the underlying amount to be redeemed + * @param to address that will receive the underlying **/ - function withdraw(address reserve, uint256 amount) external; + function withdraw( + address reserve, + uint256 amount, + address to + ) external; /** * @dev Sets allowance to borrow on a certain type of debt asset for a certain user address diff --git a/contracts/lendingpool/LendingPool.sol b/contracts/lendingpool/LendingPool.sol index 3c2fcd8a..4faae912 100644 --- a/contracts/lendingpool/LendingPool.sol +++ b/contracts/lendingpool/LendingPool.sol @@ -120,8 +120,13 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage * @dev withdraws the _reserves of user. * @param asset the address of the reserve * @param amount the underlying amount to be redeemed + * @param to address that will receive the underlying **/ - function withdraw(address asset, uint256 amount) external override { + function withdraw( + address asset, + uint256 amount, + address to + ) external override { _whenNotPaused(); ReserveLogic.ReserveData storage reserve = _reserves[asset]; @@ -155,9 +160,9 @@ contract LendingPool is VersionedInitializable, ILendingPool, LendingPoolStorage _usersConfig[msg.sender].setUsingAsCollateral(reserve.id, false); } - IAToken(aToken).burn(msg.sender, msg.sender, amountToWithdraw, reserve.liquidityIndex); + IAToken(aToken).burn(msg.sender, to, amountToWithdraw, reserve.liquidityIndex); - emit Withdraw(asset, msg.sender, amountToWithdraw); + emit Withdraw(asset, msg.sender, to, amountToWithdraw); } /** @@ -892,7 +897,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/test/helpers/actions.ts b/test/helpers/actions.ts index 422b0455..82701087 100644 --- a/test/helpers/actions.ts +++ b/test/helpers/actions.ts @@ -231,7 +231,7 @@ export const withdraw = async ( if (expectedResult === 'success') { const txResult = await waitForTx( - await pool.connect(user.signer).withdraw(reserve, amountToWithdraw) + await pool.connect(user.signer).withdraw(reserve, amountToWithdraw, user.address) ); const { @@ -269,8 +269,10 @@ export const withdraw = async ( // ); // }); } else if (expectedResult === 'revert') { - await expect(pool.connect(user.signer).withdraw(reserve, amountToWithdraw), revertMessage).to.be - .reverted; + await expect( + pool.connect(user.signer).withdraw(reserve, amountToWithdraw, user.address), + revertMessage + ).to.be.reverted; } }; diff --git a/test/pausable-functions.spec.ts b/test/pausable-functions.spec.ts index 7a24da2d..72be7ada 100644 --- a/test/pausable-functions.spec.ts +++ b/test/pausable-functions.spec.ts @@ -116,7 +116,7 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { // user tries to burn await expect( - pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit) + pool.connect(users[0].signer).withdraw(dai.address, amountDAItoDeposit, users[0].address) ).to.revertedWith(IS_PAUSED); // Configurator unpauses the pool @@ -187,7 +187,15 @@ makeSuite('Pausable Pool', (testEnv: TestEnv) => { await expect( pool .connect(caller.signer) - .flashLoan(_mockFlashLoanReceiver.address, [weth.address], [flashAmount], 1, caller.address, '0x10', '0') + .flashLoan( + _mockFlashLoanReceiver.address, + [weth.address], + [flashAmount], + 1, + caller.address, + '0x10', + '0' + ) ).revertedWith(IS_PAUSED); // Unpause pool