stdError.arithmeticError
Original Implementation
Alberto said:
testUserCannotWithdraw and testUserCannotWithdrawExcessDeposit should revert because of underflow in balances[msg.sender], not because of ERC20 properties.
Richie elaborated:
Alberto said he wanted to see this revert because of the underflow, not because of the erc20 balance. so u can:
make sure the user has an balance of the token
change this to vm.assume
(amount > 0 && amount < wmd.balanceOf(user))
instead of expectRevert -- use forge-std standard errors https://book.getfoundry.sh/reference/forge-std/std-errors.html
Correct Implementation
The takeaway here is that:
the user has some wmd tokens.
he will attempt to withdraw some tokens within the range (0, amount), from the vault
since he does not have any deposits to begin with, we run into an underflow error, resulting from:
balances[msg.sender] -= amount;
as this is going to work out to subtracting a positive figure (amount) from 0 -> hence underflow.
Last updated