- Fixed _withdraw() logic StaticAToken

This commit is contained in:
eboado 2021-02-16 11:51:06 +01:00 committed by Lasse Herskind
parent 51bd4ecee9
commit 151b240bc4

View File

@ -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));
}
}
}