mirror of
https://github.com/Instadapp/aave-protocol-v2.git
synced 2024-07-29 21:47:30 +00:00
- Fixed _withdraw() logic StaticAToken
This commit is contained in:
parent
51bd4ecee9
commit
151b240bc4
|
@ -322,12 +322,15 @@ contract StaticAToken is ERC20 {
|
|||
) internal {
|
||||
require(recipient != address(0), 'INVALID_RECIPIENT');
|
||||
|
||||
_burn(owner, amount);
|
||||
uint256 userBalance = balanceOf(owner);
|
||||
uint256 amountToWithdraw = (amount > userBalance) ? userBalance : amount;
|
||||
|
||||
_burn(owner, amountToWithdraw);
|
||||
|
||||
if (toUnderlying) {
|
||||
LENDING_POOL.withdraw(address(ASSET), staticToDynamicAmount(amount), recipient);
|
||||
LENDING_POOL.withdraw(address(ASSET), staticToDynamicAmount(amountToWithdraw), recipient);
|
||||
} else {
|
||||
ATOKEN.safeTransfer(recipient, staticToDynamicAmount(amount));
|
||||
ATOKEN.safeTransfer(recipient, staticToDynamicAmount(amountToWithdraw));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user