Function: withdraw()
This allows withdrawing from the contract.
Branches and code coverage
Intended branches
Ensure that a user can afford the withdrawal. Ensured through
withdrawAmount[msg.sender]
.Update the
withdrawAmount
mapping for the user.If the user has nothing to withdraw, return early.
If
want == weth
, withdraw WETH and transfer ETH to the user.If
want != weth
, transfer want tokens to the user.
Negative behavior
Should not allow transferring more than the user can afford.