mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Added to
to withdraw()
This commit is contained in:
parent
386138cc9c
commit
b2bbe62822
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user