Function: withdrawForStaker(address _erc20TokenAddress, address _staker, uint256 _amount)
Allows withdrawing tokens for a staker.
Inputs
_erc20TokenAddressControl: Fully controlled by the stake manager.
Constraints: None.
Impact: The token to withdraw.
_stakerControl: Fully controlled by the stake manager.
Constraints: None.
Impact: The address to withdraw to.
_amountControl: Fully controlled by the stake manager.
Constraints: Checked that it is not zero.
Impact: The amount to withdraw.
Branches and code coverage (including function calls)
Intended branches
Transfer the
_amountof_erc20TokenAddressto_staker.Decrease the balance of
_erc20TokenAddressinaddress(this)by_amount.Increase the balance of
_erc20TokenAddressin_stakerby_amount.
Negative behavior
Should not be callable by anyone other than the stake manager. Ensured through
onlyStakeManager.Should not be abused since it literally transfers any token to any address. Theoretically this should be ensured in the StakeManager contract.
Function call analysis
IERC20(_erc20TokenAddress).safeTransfer(_staker, _amount)What is controllable?
_erc20TokenAddress,_staker, and_amount.If return value 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? Then the transfer will fail; it means there is not enough balance.