Function: withdraw(address token, uint256 amount, bool unwrap)
The function can be utilized for withdrawing tokens from the escrow contract.
Inputs
tokenControl: Fully controlled by the caller.
Constraints: No constraints.
Impact: This token is withdrawn from the contract.
amountControl: Fully controlled by the caller.
Constraints: Should not be
0, and user's deposit balance should be greater than or equal to this value.Impact: The amount of token to be withdrawn.
unwrapControl: Fully controlled by the caller.
Constraints: Should be a boolean.
Impact: Unwraps and then transfers the token to the user if true; transfers directly without unwrapping if false.
Branches and code coverage
Intended branches
If
unwrapis true, then unwrap the token and transfer the unwrapped token to the caller.If
unwrapis false, directly transfer the token to the caller.Decrease the
usersBalanceof the user andtotalStakedfor that token byamount.
Negative behavior
Revert if amount is
0.Revert if balance of the user is less than the withdrawal
amountrequested.Revert if
unwrapis true and the address ofrebasefor that token isaddress(0).Revert if rebase token is ETH and the transfer of ETH to
msg.senderfails.
Function call analysis
this._getStorage()What is controllable? N/A.
If the return value is controllable, how is it used and how can it go wrong? Returns the storage slot.
What happens if it reverts, reenters or does other unusual control flow? N/A.
SafeERC20.safeTransfer(IERC20(tokenInfo.rebase), msg.sender, finalAmt)What is controllable?
msg.senderandfinalAmt(partially controllable).If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? If it reverts, the entire transaction would revert — no reentrancy scenario.
SafeERC20.safeTransfer(IERC20(token), msg.sender, amount)What is controllable?
token,msg.sender, andamount.If the return value is controllable, how is it used and how can it go wrong? N/A.
What happens if it reverts, reenters or does other unusual control flow? If it reverts, the entire transaction would revert — no reentrancy scenario.