Function: finalizeWithdrawERC20(address _l1Token, address _l2Token, address _from, address _to, uint256 _amount, bytes _data)
This function completes the ERC-20 withdrawal from Cloak to Scroll and sends funds to the recipient's account on Scroll. The caller must be the contract L1ScrollMessengerValidium, and the sender on Cloak must be the contract L2StandardERC20Gateway.
Inputs
_l1TokenControl: Fully controlled by the caller.
Constraints: The result of
getL2ERC20Address(_l1Token)must be equal to_l2Token.Impact: The address of the withdrawn token on Scroll.
_l2TokenControl: Fully controlled by the caller.
Constraints: The value of
tokenMapping[_l2Token]of the contract L2StandardERC20Gateway on Cloak must not be the zero address.Impact: The address of the withdrawn token on Cloak.
_fromControl: Fully controlled by the caller.
Constraints: N/A.
Impact: The address of the sender on Cloak.
_toControl: Fully controlled by the caller.
Constraints: N/A.
Impact: The address of the recipient on Scroll.
_amountControl: Fully controlled by the caller.
Constraints: Must be greater than zero.
Impact: The amount of tokens to withdraw.
_dataControl: Fully controlled by the caller.
Constraints: N/A.
Impact: The optional data. Only used for event logging in this implementation.
Branches and code coverage
Intended branches
The
_l1Tokenbalance of the contract decreases by the expected amount.The
_l1Tokenbalance of_toincreases by the expected amount.The
tokenMapping[_l1Token]is set to_l2Tokenif this is the first withdrawal of the token.
Negative behavior
Reverts if the caller is not the contract L1ScrollMessengerValidium.
Reverts if the sender on Cloak is not the contract L2StandardERC20Gateway.
Reverts if
msg.valueis not zero.Reverts if
_l2Tokendoes not match the expected L2 token address computed from_l1Token.
Function call analysis
SafeERC20Upgradeable.safeTransfer(IERC20Upgradeable(_l1Token), _to, _amount)What is controllable?
_l1Token,_to, and_amount.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? N/A.