{"solidity/L1GatewayRouter.sol:AddressUpgradeable":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212202b51ec87149a5e8a71610f18f1374c5010ec1bdbc5b533ee73e4673403a00b4764736f6c63430008110033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212202b51ec87149a5e8a71610f18f1374c5010ec1bdbc5b533ee73e4673403a00b4764736f6c63430008110033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"5375:9180:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;5375:9180:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"5375:9180:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Collection of functions related to the address type","kind":"dev","methods":{},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Collection of functions related to the address type\",\"kind\":\"dev\",\"methods\":{},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"AddressUpgradeable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{}},"solidity/L1GatewayRouter.sol:ContextUpgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.","kind":"dev","methods":{},"stateVariables":{"__gap":{"details":"This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps"}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"}],\"devdoc\":{\"details\":\"Provides information about the current execution context, including the sender of the transaction and its data. While these are generally available via msg.sender and msg.data, they should not be accessed in such a direct manner, since when dealing with meta-transactions the account sending and paying for execution may not be the actual sender (as far as an application is concerned). This contract is only required for intermediate, library-like contracts.\",\"kind\":\"dev\",\"methods\":{},\"stateVariables\":{\"__gap\":{\"details\":\"This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"ContextUpgradeable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{}},"solidity/L1GatewayRouter.sol:IERC20PermitUpgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"inputs":[],"name":"DOMAIN_SEPARATOR","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"nonces","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"value","type":"uint256"},{"internalType":"uint256","name":"deadline","type":"uint256"},{"internalType":"uint8","name":"v","type":"uint8"},{"internalType":"bytes32","name":"r","type":"bytes32"},{"internalType":"bytes32","name":"s","type":"bytes32"}],"name":"permit","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't need to send a transaction, and thus is not required to hold Ether at all.","kind":"dev","methods":{"DOMAIN_SEPARATOR()":{"details":"Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}."},"nonces(address)":{"details":"Returns the current nonce for `owner`. This value must be included whenever a signature is generated for {permit}. Every successful call to {permit} increases ``owner``'s nonce by one. This prevents a signature from being used multiple times."},"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)":{"details":"Sets `value` as the allowance of `spender` over ``owner``'s tokens, given ``owner``'s signed approval. IMPORTANT: The same issues {IERC20-approve} has related to transaction ordering also apply here. Emits an {Approval} event. Requirements: - `spender` cannot be the zero address. - `deadline` must be a timestamp in the future. - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` over the EIP712-formatted function arguments. - the signature must use ``owner``'s current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section]."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"name\":\"DOMAIN_SEPARATOR\",\"outputs\":[{\"internalType\":\"bytes32\",\"name\":\"\",\"type\":\"bytes32\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"}],\"name\":\"nonces\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"deadline\",\"type\":\"uint256\"},{\"internalType\":\"uint8\",\"name\":\"v\",\"type\":\"uint8\"},{\"internalType\":\"bytes32\",\"name\":\"r\",\"type\":\"bytes32\"},{\"internalType\":\"bytes32\",\"name\":\"s\",\"type\":\"bytes32\"}],\"name\":\"permit\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in https://eips.ethereum.org/EIPS/eip-2612[EIP-2612]. Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't need to send a transaction, and thus is not required to hold Ether at all.\",\"kind\":\"dev\",\"methods\":{\"DOMAIN_SEPARATOR()\":{\"details\":\"Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\"},\"nonces(address)\":{\"details\":\"Returns the current nonce for `owner`. This value must be included whenever a signature is generated for {permit}. Every successful call to {permit} increases ``owner``'s nonce by one. This prevents a signature from being used multiple times.\"},\"permit(address,address,uint256,uint256,uint8,bytes32,bytes32)\":{\"details\":\"Sets `value` as the allowance of `spender` over ``owner``'s tokens, given ``owner``'s signed approval. IMPORTANT: The same issues {IERC20-approve} has related to transaction ordering also apply here. Emits an {Approval} event. Requirements: - `spender` cannot be the zero address. - `deadline` must be a timestamp in the future. - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner` over the EIP712-formatted function arguments. - the signature must use ``owner``'s current nonce (see {nonces}). For more information on the signature format, see the https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP section].\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"IERC20PermitUpgradeable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{"DOMAIN_SEPARATOR()":"3644e515","nonces(address)":"7ecebe00","permit(address,address,uint256,uint256,uint8,bytes32,bytes32)":"d505accf"}},"solidity/L1GatewayRouter.sol:IERC20Upgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"spender","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"value","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"address","name":"spender","type":"address"}],"name":"allowance","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"spender","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"approve","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transfer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"transferFrom","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Interface of the ERC20 standard as defined in the EIP.","events":{"Approval(address,address,uint256)":{"details":"Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance."},"Transfer(address,address,uint256)":{"details":"Emitted when `value` tokens are moved from one account (`from`) to another (`to`). Note that `value` may be zero."}},"kind":"dev","methods":{"allowance(address,address)":{"details":"Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called."},"approve(address,uint256)":{"details":"Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an {Approval} event."},"balanceOf(address)":{"details":"Returns the amount of tokens owned by `account`."},"totalSupply()":{"details":"Returns the amount of tokens in existence."},"transfer(address,uint256)":{"details":"Moves `amount` tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event."},"transferFrom(address,address,uint256)":{"details":"Moves `amount` tokens from `from` to `to` using the allowance mechanism. `amount` is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Interface of the ERC20 standard as defined in the EIP.\",\"events\":{\"Approval(address,address,uint256)\":{\"details\":\"Emitted when the allowance of a `spender` for an `owner` is set by a call to {approve}. `value` is the new allowance.\"},\"Transfer(address,address,uint256)\":{\"details\":\"Emitted when `value` tokens are moved from one account (`from`) to another (`to`). Note that `value` may be zero.\"}},\"kind\":\"dev\",\"methods\":{\"allowance(address,address)\":{\"details\":\"Returns the remaining number of tokens that `spender` will be allowed to spend on behalf of `owner` through {transferFrom}. This is zero by default. This value changes when {approve} or {transferFrom} are called.\"},\"approve(address,uint256)\":{\"details\":\"Sets `amount` as the allowance of `spender` over the caller's tokens. Returns a boolean value indicating whether the operation succeeded. IMPORTANT: Beware that changing an allowance with this method brings the risk that someone may use both the old and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards: https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 Emits an {Approval} event.\"},\"balanceOf(address)\":{\"details\":\"Returns the amount of tokens owned by `account`.\"},\"totalSupply()\":{\"details\":\"Returns the amount of tokens in existence.\"},\"transfer(address,uint256)\":{\"details\":\"Moves `amount` tokens from the caller's account to `to`. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.\"},\"transferFrom(address,address,uint256)\":{\"details\":\"Moves `amount` tokens from `from` to `to` using the allowance mechanism. `amount` is then deducted from the caller's allowance. Returns a boolean value indicating whether the operation succeeded. Emits a {Transfer} event.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"IERC20Upgradeable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{"allowance(address,address)":"dd62ed3e","approve(address,uint256)":"095ea7b3","balanceOf(address)":"70a08231","totalSupply()":"18160ddd","transfer(address,uint256)":"a9059cbb","transferFrom(address,address,uint256)":"23b872dd"}},"solidity/L1GatewayRouter.sol:IL1ERC20Gateway":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DepositERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"FinalizeWithdrawERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundERC20","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20AndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_l1Token","type":"address"},{"internalType":"address","name":"_l2Token","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"finalizeWithdrawERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_l1Token","type":"address"}],"name":"getL2ERC20Address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}],"userDoc":{"events":{"DepositERC20(address,address,address,address,uint256,bytes)":{"notice":"Emitted when someone deposit ERC20 token from L1 to L2."},"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"notice":"Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient."},"RefundERC20(address,address,uint256)":{"notice":"Emitted when some ERC20 token is refunded."}},"kind":"user","methods":{"depositERC20(address,address,uint256,uint256)":{"notice":"Deposit some token to a recipient's account on L2."},"depositERC20(address,uint256,uint256)":{"notice":"Deposit some token to a caller's account on L2."},"depositERC20AndCall(address,address,uint256,bytes,uint256)":{"notice":"Deposit some token to a recipient's account on L2 and call."},"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"notice":"Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1."},"getL2ERC20Address(address)":{"notice":"Return the corresponding l2 token address given l1 token address."}},"version":1},"developerDoc":{"events":{"DepositERC20(address,address,address,address,uint256,bytes)":{"params":{"amount":"The amount of token will be deposited from L1 to L2.","data":"The optional calldata passed to recipient in L2.","from":"The address of sender in L1.","l1Token":"The address of the token in L1.","l2Token":"The address of the token in L2.","to":"The address of recipient in L2."}},"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"params":{"amount":"The amount of token withdrawn from L2 to L1.","data":"The optional calldata passed to recipient in L1.","from":"The address of sender in L2.","l1Token":"The address of the token in L1.","l2Token":"The address of the token in L2.","to":"The address of recipient in L1."}},"RefundERC20(address,address,uint256)":{"params":{"amount":"The amount of token refunded to receiver.","recipient":"The address of receiver in L1.","token":"The address of the token in L1."}}},"kind":"dev","methods":{"depositERC20(address,address,uint256,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_gasLimit":"Gas limit required to complete the deposit on L2.","_to":"The address of recipient's account on L2.","_token":"The address of token in L1."}},"depositERC20(address,uint256,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_gasLimit":"Gas limit required to complete the deposit on L2.","_token":"The address of token in L1."}},"depositERC20AndCall(address,address,uint256,bytes,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_data":"Optional data to forward to recipient's account.","_gasLimit":"Gas limit required to complete the deposit on L2.","_to":"The address of recipient's account on L2.","_token":"The address of token in L1."}},"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"details":"Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.","params":{"_amount":"The amount of the token to withdraw.","_data":"Optional data to forward to recipient's account.","_from":"The address of account who withdraw the token in L2.","_l1Token":"The address of corresponding L1 token.","_l2Token":"The address of corresponding L2 token.","_to":"The address of recipient in L1 to receive the token."}},"getL2ERC20Address(address)":{"params":{"_l1Token":"The address of l1 token."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"DepositERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"FinalizeWithdrawERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RefundERC20\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20AndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_l1Token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_l2Token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_l1Token\",\"type\":\"address\"}],\"name\":\"getL2ERC20Address\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"DepositERC20(address,address,address,address,uint256,bytes)\":{\"params\":{\"amount\":\"The amount of token will be deposited from L1 to L2.\",\"data\":\"The optional calldata passed to recipient in L2.\",\"from\":\"The address of sender in L1.\",\"l1Token\":\"The address of the token in L1.\",\"l2Token\":\"The address of the token in L2.\",\"to\":\"The address of recipient in L2.\"}},\"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"params\":{\"amount\":\"The amount of token withdrawn from L2 to L1.\",\"data\":\"The optional calldata passed to recipient in L1.\",\"from\":\"The address of sender in L2.\",\"l1Token\":\"The address of the token in L1.\",\"l2Token\":\"The address of the token in L2.\",\"to\":\"The address of recipient in L1.\"}},\"RefundERC20(address,address,uint256)\":{\"params\":{\"amount\":\"The amount of token refunded to receiver.\",\"recipient\":\"The address of receiver in L1.\",\"token\":\"The address of the token in L1.\"}}},\"kind\":\"dev\",\"methods\":{\"depositERC20(address,address,uint256,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_to\":\"The address of recipient's account on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositERC20(address,uint256,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositERC20AndCall(address,address,uint256,bytes,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_data\":\"Optional data to forward to recipient's account.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_to\":\"The address of recipient's account on L2.\",\"_token\":\"The address of token in L1.\"}},\"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"details\":\"Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.\",\"params\":{\"_amount\":\"The amount of the token to withdraw.\",\"_data\":\"Optional data to forward to recipient's account.\",\"_from\":\"The address of account who withdraw the token in L2.\",\"_l1Token\":\"The address of corresponding L1 token.\",\"_l2Token\":\"The address of corresponding L2 token.\",\"_to\":\"The address of recipient in L1 to receive the token.\"}},\"getL2ERC20Address(address)\":{\"params\":{\"_l1Token\":\"The address of l1 token.\"}}},\"version\":1},\"userdoc\":{\"events\":{\"DepositERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Emitted when someone deposit ERC20 token from L1 to L2.\"},\"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\"},\"RefundERC20(address,address,uint256)\":{\"notice\":\"Emitted when some ERC20 token is refunded.\"}},\"kind\":\"user\",\"methods\":{\"depositERC20(address,address,uint256,uint256)\":{\"notice\":\"Deposit some token to a recipient's account on L2.\"},\"depositERC20(address,uint256,uint256)\":{\"notice\":\"Deposit some token to a caller's account on L2.\"},\"depositERC20AndCall(address,address,uint256,bytes,uint256)\":{\"notice\":\"Deposit some token to a recipient's account on L2 and call.\"},\"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\"},\"getL2ERC20Address(address)\":{\"notice\":\"Return the corresponding l2 token address given l1 token address.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"IL1ERC20Gateway\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{"depositERC20(address,address,uint256,uint256)":"f219fa66","depositERC20(address,uint256,uint256)":"21425ee0","depositERC20AndCall(address,address,uint256,bytes,uint256)":"0aea8c26","finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":"84bd13b0","getL2ERC20Address(address)":"c676ad29"}},"solidity/L1GatewayRouter.sol:IL1ETHGateway":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DepositETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"FinalizeWithdrawETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundETH","type":"event"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"depositETHAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"finalizeWithdrawETH","outputs":[],"stateMutability":"payable","type":"function"}],"userDoc":{"events":{"DepositETH(address,address,uint256,bytes)":{"notice":"Emitted when someone deposit ETH from L1 to L2."},"FinalizeWithdrawETH(address,address,uint256,bytes)":{"notice":"Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient."},"RefundETH(address,uint256)":{"notice":"Emitted when some ETH is refunded."}},"kind":"user","methods":{"depositETH(address,uint256,uint256)":{"notice":"Deposit ETH to some recipient's account in L2."},"depositETH(uint256,uint256)":{"notice":"Deposit ETH to caller's account in L2."},"depositETHAndCall(address,uint256,bytes,uint256)":{"notice":"Deposit ETH to some recipient's account in L2 and call the target contract."},"finalizeWithdrawETH(address,address,uint256,bytes)":{"notice":"Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1."}},"version":1},"developerDoc":{"events":{"DepositETH(address,address,uint256,bytes)":{"params":{"amount":"The amount of ETH will be deposited from L1 to L2.","data":"The optional calldata passed to recipient in L2.","from":"The address of sender in L1.","to":"The address of recipient in L2."}},"FinalizeWithdrawETH(address,address,uint256,bytes)":{"params":{"amount":"The amount of ETH withdrawn from L2 to L1.","data":"The optional calldata passed to recipient in L1.","from":"The address of sender in L2.","to":"The address of recipient in L1."}},"RefundETH(address,uint256)":{"params":{"amount":"The amount of ETH refunded to receiver.","recipient":"The address of receiver in L1."}}},"kind":"dev","methods":{"depositETH(address,uint256,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","gasLimit":"Gas limit required to complete the deposit on L2.","to":"The address of recipient's account on L2."}},"depositETH(uint256,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","gasLimit":"Gas limit required to complete the deposit on L2."}},"depositETHAndCall(address,uint256,bytes,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","data":"Optional data to forward to recipient's account.","gasLimit":"Gas limit required to complete the deposit on L2.","to":"The address of recipient's account on L2."}},"finalizeWithdrawETH(address,address,uint256,bytes)":{"details":"This function should only be called by L1ScrollMessenger. This function should also only be called by L1ETHGateway in L2.","params":{"amount":"The amount of ETH to withdraw.","data":"Optional data to forward to recipient's account.","from":"The address of account who withdraw ETH in L2.","to":"The address of recipient in L1 to receive ETH."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"DepositETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"FinalizeWithdrawETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RefundETH\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETHAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"DepositETH(address,address,uint256,bytes)\":{\"params\":{\"amount\":\"The amount of ETH will be deposited from L1 to L2.\",\"data\":\"The optional calldata passed to recipient in L2.\",\"from\":\"The address of sender in L1.\",\"to\":\"The address of recipient in L2.\"}},\"FinalizeWithdrawETH(address,address,uint256,bytes)\":{\"params\":{\"amount\":\"The amount of ETH withdrawn from L2 to L1.\",\"data\":\"The optional calldata passed to recipient in L1.\",\"from\":\"The address of sender in L2.\",\"to\":\"The address of recipient in L1.\"}},\"RefundETH(address,uint256)\":{\"params\":{\"amount\":\"The amount of ETH refunded to receiver.\",\"recipient\":\"The address of receiver in L1.\"}}},\"kind\":\"dev\",\"methods\":{\"depositETH(address,uint256,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"to\":\"The address of recipient's account on L2.\"}},\"depositETH(uint256,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\"}},\"depositETHAndCall(address,uint256,bytes,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"data\":\"Optional data to forward to recipient's account.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"to\":\"The address of recipient's account on L2.\"}},\"finalizeWithdrawETH(address,address,uint256,bytes)\":{\"details\":\"This function should only be called by L1ScrollMessenger. This function should also only be called by L1ETHGateway in L2.\",\"params\":{\"amount\":\"The amount of ETH to withdraw.\",\"data\":\"Optional data to forward to recipient's account.\",\"from\":\"The address of account who withdraw ETH in L2.\",\"to\":\"The address of recipient in L1 to receive ETH.\"}}},\"version\":1},\"userdoc\":{\"events\":{\"DepositETH(address,address,uint256,bytes)\":{\"notice\":\"Emitted when someone deposit ETH from L1 to L2.\"},\"FinalizeWithdrawETH(address,address,uint256,bytes)\":{\"notice\":\"Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\"},\"RefundETH(address,uint256)\":{\"notice\":\"Emitted when some ETH is refunded.\"}},\"kind\":\"user\",\"methods\":{\"depositETH(address,uint256,uint256)\":{\"notice\":\"Deposit ETH to some recipient's account in L2.\"},\"depositETH(uint256,uint256)\":{\"notice\":\"Deposit ETH to caller's account in L2.\"},\"depositETHAndCall(address,uint256,bytes,uint256)\":{\"notice\":\"Deposit ETH to some recipient's account in L2 and call the target contract.\"},\"finalizeWithdrawETH(address,address,uint256,bytes)\":{\"notice\":\"Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"IL1ETHGateway\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{"depositETH(address,uint256,uint256)":"ce0b63ce","depositETH(uint256,uint256)":"9f8420b3","depositETHAndCall(address,uint256,bytes,uint256)":"aac476f8","finalizeWithdrawETH(address,address,uint256,bytes)":"8eaac8a3"}},"solidity/L1GatewayRouter.sol:IL1GatewayRouter":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DepositERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DepositETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"FinalizeWithdrawERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"FinalizeWithdrawETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldDefaultERC20Gateway","type":"address"},{"indexed":true,"internalType":"address","name":"newDefaultERC20Gateway","type":"address"}],"name":"SetDefaultERC20Gateway","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"oldGateway","type":"address"},{"indexed":true,"internalType":"address","name":"newGateway","type":"address"}],"name":"SetERC20Gateway","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldETHGateway","type":"address"},{"indexed":true,"internalType":"address","name":"newEthGateway","type":"address"}],"name":"SetETHGateway","type":"event"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20AndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"},{"internalType":"uint256","name":"gasLimit","type":"uint256"}],"name":"depositETHAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_l1Token","type":"address"},{"internalType":"address","name":"_l2Token","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"finalizeWithdrawERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"finalizeWithdrawETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getERC20Gateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_l1Token","type":"address"}],"name":"getL2ERC20Address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"sender","type":"address"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"requestERC20","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_defaultERC20Gateway","type":"address"}],"name":"setDefaultERC20Gateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"address[]","name":"_gateways","type":"address[]"}],"name":"setERC20Gateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ethGateway","type":"address"}],"name":"setETHGateway","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"events":{"DepositERC20(address,address,address,address,uint256,bytes)":{"notice":"Emitted when someone deposit ERC20 token from L1 to L2."},"DepositETH(address,address,uint256,bytes)":{"notice":"Emitted when someone deposit ETH from L1 to L2."},"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"notice":"Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient."},"FinalizeWithdrawETH(address,address,uint256,bytes)":{"notice":"Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient."},"RefundERC20(address,address,uint256)":{"notice":"Emitted when some ERC20 token is refunded."},"RefundETH(address,uint256)":{"notice":"Emitted when some ETH is refunded."},"SetDefaultERC20Gateway(address,address)":{"notice":"Emitted when the address of default ERC20 Gateway is updated."},"SetERC20Gateway(address,address,address)":{"notice":"Emitted when the `gateway` for `token` is updated."},"SetETHGateway(address,address)":{"notice":"Emitted when the address of ETH Gateway is updated."}},"kind":"user","methods":{"depositERC20(address,address,uint256,uint256)":{"notice":"Deposit some token to a recipient's account on L2."},"depositERC20(address,uint256,uint256)":{"notice":"Deposit some token to a caller's account on L2."},"depositERC20AndCall(address,address,uint256,bytes,uint256)":{"notice":"Deposit some token to a recipient's account on L2 and call."},"depositETH(address,uint256,uint256)":{"notice":"Deposit ETH to some recipient's account in L2."},"depositETH(uint256,uint256)":{"notice":"Deposit ETH to caller's account in L2."},"depositETHAndCall(address,uint256,bytes,uint256)":{"notice":"Deposit ETH to some recipient's account in L2 and call the target contract."},"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"notice":"Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1."},"finalizeWithdrawETH(address,address,uint256,bytes)":{"notice":"Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1."},"getERC20Gateway(address)":{"notice":"Return the corresponding gateway address for given token address."},"getL2ERC20Address(address)":{"notice":"Return the corresponding l2 token address given l1 token address."},"requestERC20(address,address,uint256)":{"notice":"Request ERC20 token transfer from users to gateways."},"setDefaultERC20Gateway(address)":{"notice":"Update the address of default ERC20 gateway contract."},"setERC20Gateway(address[],address[])":{"notice":"Update the mapping from token address to gateway address."},"setETHGateway(address)":{"notice":"Update the address of ETH gateway contract."}},"version":1},"developerDoc":{"events":{"SetDefaultERC20Gateway(address,address)":{"params":{"newDefaultERC20Gateway":"The address of the new default ERC20 Gateway.","oldDefaultERC20Gateway":"The address of the old default ERC20 Gateway."}},"SetERC20Gateway(address,address,address)":{"params":{"newGateway":"The corresponding address of the new gateway.","oldGateway":"The corresponding address of the old gateway.","token":"The address of token updated."}},"SetETHGateway(address,address)":{"params":{"newEthGateway":"The address of the new ETH Gateway.","oldETHGateway":"The address of the old ETH Gateway."}}},"kind":"dev","methods":{"depositERC20(address,address,uint256,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_gasLimit":"Gas limit required to complete the deposit on L2.","_to":"The address of recipient's account on L2.","_token":"The address of token in L1."}},"depositERC20(address,uint256,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_gasLimit":"Gas limit required to complete the deposit on L2.","_token":"The address of token in L1."}},"depositERC20AndCall(address,address,uint256,bytes,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_data":"Optional data to forward to recipient's account.","_gasLimit":"Gas limit required to complete the deposit on L2.","_to":"The address of recipient's account on L2.","_token":"The address of token in L1."}},"depositETH(address,uint256,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","gasLimit":"Gas limit required to complete the deposit on L2.","to":"The address of recipient's account on L2."}},"depositETH(uint256,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","gasLimit":"Gas limit required to complete the deposit on L2."}},"depositETHAndCall(address,uint256,bytes,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","data":"Optional data to forward to recipient's account.","gasLimit":"Gas limit required to complete the deposit on L2.","to":"The address of recipient's account on L2."}},"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"details":"Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.","params":{"_amount":"The amount of the token to withdraw.","_data":"Optional data to forward to recipient's account.","_from":"The address of account who withdraw the token in L2.","_l1Token":"The address of corresponding L1 token.","_l2Token":"The address of corresponding L2 token.","_to":"The address of recipient in L1 to receive the token."}},"finalizeWithdrawETH(address,address,uint256,bytes)":{"details":"This function should only be called by L1ScrollMessenger. This function should also only be called by L1ETHGateway in L2.","params":{"amount":"The amount of ETH to withdraw.","data":"Optional data to forward to recipient's account.","from":"The address of account who withdraw ETH in L2.","to":"The address of recipient in L1 to receive ETH."}},"getERC20Gateway(address)":{"params":{"_token":"The address of token to query."}},"getL2ERC20Address(address)":{"params":{"_l1Token":"The address of l1 token."}},"requestERC20(address,address,uint256)":{"params":{"amount":"The amount of token to request.","sender":"The address of sender to request fund.","token":"The address of token to request."}},"setDefaultERC20Gateway(address)":{"details":"This function should only be called by contract owner.","params":{"_defaultERC20Gateway":"The address to update."}},"setERC20Gateway(address[],address[])":{"details":"This function should only be called by contract owner.","params":{"_gateways":"The list of addresses of gateways to update.","_tokens":"The list of addresses of tokens to update."}},"setETHGateway(address)":{"details":"This function should only be called by contract owner.","params":{"_ethGateway":"The address to update."}}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"DepositERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"DepositETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"FinalizeWithdrawERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"FinalizeWithdrawETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RefundERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RefundETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldDefaultERC20Gateway\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newDefaultERC20Gateway\",\"type\":\"address\"}],\"name\":\"SetDefaultERC20Gateway\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldGateway\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newGateway\",\"type\":\"address\"}],\"name\":\"SetERC20Gateway\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldETHGateway\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newEthGateway\",\"type\":\"address\"}],\"name\":\"SetETHGateway\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20AndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETHAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_l1Token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_l2Token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"getERC20Gateway\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_l1Token\",\"type\":\"address\"}],\"name\":\"getL2ERC20Address\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"requestERC20\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_defaultERC20Gateway\",\"type\":\"address\"}],\"name\":\"setDefaultERC20Gateway\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_gateways\",\"type\":\"address[]\"}],\"name\":\"setERC20Gateway\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_ethGateway\",\"type\":\"address\"}],\"name\":\"setETHGateway\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"events\":{\"SetDefaultERC20Gateway(address,address)\":{\"params\":{\"newDefaultERC20Gateway\":\"The address of the new default ERC20 Gateway.\",\"oldDefaultERC20Gateway\":\"The address of the old default ERC20 Gateway.\"}},\"SetERC20Gateway(address,address,address)\":{\"params\":{\"newGateway\":\"The corresponding address of the new gateway.\",\"oldGateway\":\"The corresponding address of the old gateway.\",\"token\":\"The address of token updated.\"}},\"SetETHGateway(address,address)\":{\"params\":{\"newEthGateway\":\"The address of the new ETH Gateway.\",\"oldETHGateway\":\"The address of the old ETH Gateway.\"}}},\"kind\":\"dev\",\"methods\":{\"depositERC20(address,address,uint256,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_to\":\"The address of recipient's account on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositERC20(address,uint256,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositERC20AndCall(address,address,uint256,bytes,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_data\":\"Optional data to forward to recipient's account.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_to\":\"The address of recipient's account on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositETH(address,uint256,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"to\":\"The address of recipient's account on L2.\"}},\"depositETH(uint256,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\"}},\"depositETHAndCall(address,uint256,bytes,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"data\":\"Optional data to forward to recipient's account.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"to\":\"The address of recipient's account on L2.\"}},\"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"details\":\"Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.\",\"params\":{\"_amount\":\"The amount of the token to withdraw.\",\"_data\":\"Optional data to forward to recipient's account.\",\"_from\":\"The address of account who withdraw the token in L2.\",\"_l1Token\":\"The address of corresponding L1 token.\",\"_l2Token\":\"The address of corresponding L2 token.\",\"_to\":\"The address of recipient in L1 to receive the token.\"}},\"finalizeWithdrawETH(address,address,uint256,bytes)\":{\"details\":\"This function should only be called by L1ScrollMessenger. This function should also only be called by L1ETHGateway in L2.\",\"params\":{\"amount\":\"The amount of ETH to withdraw.\",\"data\":\"Optional data to forward to recipient's account.\",\"from\":\"The address of account who withdraw ETH in L2.\",\"to\":\"The address of recipient in L1 to receive ETH.\"}},\"getERC20Gateway(address)\":{\"params\":{\"_token\":\"The address of token to query.\"}},\"getL2ERC20Address(address)\":{\"params\":{\"_l1Token\":\"The address of l1 token.\"}},\"requestERC20(address,address,uint256)\":{\"params\":{\"amount\":\"The amount of token to request.\",\"sender\":\"The address of sender to request fund.\",\"token\":\"The address of token to request.\"}},\"setDefaultERC20Gateway(address)\":{\"details\":\"This function should only be called by contract owner.\",\"params\":{\"_defaultERC20Gateway\":\"The address to update.\"}},\"setERC20Gateway(address[],address[])\":{\"details\":\"This function should only be called by contract owner.\",\"params\":{\"_gateways\":\"The list of addresses of gateways to update.\",\"_tokens\":\"The list of addresses of tokens to update.\"}},\"setETHGateway(address)\":{\"details\":\"This function should only be called by contract owner.\",\"params\":{\"_ethGateway\":\"The address to update.\"}}},\"version\":1},\"userdoc\":{\"events\":{\"DepositERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Emitted when someone deposit ERC20 token from L1 to L2.\"},\"DepositETH(address,address,uint256,bytes)\":{\"notice\":\"Emitted when someone deposit ETH from L1 to L2.\"},\"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\"},\"FinalizeWithdrawETH(address,address,uint256,bytes)\":{\"notice\":\"Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\"},\"RefundERC20(address,address,uint256)\":{\"notice\":\"Emitted when some ERC20 token is refunded.\"},\"RefundETH(address,uint256)\":{\"notice\":\"Emitted when some ETH is refunded.\"},\"SetDefaultERC20Gateway(address,address)\":{\"notice\":\"Emitted when the address of default ERC20 Gateway is updated.\"},\"SetERC20Gateway(address,address,address)\":{\"notice\":\"Emitted when the `gateway` for `token` is updated.\"},\"SetETHGateway(address,address)\":{\"notice\":\"Emitted when the address of ETH Gateway is updated.\"}},\"kind\":\"user\",\"methods\":{\"depositERC20(address,address,uint256,uint256)\":{\"notice\":\"Deposit some token to a recipient's account on L2.\"},\"depositERC20(address,uint256,uint256)\":{\"notice\":\"Deposit some token to a caller's account on L2.\"},\"depositERC20AndCall(address,address,uint256,bytes,uint256)\":{\"notice\":\"Deposit some token to a recipient's account on L2 and call.\"},\"depositETH(address,uint256,uint256)\":{\"notice\":\"Deposit ETH to some recipient's account in L2.\"},\"depositETH(uint256,uint256)\":{\"notice\":\"Deposit ETH to caller's account in L2.\"},\"depositETHAndCall(address,uint256,bytes,uint256)\":{\"notice\":\"Deposit ETH to some recipient's account in L2 and call the target contract.\"},\"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\"},\"finalizeWithdrawETH(address,address,uint256,bytes)\":{\"notice\":\"Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\"},\"getERC20Gateway(address)\":{\"notice\":\"Return the corresponding gateway address for given token address.\"},\"getL2ERC20Address(address)\":{\"notice\":\"Return the corresponding l2 token address given l1 token address.\"},\"requestERC20(address,address,uint256)\":{\"notice\":\"Request ERC20 token transfer from users to gateways.\"},\"setDefaultERC20Gateway(address)\":{\"notice\":\"Update the address of default ERC20 gateway contract.\"},\"setERC20Gateway(address[],address[])\":{\"notice\":\"Update the mapping from token address to gateway address.\"},\"setETHGateway(address)\":{\"notice\":\"Update the address of ETH gateway contract.\"}},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"IL1GatewayRouter\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{"depositERC20(address,address,uint256,uint256)":"f219fa66","depositERC20(address,uint256,uint256)":"21425ee0","depositERC20AndCall(address,address,uint256,bytes,uint256)":"0aea8c26","depositETH(address,uint256,uint256)":"ce0b63ce","depositETH(uint256,uint256)":"9f8420b3","depositETHAndCall(address,uint256,bytes,uint256)":"aac476f8","finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":"84bd13b0","finalizeWithdrawETH(address,address,uint256,bytes)":"8eaac8a3","getERC20Gateway(address)":"43c66741","getL2ERC20Address(address)":"c676ad29","requestERC20(address,address,uint256)":"c52a3bbc","setDefaultERC20Gateway(address)":"5dfd5b9a","setERC20Gateway(address[],address[])":"635c8637","setETHGateway(address)":"3d1d31c7"}},"solidity/L1GatewayRouter.sol:Initializable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"custom:oz-upgrades-unsafe-allow":"constructor constructor() { _disableInitializers(); } ``` ====","details":"This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in case an upgrade adds a module that needs to be initialized. For example: [.hljs-theme-light.nopadding] ```solidity contract MyToken is ERC20Upgradeable { function initialize() initializer public { __ERC20_init(\"MyToken\", \"MTK\"); } } contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { function initializeV2() reinitializer(2) public { __ERC20Permit_init(\"MyToken\"); } } ``` TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding] ```","events":{"Initialized(uint8)":{"details":"Triggered when the contract has been initialized or reinitialized."}},"kind":"dev","methods":{},"stateVariables":{"_initialized":{"custom:oz-retyped-from":"bool","details":"Indicates that the contract has been initialized."},"_initializing":{"details":"Indicates that the contract is in the process of being initialized."}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"}],\"devdoc\":{\"custom:oz-upgrades-unsafe-allow\":\"constructor constructor() { _disableInitializers(); } ``` ====\",\"details\":\"This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. The initialization functions use a version number. Once a version number is used, it is consumed and cannot be reused. This mechanism prevents re-execution of each \\\"step\\\" but allows the creation of new initialization steps in case an upgrade adds a module that needs to be initialized. For example: [.hljs-theme-light.nopadding] ```solidity contract MyToken is ERC20Upgradeable { function initialize() initializer public { __ERC20_init(\\\"MyToken\\\", \\\"MTK\\\"); } } contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { function initializeV2() reinitializer(2) public { __ERC20Permit_init(\\\"MyToken\\\"); } } ``` TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. [CAUTION] ==== Avoid leaving a contract uninitialized. An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: [.hljs-theme-light.nopadding] ```\",\"events\":{\"Initialized(uint8)\":{\"details\":\"Triggered when the contract has been initialized or reinitialized.\"}},\"kind\":\"dev\",\"methods\":{},\"stateVariables\":{\"_initialized\":{\"custom:oz-retyped-from\":\"bool\",\"details\":\"Indicates that the contract has been initialized.\"},\"_initializing\":{\"details\":\"Indicates that the contract is in the process of being initialized.\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"Initializable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{}},"solidity/L1GatewayRouter.sol:L1GatewayRouter":{"code":"0x608060405234801561001057600080fd5b5061001961001e565b6100dd565b600054610100900460ff161561008a5760405162461bcd60e51b815260206004820152602760248201527f496e697469616c697a61626c653a20636f6e747261637420697320696e697469604482015266616c697a696e6760c81b606482015260840160405180910390fd5b60005460ff908116146100db576000805460ff191660ff9081179091556040519081527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b565b611d35806100ec6000396000f3fe6080604052600436106101755760003560e01c80638c00ce73116100cb578063c52a3bbc1161007f578063ce8c3e0611610059578063ce8c3e06146103b0578063f219fa66146103d0578063f2fde38b146103e357600080fd5b8063c52a3bbc1461034f578063c676ad291461037d578063ce0b63ce1461039d57600080fd5b80638eaac8a3116100b05780638eaac8a31461031b5780639f8420b314610329578063aac476f81461033c57600080fd5b80638c00ce73146102dd5780638da5cb5b146102fd57600080fd5b8063485cc9551161012d578063705b05b811610107578063705b05b81461027f578063715018a6146102b557806384bd13b0146102ca57600080fd5b8063485cc9551461021f5780635dfd5b9a1461023f578063635c86371461025f57600080fd5b80633a9a7b201161015e5780633a9a7b20146101a25780633d1d31c7146101df57806343c66741146101ff57600080fd5b80630aea8c261461017a57806321425ee01461018f575b600080fd5b61018d610188366004611683565b610403565b005b61018d61019d3660046116f7565b6105ec565b3480156101ae57600080fd5b506068546101c2906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101eb57600080fd5b5061018d6101fa36600461172c565b61062b565b34801561020b57600080fd5b506101c261021a36600461172c565b61069d565b34801561022b57600080fd5b5061018d61023a366004611749565b6106d3565b34801561024b57600080fd5b5061018d61025a36600461172c565b61092e565b34801561026b57600080fd5b5061018d61027a366004611800565b6109a0565b34801561028b57600080fd5b506101c261029a36600461172c565b6067602052600090815260409020546001600160a01b031681565b3480156102c157600080fd5b5061018d610b66565b61018d6102d83660046118ad565b610b7a565b3480156102e957600080fd5b506065546101c2906001600160a01b031681565b34801561030957600080fd5b506033546001600160a01b03166101c2565b61018d6102d8366004611945565b61018d6103373660046119b8565b610bc2565b61018d61034a3660046119da565b610bff565b34801561035b57600080fd5b5061036f61036a366004611a3b565b610d7b565b6040519081526020016101d6565b34801561038957600080fd5b506101c261039836600461172c565b610f1e565b61018d6103ab3660046116f7565b610fcd565b3480156103bc57600080fd5b506066546101c2906001600160a01b031681565b61018d6103de366004611a7c565b610fd9565b3480156103ef57600080fd5b5061018d6103fe36600461172c565b610fec565b6068546001600160a01b0316156104615760405162461bcd60e51b815260206004820152601360248201527f4f6e6c79206e6f7420696e20636f6e746578740000000000000000000000000060448201526064015b60405180910390fd5b600061046c8661069d565b90506001600160a01b0381166104c45760405162461bcd60e51b815260206004820152601460248201527f6e6f206761746577617920617661696c61626c650000000000000000000000006044820152606401610458565b606880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556000338460405160200161050c929190611b30565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f0aea8c2600000000000000000000000000000000000000000000000000000000825291506001600160a01b03831690630aea8c26903490610589908b908b908b9088908b90600401611b52565b6000604051808303818588803b1580156105a257600080fd5b505af11580156105b6573d6000803e3d6000fd5b5050606880547fffffffffffffffffffffffff000000000000000000000000000000000000000016905550505050505050505050565b61062683338460005b6040519080825280601f01601f19166020018201604052801561061f576020820181803683370190505b5085610403565b505050565b61063361107c565b606580546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907fa1bfcc6dd729ad197a1180f44d5c12bcc630943df0874b9ed53da23165621b6a90600090a35050565b6001600160a01b03808216600090815260676020526040812054909116806106cd57506066546001600160a01b03165b92915050565b600054610100900460ff16158080156106f35750600054600160ff909116105b8061070d5750303b15801561070d575060005460ff166001145b61077f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610458565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156107dd57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6107e56110d6565b6001600160a01b0382161561085657606680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040516000907f2904fcae71038f87b116fd2875871e153722cabddd71de1b77473de263cd74d1908290a35b6001600160a01b038316156108c757606580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040516000907fa1bfcc6dd729ad197a1180f44d5c12bcc630943df0874b9ed53da23165621b6a908290a35b801561062657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b61093661107c565b606680546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f2904fcae71038f87b116fd2875871e153722cabddd71de1b77473de263cd74d190600090a35050565b6109a861107c565b80518251146109f95760405162461bcd60e51b815260206004820152600f60248201527f6c656e677468206d69736d6174636800000000000000000000000000000000006044820152606401610458565b60005b825181101561062657600060676000858481518110610a1d57610a1d611b96565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03169050828281518110610a6d57610a6d611b96565b602002602001015160676000868581518110610a8b57610a8b611b96565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550828281518110610ae957610ae9611b96565b60200260200101516001600160a01b0316816001600160a01b0316858481518110610b1657610b16611b96565b60200260200101516001600160a01b03167f0ead4808404683f66d413d788a768219ea9785c97889221193103841a5841eaf60405160405180910390a45080610b5e81611bf4565b9150506109fc565b610b6e61107c565b610b78600061115b565b565b60405162461bcd60e51b815260206004820152601660248201527f73686f756c64206e657665722062652063616c6c6564000000000000000000006044820152606401610458565b610bfb338360005b6040519080825280601f01601f191660200182016040528015610bf4576020820181803683370190505b5084610bff565b5050565b6068546001600160a01b031615610c585760405162461bcd60e51b815260206004820152601360248201527f4f6e6c79206e6f7420696e20636f6e74657874000000000000000000000000006044820152606401610458565b6065546001600160a01b031680610cb15760405162461bcd60e51b815260206004820152601560248201527f657468206761746577617920617661696c61626c6500000000000000000000006044820152606401610458565b60003384604051602001610cc6929190611b30565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527faac476f800000000000000000000000000000000000000000000000000000000825291506001600160a01b0383169063aac476f8903490610d41908a908a9087908a90600401611c2c565b6000604051808303818588803b158015610d5a57600080fd5b505af1158015610d6e573d6000803e3d6000fd5b5050505050505050505050565b6068546000906001600160a01b0316336001600160a01b031614610de15760405162461bcd60e51b815260206004820152601760248201527f4f6e6c7920696e206465706f73697420636f6e746578740000000000000000006044820152606401610458565b6000336040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0380831660048301529192506000918616906370a0823190602401602060405180830381865afa158015610e49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6d9190611c65565b9050610e846001600160a01b0386168784876111c5565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301528291908716906370a0823190602401602060405180830381865afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190611c65565b610f149190611c7e565b9695505050505050565b600080610f2a8361069d565b90506001600160a01b038116610f435750600092915050565b6040517fc676ad290000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015282169063c676ad2990602401602060405180830381865afa158015610fa2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc69190611c91565b9392505050565b61062683836000610bca565b610fe684848460006105f5565b50505050565b610ff461107c565b6001600160a01b0381166110705760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610458565b6110798161115b565b50565b6033546001600160a01b03163314610b785760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610458565b600054610100900460ff166111535760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610458565b610b7861124d565b603380546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610fe69085906112d3565b600054610100900460ff166112ca5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610458565b610b783361115b565b6000611328826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113bb9092919063ffffffff16565b90508051600014806113495750808060200190518101906113499190611cae565b6106265760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610458565b60606113ca84846000856113d2565b949350505050565b60608247101561144a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610458565b600080866001600160a01b031685876040516114669190611cd0565b60006040518083038185875af1925050503d80600081146114a3576040519150601f19603f3d011682016040523d82523d6000602084013e6114a8565b606091505b50915091506114b9878383876114c4565b979650505050505050565b6060831561153357825160000361152c576001600160a01b0385163b61152c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610458565b50816113ca565b6113ca83838151156115485781518083602001fd5b8060405162461bcd60e51b81526004016104589190611cec565b6001600160a01b038116811461107957600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156115ed576115ed611577565b604052919050565b600082601f83011261160657600080fd5b813567ffffffffffffffff81111561162057611620611577565b61165160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016115a6565b81815284602083860101111561166657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561169b57600080fd5b85356116a681611562565b945060208601356116b681611562565b935060408601359250606086013567ffffffffffffffff8111156116d957600080fd5b6116e5888289016115f5565b95989497509295608001359392505050565b60008060006060848603121561170c57600080fd5b833561171781611562565b95602085013595506040909401359392505050565b60006020828403121561173e57600080fd5b8135610fc681611562565b6000806040838503121561175c57600080fd5b823561176781611562565b9150602083013561177781611562565b809150509250929050565b600082601f83011261179357600080fd5b8135602067ffffffffffffffff8211156117af576117af611577565b8160051b6117be8282016115a6565b92835284810182019282810190878511156117d857600080fd5b83870192505b848310156114b95782356117f181611562565b825291830191908301906117de565b6000806040838503121561181357600080fd5b823567ffffffffffffffff8082111561182b57600080fd5b61183786838701611782565b9350602085013591508082111561184d57600080fd5b5061185a85828601611782565b9150509250929050565b60008083601f84011261187657600080fd5b50813567ffffffffffffffff81111561188e57600080fd5b6020830191508360208285010111156118a657600080fd5b9250929050565b600080600080600080600060c0888a0312156118c857600080fd5b87356118d381611562565b965060208801356118e381611562565b955060408801356118f381611562565b9450606088013561190381611562565b93506080880135925060a088013567ffffffffffffffff81111561192657600080fd5b6119328a828b01611864565b989b979a50959850939692959293505050565b60008060008060006080868803121561195d57600080fd5b853561196881611562565b9450602086013561197881611562565b935060408601359250606086013567ffffffffffffffff81111561199b57600080fd5b6119a788828901611864565b969995985093965092949392505050565b600080604083850312156119cb57600080fd5b50508035926020909101359150565b600080600080608085870312156119f057600080fd5b84356119fb81611562565b935060208501359250604085013567ffffffffffffffff811115611a1e57600080fd5b611a2a878288016115f5565b949793965093946060013593505050565b600080600060608486031215611a5057600080fd5b8335611a5b81611562565b92506020840135611a6b81611562565b929592945050506040919091013590565b60008060008060808587031215611a9257600080fd5b8435611a9d81611562565b93506020850135611aad81611562565b93969395505050506040820135916060013590565b60005b83811015611add578181015183820152602001611ac5565b50506000910152565b60008151808452611afe816020860160208601611ac2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6001600160a01b03831681526040602082015260006113ca6040830184611ae6565b60006001600160a01b03808816835280871660208401525084604083015260a06060830152611b8460a0830185611ae6565b90508260808301529695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611c2557611c25611bc5565b5060010190565b6001600160a01b0385168152836020820152608060408201526000611c546080830185611ae6565b905082606083015295945050505050565b600060208284031215611c7757600080fd5b5051919050565b818103818111156106cd576106cd611bc5565b600060208284031215611ca357600080fd5b8151610fc681611562565b600060208284031215611cc057600080fd5b81518015158114610fc657600080fd5b60008251611ce2818460208701611ac2565b9190910192915050565b602081526000610fc66020830184611ae656fea26469706673582212202cec4819d1be9525e2fff8e6e0b45cae981bb05643bafabf8c9910d2c41af38264736f6c63430008110033","runtime-code":"0x6080604052600436106101755760003560e01c80638c00ce73116100cb578063c52a3bbc1161007f578063ce8c3e0611610059578063ce8c3e06146103b0578063f219fa66146103d0578063f2fde38b146103e357600080fd5b8063c52a3bbc1461034f578063c676ad291461037d578063ce0b63ce1461039d57600080fd5b80638eaac8a3116100b05780638eaac8a31461031b5780639f8420b314610329578063aac476f81461033c57600080fd5b80638c00ce73146102dd5780638da5cb5b146102fd57600080fd5b8063485cc9551161012d578063705b05b811610107578063705b05b81461027f578063715018a6146102b557806384bd13b0146102ca57600080fd5b8063485cc9551461021f5780635dfd5b9a1461023f578063635c86371461025f57600080fd5b80633a9a7b201161015e5780633a9a7b20146101a25780633d1d31c7146101df57806343c66741146101ff57600080fd5b80630aea8c261461017a57806321425ee01461018f575b600080fd5b61018d610188366004611683565b610403565b005b61018d61019d3660046116f7565b6105ec565b3480156101ae57600080fd5b506068546101c2906001600160a01b031681565b6040516001600160a01b0390911681526020015b60405180910390f35b3480156101eb57600080fd5b5061018d6101fa36600461172c565b61062b565b34801561020b57600080fd5b506101c261021a36600461172c565b61069d565b34801561022b57600080fd5b5061018d61023a366004611749565b6106d3565b34801561024b57600080fd5b5061018d61025a36600461172c565b61092e565b34801561026b57600080fd5b5061018d61027a366004611800565b6109a0565b34801561028b57600080fd5b506101c261029a36600461172c565b6067602052600090815260409020546001600160a01b031681565b3480156102c157600080fd5b5061018d610b66565b61018d6102d83660046118ad565b610b7a565b3480156102e957600080fd5b506065546101c2906001600160a01b031681565b34801561030957600080fd5b506033546001600160a01b03166101c2565b61018d6102d8366004611945565b61018d6103373660046119b8565b610bc2565b61018d61034a3660046119da565b610bff565b34801561035b57600080fd5b5061036f61036a366004611a3b565b610d7b565b6040519081526020016101d6565b34801561038957600080fd5b506101c261039836600461172c565b610f1e565b61018d6103ab3660046116f7565b610fcd565b3480156103bc57600080fd5b506066546101c2906001600160a01b031681565b61018d6103de366004611a7c565b610fd9565b3480156103ef57600080fd5b5061018d6103fe36600461172c565b610fec565b6068546001600160a01b0316156104615760405162461bcd60e51b815260206004820152601360248201527f4f6e6c79206e6f7420696e20636f6e746578740000000000000000000000000060448201526064015b60405180910390fd5b600061046c8661069d565b90506001600160a01b0381166104c45760405162461bcd60e51b815260206004820152601460248201527f6e6f206761746577617920617661696c61626c650000000000000000000000006044820152606401610458565b606880547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0383161790556000338460405160200161050c929190611b30565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527f0aea8c2600000000000000000000000000000000000000000000000000000000825291506001600160a01b03831690630aea8c26903490610589908b908b908b9088908b90600401611b52565b6000604051808303818588803b1580156105a257600080fd5b505af11580156105b6573d6000803e3d6000fd5b5050606880547fffffffffffffffffffffffff000000000000000000000000000000000000000016905550505050505050505050565b61062683338460005b6040519080825280601f01601f19166020018201604052801561061f576020820181803683370190505b5085610403565b505050565b61063361107c565b606580546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907fa1bfcc6dd729ad197a1180f44d5c12bcc630943df0874b9ed53da23165621b6a90600090a35050565b6001600160a01b03808216600090815260676020526040812054909116806106cd57506066546001600160a01b03165b92915050565b600054610100900460ff16158080156106f35750600054600160ff909116105b8061070d5750303b15801561070d575060005460ff166001145b61077f5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201527f647920696e697469616c697a65640000000000000000000000000000000000006064820152608401610458565b600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0016600117905580156107dd57600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff166101001790555b6107e56110d6565b6001600160a01b0382161561085657606680547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0384169081179091556040516000907f2904fcae71038f87b116fd2875871e153722cabddd71de1b77473de263cd74d1908290a35b6001600160a01b038316156108c757606580547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0385169081179091556040516000907fa1bfcc6dd729ad197a1180f44d5c12bcc630943df0874b9ed53da23165621b6a908290a35b801561062657600080547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a1505050565b61093661107c565b606680546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f2904fcae71038f87b116fd2875871e153722cabddd71de1b77473de263cd74d190600090a35050565b6109a861107c565b80518251146109f95760405162461bcd60e51b815260206004820152600f60248201527f6c656e677468206d69736d6174636800000000000000000000000000000000006044820152606401610458565b60005b825181101561062657600060676000858481518110610a1d57610a1d611b96565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060009054906101000a90046001600160a01b03169050828281518110610a6d57610a6d611b96565b602002602001015160676000868581518110610a8b57610a8b611b96565b60200260200101516001600160a01b03166001600160a01b0316815260200190815260200160002060006101000a8154816001600160a01b0302191690836001600160a01b03160217905550828281518110610ae957610ae9611b96565b60200260200101516001600160a01b0316816001600160a01b0316858481518110610b1657610b16611b96565b60200260200101516001600160a01b03167f0ead4808404683f66d413d788a768219ea9785c97889221193103841a5841eaf60405160405180910390a45080610b5e81611bf4565b9150506109fc565b610b6e61107c565b610b78600061115b565b565b60405162461bcd60e51b815260206004820152601660248201527f73686f756c64206e657665722062652063616c6c6564000000000000000000006044820152606401610458565b610bfb338360005b6040519080825280601f01601f191660200182016040528015610bf4576020820181803683370190505b5084610bff565b5050565b6068546001600160a01b031615610c585760405162461bcd60e51b815260206004820152601360248201527f4f6e6c79206e6f7420696e20636f6e74657874000000000000000000000000006044820152606401610458565b6065546001600160a01b031680610cb15760405162461bcd60e51b815260206004820152601560248201527f657468206761746577617920617661696c61626c6500000000000000000000006044820152606401610458565b60003384604051602001610cc6929190611b30565b604080517fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0818403018152908290527faac476f800000000000000000000000000000000000000000000000000000000825291506001600160a01b0383169063aac476f8903490610d41908a908a9087908a90600401611c2c565b6000604051808303818588803b158015610d5a57600080fd5b505af1158015610d6e573d6000803e3d6000fd5b5050505050505050505050565b6068546000906001600160a01b0316336001600160a01b031614610de15760405162461bcd60e51b815260206004820152601760248201527f4f6e6c7920696e206465706f73697420636f6e746578740000000000000000006044820152606401610458565b6000336040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0380831660048301529192506000918616906370a0823190602401602060405180830381865afa158015610e49573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e6d9190611c65565b9050610e846001600160a01b0386168784876111c5565b6040517f70a082310000000000000000000000000000000000000000000000000000000081526001600160a01b0383811660048301528291908716906370a0823190602401602060405180830381865afa158015610ee6573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f0a9190611c65565b610f149190611c7e565b9695505050505050565b600080610f2a8361069d565b90506001600160a01b038116610f435750600092915050565b6040517fc676ad290000000000000000000000000000000000000000000000000000000081526001600160a01b03848116600483015282169063c676ad2990602401602060405180830381865afa158015610fa2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fc69190611c91565b9392505050565b61062683836000610bca565b610fe684848460006105f5565b50505050565b610ff461107c565b6001600160a01b0381166110705760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610458565b6110798161115b565b50565b6033546001600160a01b03163314610b785760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610458565b600054610100900460ff166111535760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610458565b610b7861124d565b603380546001600160a01b038381167fffffffffffffffffffffffff0000000000000000000000000000000000000000831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604080516001600160a01b0385811660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd00000000000000000000000000000000000000000000000000000000179052610fe69085906112d3565b600054610100900460ff166112ca5760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201527f6e697469616c697a696e670000000000000000000000000000000000000000006064820152608401610458565b610b783361115b565b6000611328826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c6564815250856001600160a01b03166113bb9092919063ffffffff16565b90508051600014806113495750808060200190518101906113499190611cae565b6106265760405162461bcd60e51b815260206004820152602a60248201527f5361666545524332303a204552433230206f7065726174696f6e20646964206e60448201527f6f742073756363656564000000000000000000000000000000000000000000006064820152608401610458565b60606113ca84846000856113d2565b949350505050565b60608247101561144a5760405162461bcd60e51b815260206004820152602660248201527f416464726573733a20696e73756666696369656e742062616c616e636520666f60448201527f722063616c6c00000000000000000000000000000000000000000000000000006064820152608401610458565b600080866001600160a01b031685876040516114669190611cd0565b60006040518083038185875af1925050503d80600081146114a3576040519150601f19603f3d011682016040523d82523d6000602084013e6114a8565b606091505b50915091506114b9878383876114c4565b979650505050505050565b6060831561153357825160000361152c576001600160a01b0385163b61152c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e74726163740000006044820152606401610458565b50816113ca565b6113ca83838151156115485781518083602001fd5b8060405162461bcd60e51b81526004016104589190611cec565b6001600160a01b038116811461107957600080fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604051601f82017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe016810167ffffffffffffffff811182821017156115ed576115ed611577565b604052919050565b600082601f83011261160657600080fd5b813567ffffffffffffffff81111561162057611620611577565b61165160207fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0601f840116016115a6565b81815284602083860101111561166657600080fd5b816020850160208301376000918101602001919091529392505050565b600080600080600060a0868803121561169b57600080fd5b85356116a681611562565b945060208601356116b681611562565b935060408601359250606086013567ffffffffffffffff8111156116d957600080fd5b6116e5888289016115f5565b95989497509295608001359392505050565b60008060006060848603121561170c57600080fd5b833561171781611562565b95602085013595506040909401359392505050565b60006020828403121561173e57600080fd5b8135610fc681611562565b6000806040838503121561175c57600080fd5b823561176781611562565b9150602083013561177781611562565b809150509250929050565b600082601f83011261179357600080fd5b8135602067ffffffffffffffff8211156117af576117af611577565b8160051b6117be8282016115a6565b92835284810182019282810190878511156117d857600080fd5b83870192505b848310156114b95782356117f181611562565b825291830191908301906117de565b6000806040838503121561181357600080fd5b823567ffffffffffffffff8082111561182b57600080fd5b61183786838701611782565b9350602085013591508082111561184d57600080fd5b5061185a85828601611782565b9150509250929050565b60008083601f84011261187657600080fd5b50813567ffffffffffffffff81111561188e57600080fd5b6020830191508360208285010111156118a657600080fd5b9250929050565b600080600080600080600060c0888a0312156118c857600080fd5b87356118d381611562565b965060208801356118e381611562565b955060408801356118f381611562565b9450606088013561190381611562565b93506080880135925060a088013567ffffffffffffffff81111561192657600080fd5b6119328a828b01611864565b989b979a50959850939692959293505050565b60008060008060006080868803121561195d57600080fd5b853561196881611562565b9450602086013561197881611562565b935060408601359250606086013567ffffffffffffffff81111561199b57600080fd5b6119a788828901611864565b969995985093965092949392505050565b600080604083850312156119cb57600080fd5b50508035926020909101359150565b600080600080608085870312156119f057600080fd5b84356119fb81611562565b935060208501359250604085013567ffffffffffffffff811115611a1e57600080fd5b611a2a878288016115f5565b949793965093946060013593505050565b600080600060608486031215611a5057600080fd5b8335611a5b81611562565b92506020840135611a6b81611562565b929592945050506040919091013590565b60008060008060808587031215611a9257600080fd5b8435611a9d81611562565b93506020850135611aad81611562565b93969395505050506040820135916060013590565b60005b83811015611add578181015183820152602001611ac5565b50506000910152565b60008151808452611afe816020860160208601611ac2565b601f017fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe0169290920160200192915050565b6001600160a01b03831681526040602082015260006113ca6040830184611ae6565b60006001600160a01b03808816835280871660208401525084604083015260a06060830152611b8460a0830185611ae6565b90508260808301529695505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b60007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8203611c2557611c25611bc5565b5060010190565b6001600160a01b0385168152836020820152608060408201526000611c546080830185611ae6565b905082606083015295945050505050565b600060208284031215611c7757600080fd5b5051919050565b818103818111156106cd576106cd611bc5565b600060208284031215611ca357600080fd5b8151610fc681611562565b600060208284031215611cc057600080fd5b81518015158114610fc657600080fd5b60008251611ce2818460208701611ac2565b9190910192915050565b602081526000610fc66020830184611ae656fea26469706673582212202cec4819d1be9525e2fff8e6e0b45cae981bb05643bafabf8c9910d2c41af38264736f6c63430008110033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"43643:7635:0:-:0;;;44742:53;;;;;;;;;-1:-1:-1;44766:22:0;:20;:22::i;:::-;43643:7635;;28203:280;28271:13;;;;;;;28270:14;28262:66;;;;-1:-1:-1;;;28262:66:0;;216:2:1;28262:66:0;;;198:21:1;255:2;235:18;;;228:30;294:34;274:18;;;267:62;-1:-1:-1;;;345:18:1;;;338:37;392:19;;28262:66:0;;;;;;;;28342:12;;28358:15;28342:12;;;:31;28338:139;;28389:12;:30;;-1:-1:-1;;28389:30:0;28404:15;28389:30;;;;;;28438:28;;564:36:1;;;28438:28:0;;552:2:1;537:18;28438:28:0;;;;;;;28338:139;28203:280::o;422:184:1:-;43643:7635:0;;;;;;","srcMapRuntime":"43643:7635:0:-:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;47763:698;;;;;;:::i;:::-;;:::i;:::-;;47223:222;;;;;;:::i;:::-;;:::i;44302:31::-;;;;;;;;;;-1:-1:-1;44302:31:0;;;;-1:-1:-1;;;;;44302:31:0;;;;;;-1:-1:-1;;;;;2586:55:1;;;2568:74;;2556:2;2541:18;44302:31:0;;;;;;;;50247:216;;;;;;;;;;-1:-1:-1;50247:216:0;;;;;:::i;:::-;;:::i;46070:244::-;;;;;;;;;;-1:-1:-1;46070:244:0;;;;;:::i;:::-;;:::i;45008:579::-;;;;;;;;;;-1:-1:-1;45008:579:0;;;;;:::i;:::-;;:::i;50506:297::-;;;;;;;;;;-1:-1:-1;50506:297:0;;;;;:::i;:::-;;:::i;50846:430::-;;;;;;;;;;-1:-1:-1;50846:430:0;;;;;:::i;:::-;;:::i;44179:47::-;;;;;;;;;;-1:-1:-1;44179:47:0;;;;;:::i;:::-;;;;;;;;;;;;-1:-1:-1;;;;;44179:47:0;;;35175:101;;;;;;;;;;;;;:::i;48503:229::-;;;;;;:::i;:::-;;:::i;43873:25::-;;;;;;;;;;-1:-1:-1;43873:25:0;;;;-1:-1:-1;;;;;43873:25:0;;;34552:85;;;;;;;;;;-1:-1:-1;34624:6:0;;-1:-1:-1;;;;;34624:6:0;34552:85;;49919:193;;;;;;:::i;48933:164::-;;;;;;:::i;:::-;;:::i;49375:504::-;;;;;;:::i;:::-;;:::i;46573:441::-;;;;;;;;;;-1:-1:-1;46573:441:0;;;;;:::i;:::-;;:::i;:::-;;;8301:25:1;;;8289:2;8274:18;46573:441:0;8155:177:1;45724:303:0;;;;;;;;;;-1:-1:-1;45724:303:0;;;;;:::i;:::-;;:::i;49137:198::-;;;;;;:::i;:::-;;:::i;44004:34::-;;;;;;;;;;-1:-1:-1;44004:34:0;;;;-1:-1:-1;;;;;44004:34:0;;;47487:234;;;;;;:::i;:::-;;:::i;35425:198::-;;;;;;;;;;-1:-1:-1;35425:198:0;;;;;:::i;:::-;;:::i;47763:698::-;44472:16;;-1:-1:-1;;;;;44472:16:0;:30;44464:62;;;;-1:-1:-1;;;44464:62:0;;9069:2:1;44464:62:0;;;9051:21:1;9108:2;9088:18;;;9081:30;9147:21;9127:18;;;9120:49;9186:18;;44464:62:0;;;;;;;;;47974:16:::1;47993:23;48009:6;47993:15;:23::i;:::-;47974:42:::0;-1:-1:-1;;;;;;48034:22:0;::::1;48026:55;;;::::0;-1:-1:-1;;;48026:55:0;;9417:2:1;48026:55:0::1;::::0;::::1;9399:21:1::0;9456:2;9436:18;;;9429:30;9495:22;9475:18;;;9468:50;9535:18;;48026:55:0::1;9215:344:1::0;48026:55:0::1;48125:16;:27:::0;;;::::1;-1:-1:-1::0;;;;;48125:27:0;::::1;;::::0;;-1:-1:-1;29817:10:0;48255:5:::1;48230:31;;;;;;;;;:::i;:::-;;::::0;;;;;::::1;::::0;;;;;;;48272:109;;;48230:31;-1:-1:-1;;;;;;48272:45:0;::::1;::::0;::::1;::::0;48325:9:::1;::::0;48272:109:::1;::::0;48336:6;;48344:3;;48349:7;;48230:31;;48371:9;;48272:109:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;-1:-1:-1::0;;48425:16:0::1;:29:::0;;;::::1;::::0;;-1:-1:-1;;;;;;;;;;47763:698:0:o;47223:222::-;47363:75;47383:6;29817:10;47405:7;47424:1;47414:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;47414:12:0;;47428:9;47363:19;:75::i;:::-;47223:222;;;:::o;50247:216::-;34445:13;:11;:13::i;:::-;50348:10:::1;::::0;;-1:-1:-1;;;;;50368:27:0;;::::1;::::0;;::::1;::::0;::::1;::::0;;;50411:45:::1;::::0;50348:10;::::1;::::0;50368:27;50348:10;;50411:45:::1;::::0;50323:22:::1;::::0;50411:45:::1;50313:150;50247:216:::0;:::o;46070:244::-;-1:-1:-1;;;;;46170:20:0;;;46132:7;46170:20;;;:12;:20;;;;;;46132:7;;46170:20;;46200:83;;-1:-1:-1;46253:19:0;;-1:-1:-1;;;;;46253:19:0;46200:83;46299:8;46070:244;-1:-1:-1;;46070:244:0:o;45008:579::-;25543:19;25566:13;;;;;;25565:14;;25611:34;;;;-1:-1:-1;25629:12:0;;25644:1;25629:12;;;;:16;25611:34;25610:108;;;-1:-1:-1;25690:4:0;6894:19;:23;;;25651:66;;-1:-1:-1;25700:12:0;;;;;:17;25651:66;25589:201;;;;-1:-1:-1;;;25589:201:0;;11285:2:1;25589:201:0;;;11267:21:1;11324:2;11304:18;;;11297:30;11363:34;11343:18;;;11336:62;11434:16;11414:18;;;11407:44;11468:19;;25589:201:0;11083:410:1;25589:201:0;25800:12;:16;;;;25815:1;25800:16;;;25826:65;;;;25860:13;:20;;;;;;;;25826:65;45110:35:::1;:33;:35::i;:::-;-1:-1:-1::0;;;;;45208:34:0;::::1;::::0;45204:182:::1;;45258:19;:42:::0;;;::::1;-1:-1:-1::0;;;;;45258:42:0;::::1;::::0;;::::1;::::0;;;45319:56:::1;::::0;-1:-1:-1;;45319:56:0::1;::::0;-1:-1:-1;;45319:56:0::1;45204:182;-1:-1:-1::0;;;;;45448:25:0;::::1;::::0;45444:137:::1;;45489:10;:24:::0;;;::::1;-1:-1:-1::0;;;;;45489:24:0;::::1;::::0;;::::1;::::0;;;45532:38:::1;::::0;-1:-1:-1;;45532:38:0::1;::::0;-1:-1:-1;;45532:38:0::1;45444:137;25915:14:::0;25911:99;;;25961:5;25945:21;;;;;;25985:14;;-1:-1:-1;11650:36:1;;25985:14:0;;11638:2:1;11623:18;25985:14:0;;;;;;;25533:483;45008:579;;:::o;50506:297::-;34445:13;:11;:13::i;:::-;50634:19:::1;::::0;;-1:-1:-1;;;;;50663:45:0;;::::1;::::0;;::::1;::::0;::::1;::::0;;;50724:72:::1;::::0;50634:19;::::1;::::0;50663:45;50634:19;;50724:72:::1;::::0;50600:31:::1;::::0;50724:72:::1;50590:213;50506:297:::0;:::o;50846:430::-;34445:13;:11;:13::i;:::-;50980:9:::1;:16;50962:7;:14;:34;50954:62;;;::::0;-1:-1:-1;;;50954:62:0;;11899:2:1;50954:62:0::1;::::0;::::1;11881:21:1::0;11938:2;11918:18;;;11911:30;11977:17;11957:18;;;11950:45;12012:18;;50954:62:0::1;11697:339:1::0;50954:62:0::1;51032:9;51027:243;51051:7;:14;51047:1;:18;51027:243;;;51086:19;51108:12;:24;51121:7;51129:1;51121:10;;;;;;;;:::i;:::-;;;;;;;-1:-1:-1::0;;;;;51108:24:0::1;-1:-1:-1::0;;;;;51108:24:0::1;;;;;;;;;;;;;;;;;;;;-1:-1:-1::0;;;;;51108:24:0::1;51086:46;;51173:9;51183:1;51173:12;;;;;;;;:::i;:::-;;;;;;;51146;:24;51159:7;51167:1;51159:10;;;;;;;;:::i;:::-;;;;;;;-1:-1:-1::0;;;;;51146:24:0::1;-1:-1:-1::0;;;;;51146:24:0::1;;;;;;;;;;;;;:39;;;;;-1:-1:-1::0;;;;;51146:39:0::1;;;;;-1:-1:-1::0;;;;;51146:39:0::1;;;;;;51246:9;51256:1;51246:12;;;;;;;;:::i;:::-;;;;;;;-1:-1:-1::0;;;;;51205:54:0::1;51233:11;-1:-1:-1::0;;;;;51205:54:0::1;51221:7;51229:1;51221:10;;;;;;;;:::i;:::-;;;;;;;-1:-1:-1::0;;;;;51205:54:0::1;;;;;;;;;;;-1:-1:-1::0;51067:3:0;::::1;::::0;::::1;:::i;:::-;;;;51027:243;;35175:101:::0;34445:13;:11;:13::i;:::-;35239:30:::1;35266:1;35239:18;:30::i;:::-;35175:101::o:0;48503:229::-;48693:32;;-1:-1:-1;;;48693:32:0;;12821:2:1;48693:32:0;;;12803:21:1;12860:2;12840:18;;;12833:30;12899:24;12879:18;;;12872:52;12941:18;;48693:32:0;12619:346:1;48933:164:0;49025:65;29817:10;49057:7;49076:1;49066:12;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;-1:-1:-1;49066:12:0;;49080:9;49025:17;:65::i;:::-;48933:164;;:::o;49375:504::-;44472:16;;-1:-1:-1;;;;;44472:16:0;:30;44464:62;;;;-1:-1:-1;;;44464:62:0;;9069:2:1;44464:62:0;;;9051:21:1;9108:2;9088:18;;;9081:30;9147:21;9127:18;;;9120:49;9186:18;;44464:62:0;8867:343:1;44464:62:0;49579:10:::1;::::0;-1:-1:-1;;;;;49579:10:0::1;::::0;49599:56:::1;;;::::0;-1:-1:-1;;;49599:56:0;;13172:2:1;49599:56:0::1;::::0;::::1;13154:21:1::0;13211:2;13191:18;;;13184:30;13250:23;13230:18;;;13223:51;13291:18;;49599:56:0::1;12970:345:1::0;49599:56:0::1;49706:24;29817:10:::0;49758:5:::1;49733:31;;;;;;;;;:::i;:::-;;::::0;;;;;::::1;::::0;;;;;;;49775:97;;;49733:31;-1:-1:-1;;;;;;49775:41:0;::::1;::::0;::::1;::::0;49824:9:::1;::::0;49775:97:::1;::::0;49835:3;;49840:7;;49733:31;;49862:9;;49775:97:::1;;;:::i;:::-;;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;::::0;::::1;;;;;;;;;;49550:329;;49375:504:::0;;;;:::o;46573:441::-;44609:16;;46707:7;;-1:-1:-1;;;;;44609:16:0;29817:10;-1:-1:-1;;;;;44593:32:0;;44585:68;;;;-1:-1:-1;;;44585:68:0;;14008:2:1;44585:68:0;;;13990:21:1;14047:2;14027:18;;;14020:30;14086:25;14066:18;;;14059:53;14129:18;;44585:68:0;13806:347:1;44585:68:0;46726:15:::1;29817:10:::0;46785:44:::1;::::0;;;;-1:-1:-1;;;;;2586:55:1;;;46785:44:0::1;::::0;::::1;2568:74:1::0;46726:30:0;;-1:-1:-1;46766:16:0::1;::::0;46785:35;::::1;::::0;::::1;::::0;2541:18:1;;46785:44:0::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;46766:63:::0;-1:-1:-1;46839:69:0::1;-1:-1:-1::0;;;;;46839:42:0;::::1;46882:7:::0;46891;46900;46839:42:::1;:69::i;:::-;46928:44;::::0;;;;-1:-1:-1;;;;;2586:55:1;;;46928:44:0::1;::::0;::::1;2568:74:1::0;46975:8:0;;46928:35;;::::1;::::0;::::1;::::0;2541:18:1;;46928:44:0::1;;;;;;;;;;;;;;;;;::::0;::::1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;:55;;;;:::i;:::-;46918:65:::0;46573:441;-1:-1:-1;;;;;;46573:441:0:o;45724:303::-;45803:7;45822:16;45841:27;45857:10;45841:15;:27::i;:::-;45822:46;-1:-1:-1;;;;;;45882:22:0;;45878:70;;-1:-1:-1;45935:1:0;;45724:303;-1:-1:-1;;45724:303:0:o;45878:70::-;45965:55;;;;;-1:-1:-1;;;;;2586:55:1;;;45965::0;;;2568:74:1;45965:43:0;;;;;2541:18:1;;45965:55:0;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;:::i;:::-;45958:62;45724:303;-1:-1:-1;;;45724:303:0:o;49137:198::-;49272:56;49290:3;49295:7;49314:1;49304:12;;47487:234;47648:66;47668:6;47676:3;47681:7;47700:1;47690:12;;47648:66;47487:234;;;;:::o;35425:198::-;34445:13;:11;:13::i;:::-;-1:-1:-1;;;;;35513:22:0;::::1;35505:73;;;::::0;-1:-1:-1;;;35505:73:0;;14938:2:1;35505:73:0::1;::::0;::::1;14920:21:1::0;14977:2;14957:18;;;14950:30;15016:34;14996:18;;;14989:62;15087:8;15067:18;;;15060:36;15113:19;;35505:73:0::1;14736:402:1::0;35505:73:0::1;35588:28;35607:8;35588:18;:28::i;:::-;35425:198:::0;:::o;34710:130::-;34624:6;;-1:-1:-1;;;;;34624:6:0;29817:10;34773:23;34765:68;;;;-1:-1:-1;;;34765:68:0;;15345:2:1;34765:68:0;;;15327:21:1;;;15364:18;;;15357:30;15423:34;15403:18;;;15396:62;15475:18;;34765:68:0;15143:356:1;34114:95:0;27638:13;;;;;;;27630:69;;;;-1:-1:-1;;;27630:69:0;;15706:2:1;27630:69:0;;;15688:21:1;15745:2;15725:18;;;15718:30;15784:34;15764:18;;;15757:62;15855:13;15835:18;;;15828:41;15886:19;;27630:69:0;15504:407:1;27630:69:0;34176:26:::1;:24;:26::i;35777:187::-:0;35869:6;;;-1:-1:-1;;;;;35885:17:0;;;;;;;;;;;35917:40;;35869:6;;;35885:17;35869:6;;35917:40;;35850:16;;35917:40;35840:124;35777:187;:::o;37583:214::-;37721:68;;;-1:-1:-1;;;;;16197:15:1;;;37721:68:0;;;16179:34:1;16249:15;;16229:18;;;16222:43;16281:18;;;;16274:34;;;37721:68:0;;;;;;;;;;16091:18:1;;;;37721:68:0;;;;;;;;;;37744:27;37721:68;;;37694:96;;37714:5;;37694:19;:96::i;34215:111::-;27638:13;;;;;;;27630:69;;;;-1:-1:-1;;;27630:69:0;;15706:2:1;27630:69:0;;;15688:21:1;15745:2;15725:18;;;15718:30;15784:34;15764:18;;;15757:62;15855:13;15835:18;;;15828:41;15886:19;;27630:69:0;15504:407:1;27630:69:0;34287:32:::1;29817:10:::0;34287:18:::1;:32::i;41490:653::-:0;41920:23;41946:69;41974:4;41946:69;;;;;;;;;;;;;;;;;41954:5;-1:-1:-1;;;;;41946:27:0;;;:69;;;;;:::i;:::-;41920:95;;42033:10;:17;42054:1;42033:22;:56;;;;42070:10;42059:30;;;;;;;;;;;;:::i;:::-;42025:111;;;;-1:-1:-1;;;42025:111:0;;16803:2:1;42025:111:0;;;16785:21:1;16842:2;16822:18;;;16815:30;16881:34;16861:18;;;16854:62;16952:12;16932:18;;;16925:40;16982:19;;42025:111:0;16601:406:1;9300:223:0;9433:12;9464:52;9486:6;9494:4;9500:1;9503:12;9464:21;:52::i;:::-;9457:59;9300:223;-1:-1:-1;;;;9300:223:0:o;10357:446::-;10522:12;10579:5;10554:21;:30;;10546:81;;;;-1:-1:-1;;;10546:81:0;;17214:2:1;10546:81:0;;;17196:21:1;17253:2;17233:18;;;17226:30;17292:34;17272:18;;;17265:62;17363:8;17343:18;;;17336:36;17389:19;;10546:81:0;17012:402:1;10546:81:0;10638:12;10652:23;10679:6;-1:-1:-1;;;;;10679:11:0;10698:5;10705:4;10679:31;;;;;;:::i;:::-;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;10637:73;;;;10727:69;10754:6;10762:7;10771:10;10783:12;10727:26;:69::i;:::-;10720:76;10357:446;-1:-1:-1;;;;;;;10357:446:0:o;12863:628::-;13043:12;13071:7;13067:418;;;13098:10;:17;13119:1;13098:22;13094:286;;-1:-1:-1;;;;;6894:19:0;;;13305:60;;;;-1:-1:-1;;;13305:60:0;;17913:2:1;13305:60:0;;;17895:21:1;17952:2;17932:18;;;17925:30;17991:31;17971:18;;;17964:59;18040:18;;13305:60:0;17711:353:1;13305:60:0;-1:-1:-1;13400:10:0;13393:17;;13067:418;13441:33;13449:10;13461:12;14172:17;;:21;14168:379;;14400:10;14394:17;14456:15;14443:10;14439:2;14435:19;14428:44;14168:379;14523:12;14516:20;;-1:-1:-1;;;14516:20:0;;;;;;;;:::i;14:154:1:-;-1:-1:-1;;;;;93:5:1;89:54;82:5;79:65;69:93;;158:1;155;148:12;173:184;225:77;222:1;215:88;322:4;319:1;312:15;346:4;343:1;336:15;362:334;433:2;427:9;489:2;479:13;;494:66;475:86;463:99;;592:18;577:34;;613:22;;;574:62;571:88;;;639:18;;:::i;:::-;675:2;668:22;362:334;;-1:-1:-1;362:334:1:o;701:589::-;743:5;796:3;789:4;781:6;777:17;773:27;763:55;;814:1;811;804:12;763:55;850:6;837:20;876:18;872:2;869:26;866:52;;;898:18;;:::i;:::-;942:114;1050:4;981:66;974:4;970:2;966:13;962:86;958:97;942:114;:::i;:::-;1081:2;1072:7;1065:19;1127:3;1120:4;1115:2;1107:6;1103:15;1099:26;1096:35;1093:55;;;1144:1;1141;1134:12;1093:55;1209:2;1202:4;1194:6;1190:17;1183:4;1174:7;1170:18;1157:55;1257:1;1232:16;;;1250:4;1228:27;1221:38;;;;1236:7;701:589;-1:-1:-1;;;701:589:1:o;1295:734::-;1399:6;1407;1415;1423;1431;1484:3;1472:9;1463:7;1459:23;1455:33;1452:53;;;1501:1;1498;1491:12;1452:53;1540:9;1527:23;1559:31;1584:5;1559:31;:::i;:::-;1609:5;-1:-1:-1;1666:2:1;1651:18;;1638:32;1679:33;1638:32;1679:33;:::i;:::-;1731:7;-1:-1:-1;1785:2:1;1770:18;;1757:32;;-1:-1:-1;1840:2:1;1825:18;;1812:32;1867:18;1856:30;;1853:50;;;1899:1;1896;1889:12;1853:50;1922:49;1963:7;1954:6;1943:9;1939:22;1922:49;:::i;:::-;1295:734;;;;-1:-1:-1;1295:734:1;;2018:3;2003:19;1990:33;;1295:734;-1:-1:-1;;;1295:734:1:o;2034:383::-;2111:6;2119;2127;2180:2;2168:9;2159:7;2155:23;2151:32;2148:52;;;2196:1;2193;2186:12;2148:52;2235:9;2222:23;2254:31;2279:5;2254:31;:::i;:::-;2304:5;2356:2;2341:18;;2328:32;;-1:-1:-1;2407:2:1;2392:18;;;2379:32;;2034:383;-1:-1:-1;;;2034:383:1:o;2653:247::-;2712:6;2765:2;2753:9;2744:7;2740:23;2736:32;2733:52;;;2781:1;2778;2771:12;2733:52;2820:9;2807:23;2839:31;2864:5;2839:31;:::i;2905:388::-;2973:6;2981;3034:2;3022:9;3013:7;3009:23;3005:32;3002:52;;;3050:1;3047;3040:12;3002:52;3089:9;3076:23;3108:31;3133:5;3108:31;:::i;:::-;3158:5;-1:-1:-1;3215:2:1;3200:18;;3187:32;3228:33;3187:32;3228:33;:::i;:::-;3280:7;3270:17;;;2905:388;;;;;:::o;3298:787::-;3352:5;3405:3;3398:4;3390:6;3386:17;3382:27;3372:55;;3423:1;3420;3413:12;3372:55;3459:6;3446:20;3485:4;3508:18;3504:2;3501:26;3498:52;;;3530:18;;:::i;:::-;3576:2;3573:1;3569:10;3599:28;3623:2;3619;3615:11;3599:28;:::i;:::-;3661:15;;;3731;;;3727:24;;;3692:12;;;;3763:15;;;3760:35;;;3791:1;3788;3781:12;3760:35;3827:2;3819:6;3815:15;3804:26;;3839:217;3855:6;3850:3;3847:15;3839:217;;;3935:3;3922:17;3952:31;3977:5;3952:31;:::i;:::-;3996:18;;3872:12;;;;4034;;;;3839:217;;4090:595;4208:6;4216;4269:2;4257:9;4248:7;4244:23;4240:32;4237:52;;;4285:1;4282;4275:12;4237:52;4325:9;4312:23;4354:18;4395:2;4387:6;4384:14;4381:34;;;4411:1;4408;4401:12;4381:34;4434:61;4487:7;4478:6;4467:9;4463:22;4434:61;:::i;:::-;4424:71;;4548:2;4537:9;4533:18;4520:32;4504:48;;4577:2;4567:8;4564:16;4561:36;;;4593:1;4590;4583:12;4561:36;;4616:63;4671:7;4660:8;4649:9;4645:24;4616:63;:::i;:::-;4606:73;;;4090:595;;;;;:::o;4690:347::-;4741:8;4751:6;4805:3;4798:4;4790:6;4786:17;4782:27;4772:55;;4823:1;4820;4813:12;4772:55;-1:-1:-1;4846:20:1;;4889:18;4878:30;;4875:50;;;4921:1;4918;4911:12;4875:50;4958:4;4950:6;4946:17;4934:29;;5010:3;5003:4;4994:6;4986;4982:19;4978:30;4975:39;4972:59;;;5027:1;5024;5017:12;4972:59;4690:347;;;;;:::o;5042:1038::-;5157:6;5165;5173;5181;5189;5197;5205;5258:3;5246:9;5237:7;5233:23;5229:33;5226:53;;;5275:1;5272;5265:12;5226:53;5314:9;5301:23;5333:31;5358:5;5333:31;:::i;:::-;5383:5;-1:-1:-1;5440:2:1;5425:18;;5412:32;5453:33;5412:32;5453:33;:::i;:::-;5505:7;-1:-1:-1;5564:2:1;5549:18;;5536:32;5577:33;5536:32;5577:33;:::i;:::-;5629:7;-1:-1:-1;5688:2:1;5673:18;;5660:32;5701:33;5660:32;5701:33;:::i;:::-;5753:7;-1:-1:-1;5807:3:1;5792:19;;5779:33;;-1:-1:-1;5863:3:1;5848:19;;5835:33;5891:18;5880:30;;5877:50;;;5923:1;5920;5913:12;5877:50;5962:58;6012:7;6003:6;5992:9;5988:22;5962:58;:::i;:::-;5042:1038;;;;-1:-1:-1;5042:1038:1;;-1:-1:-1;5042:1038:1;;;;5936:84;;-1:-1:-1;;;5042:1038:1:o;6085:754::-;6182:6;6190;6198;6206;6214;6267:3;6255:9;6246:7;6242:23;6238:33;6235:53;;;6284:1;6281;6274:12;6235:53;6323:9;6310:23;6342:31;6367:5;6342:31;:::i;:::-;6392:5;-1:-1:-1;6449:2:1;6434:18;;6421:32;6462:33;6421:32;6462:33;:::i;:::-;6514:7;-1:-1:-1;6568:2:1;6553:18;;6540:32;;-1:-1:-1;6623:2:1;6608:18;;6595:32;6650:18;6639:30;;6636:50;;;6682:1;6679;6672:12;6636:50;6721:58;6771:7;6762:6;6751:9;6747:22;6721:58;:::i;:::-;6085:754;;;;-1:-1:-1;6085:754:1;;-1:-1:-1;6798:8:1;;6695:84;6085:754;-1:-1:-1;;;6085:754:1:o;6844:248::-;6912:6;6920;6973:2;6961:9;6952:7;6948:23;6944:32;6941:52;;;6989:1;6986;6979:12;6941:52;-1:-1:-1;;7012:23:1;;;7082:2;7067:18;;;7054:32;;-1:-1:-1;6844:248:1:o;7097:592::-;7192:6;7200;7208;7216;7269:3;7257:9;7248:7;7244:23;7240:33;7237:53;;;7286:1;7283;7276:12;7237:53;7325:9;7312:23;7344:31;7369:5;7344:31;:::i;:::-;7394:5;-1:-1:-1;7446:2:1;7431:18;;7418:32;;-1:-1:-1;7501:2:1;7486:18;;7473:32;7528:18;7517:30;;7514:50;;;7560:1;7557;7550:12;7514:50;7583:49;7624:7;7615:6;7604:9;7600:22;7583:49;:::i;:::-;7097:592;;;;-1:-1:-1;7573:59:1;;7679:2;7664:18;7651:32;;-1:-1:-1;;;7097:592:1:o;7694:456::-;7771:6;7779;7787;7840:2;7828:9;7819:7;7815:23;7811:32;7808:52;;;7856:1;7853;7846:12;7808:52;7895:9;7882:23;7914:31;7939:5;7914:31;:::i;:::-;7964:5;-1:-1:-1;8021:2:1;8006:18;;7993:32;8034:33;7993:32;8034:33;:::i;:::-;7694:456;;8086:7;;-1:-1:-1;;;8140:2:1;8125:18;;;;8112:32;;7694:456::o;8337:525::-;8423:6;8431;8439;8447;8500:3;8488:9;8479:7;8475:23;8471:33;8468:53;;;8517:1;8514;8507:12;8468:53;8556:9;8543:23;8575:31;8600:5;8575:31;:::i;:::-;8625:5;-1:-1:-1;8682:2:1;8667:18;;8654:32;8695:33;8654:32;8695:33;:::i;:::-;8337:525;;8747:7;;-1:-1:-1;;;;8801:2:1;8786:18;;8773:32;;8852:2;8837:18;8824:32;;8337:525::o;9564:250::-;9649:1;9659:113;9673:6;9670:1;9667:13;9659:113;;;9749:11;;;9743:18;9730:11;;;9723:39;9695:2;9688:10;9659:113;;;-1:-1:-1;;9806:1:1;9788:16;;9781:27;9564:250::o;9819:329::-;9860:3;9898:5;9892:12;9925:6;9920:3;9913:19;9941:76;10010:6;10003:4;9998:3;9994:14;9987:4;9980:5;9976:16;9941:76;:::i;:::-;10062:2;10050:15;10067:66;10046:88;10037:98;;;;10137:4;10033:109;;9819:329;-1:-1:-1;;9819:329:1:o;10153:337::-;-1:-1:-1;;;;;10332:6:1;10328:55;10317:9;10310:74;10420:2;10415;10404:9;10400:18;10393:30;10291:4;10440:44;10480:2;10469:9;10465:18;10457:6;10440:44;:::i;10495:583::-;10717:4;-1:-1:-1;;;;;10827:2:1;10819:6;10815:15;10804:9;10797:34;10879:2;10871:6;10867:15;10862:2;10851:9;10847:18;10840:43;;10919:6;10914:2;10903:9;10899:18;10892:34;10962:3;10957:2;10946:9;10942:18;10935:31;10983:45;11023:3;11012:9;11008:19;11000:6;10983:45;:::i;:::-;10975:53;;11065:6;11059:3;11048:9;11044:19;11037:35;10495:583;;;;;;;;:::o;12041:184::-;12093:77;12090:1;12083:88;12190:4;12187:1;12180:15;12214:4;12211:1;12204:15;12230:184;12282:77;12279:1;12272:88;12379:4;12376:1;12369:15;12403:4;12400:1;12393:15;12419:195;12458:3;12489:66;12482:5;12479:77;12476:103;;12559:18;;:::i;:::-;-1:-1:-1;12606:1:1;12595:13;;12419:195::o;13320:481::-;-1:-1:-1;;;;;13555:6:1;13551:55;13540:9;13533:74;13643:6;13638:2;13627:9;13623:18;13616:34;13686:3;13681:2;13670:9;13666:18;13659:31;13514:4;13707:45;13747:3;13736:9;13732:19;13724:6;13707:45;:::i;:::-;13699:53;;13788:6;13783:2;13772:9;13768:18;13761:34;13320:481;;;;;;;:::o;14158:184::-;14228:6;14281:2;14269:9;14260:7;14256:23;14252:32;14249:52;;;14297:1;14294;14287:12;14249:52;-1:-1:-1;14320:16:1;;14158:184;-1:-1:-1;14158:184:1:o;14347:128::-;14414:9;;;14435:11;;;14432:37;;;14449:18;;:::i;14480:251::-;14550:6;14603:2;14591:9;14582:7;14578:23;14574:32;14571:52;;;14619:1;14616;14609:12;14571:52;14651:9;14645:16;14670:31;14695:5;14670:31;:::i;16319:277::-;16386:6;16439:2;16427:9;16418:7;16414:23;16410:32;16407:52;;;16455:1;16452;16445:12;16407:52;16487:9;16481:16;16540:5;16533:13;16526:21;16519:5;16516:32;16506:60;;16562:1;16559;16552:12;17419:287;17548:3;17586:6;17580:13;17602:66;17661:6;17656:3;17649:4;17641:6;17637:17;17602:66;:::i;:::-;17684:16;;;;;17419:287;-1:-1:-1;;17419:287:1:o;18069:219::-;18218:2;18207:9;18200:21;18181:4;18238:44;18278:2;18267:9;18263:18;18255:6;18238:44;:::i","abiDefinition":[{"inputs":[],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DepositERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"DepositETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"l1Token","type":"address"},{"indexed":true,"internalType":"address","name":"l2Token","type":"address"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"FinalizeWithdrawERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"},{"indexed":false,"internalType":"bytes","name":"data","type":"bytes"}],"name":"FinalizeWithdrawETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundERC20","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"recipient","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RefundETH","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldDefaultERC20Gateway","type":"address"},{"indexed":true,"internalType":"address","name":"newDefaultERC20Gateway","type":"address"}],"name":"SetDefaultERC20Gateway","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"token","type":"address"},{"indexed":true,"internalType":"address","name":"oldGateway","type":"address"},{"indexed":true,"internalType":"address","name":"newGateway","type":"address"}],"name":"SetERC20Gateway","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"oldETHGateway","type":"address"},{"indexed":true,"internalType":"address","name":"newEthGateway","type":"address"}],"name":"SetETHGateway","type":"event"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"ERC20Gateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"defaultERC20Gateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositERC20AndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"},{"internalType":"uint256","name":"_gasLimit","type":"uint256"}],"name":"depositETHAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"ethGateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"finalizeWithdrawERC20","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"finalizeWithdrawETH","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"gatewayInContext","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_token","type":"address"}],"name":"getERC20Gateway","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_l1Address","type":"address"}],"name":"getL2ERC20Address","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_ethGateway","type":"address"},{"internalType":"address","name":"_defaultERC20Gateway","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_sender","type":"address"},{"internalType":"address","name":"_token","type":"address"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"requestERC20","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newDefaultERC20Gateway","type":"address"}],"name":"setDefaultERC20Gateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"address[]","name":"_gateways","type":"address[]"}],"name":"setERC20Gateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_newEthGateway","type":"address"}],"name":"setETHGateway","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"events":{"DepositERC20(address,address,address,address,uint256,bytes)":{"notice":"Emitted when someone deposit ERC20 token from L1 to L2."},"DepositETH(address,address,uint256,bytes)":{"notice":"Emitted when someone deposit ETH from L1 to L2."},"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"notice":"Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient."},"FinalizeWithdrawETH(address,address,uint256,bytes)":{"notice":"Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient."},"RefundERC20(address,address,uint256)":{"notice":"Emitted when some ERC20 token is refunded."},"RefundETH(address,uint256)":{"notice":"Emitted when some ETH is refunded."},"SetDefaultERC20Gateway(address,address)":{"notice":"Emitted when the address of default ERC20 Gateway is updated."},"SetERC20Gateway(address,address,address)":{"notice":"Emitted when the `gateway` for `token` is updated."},"SetETHGateway(address,address)":{"notice":"Emitted when the address of ETH Gateway is updated."}},"kind":"user","methods":{"ERC20Gateway(address)":{"notice":"Mapping from ERC20 token address to corresponding L1ERC20Gateway."},"defaultERC20Gateway()":{"notice":"The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract."},"depositERC20(address,address,uint256,uint256)":{"notice":"Deposit some token to a recipient's account on L2."},"depositERC20(address,uint256,uint256)":{"notice":"Deposit some token to a caller's account on L2."},"depositERC20AndCall(address,address,uint256,bytes,uint256)":{"notice":"Deposit some token to a recipient's account on L2 and call."},"depositETH(address,uint256,uint256)":{"notice":"Deposit ETH to some recipient's account in L2."},"depositETH(uint256,uint256)":{"notice":"Deposit ETH to caller's account in L2."},"depositETHAndCall(address,uint256,bytes,uint256)":{"notice":"Deposit ETH to some recipient's account in L2 and call the target contract."},"ethGateway()":{"notice":"The address of L1ETHGateway."},"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"notice":"Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1."},"finalizeWithdrawETH(address,address,uint256,bytes)":{"notice":"Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1."},"gatewayInContext()":{"notice":"The address of gateway in current execution context."},"getERC20Gateway(address)":{"notice":"Return the corresponding gateway address for given token address."},"getL2ERC20Address(address)":{"notice":"Return the corresponding l2 token address given l1 token address."},"initialize(address,address)":{"notice":"Initialize the storage of L1GatewayRouter."},"requestERC20(address,address,uint256)":{"notice":"Request ERC20 token transfer from users to gateways."},"setDefaultERC20Gateway(address)":{"notice":"Update the address of default ERC20 gateway contract."},"setERC20Gateway(address[],address[])":{"notice":"Update the mapping from token address to gateway address."},"setETHGateway(address)":{"notice":"Update the address of ETH gateway contract."}},"notice":"The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens. All deposited tokens are routed to corresponding gateways.","version":1},"developerDoc":{"details":"One can also use this contract to query L1/L2 token address mapping. In the future, ERC-721 and ERC-1155 tokens will be added to the router too.","kind":"dev","methods":{"depositERC20(address,address,uint256,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_gasLimit":"Gas limit required to complete the deposit on L2.","_to":"The address of recipient's account on L2.","_token":"The address of token in L1."}},"depositERC20(address,uint256,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_gasLimit":"Gas limit required to complete the deposit on L2.","_token":"The address of token in L1."}},"depositERC20AndCall(address,address,uint256,bytes,uint256)":{"details":"Make this function payable to send relayer fee in Ether.","params":{"_amount":"The amount of token to transfer.","_data":"Optional data to forward to recipient's account.","_gasLimit":"Gas limit required to complete the deposit on L2.","_to":"The address of recipient's account on L2.","_token":"The address of token in L1."}},"depositETH(address,uint256,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","gasLimit":"Gas limit required to complete the deposit on L2.","to":"The address of recipient's account on L2."}},"depositETH(uint256,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","gasLimit":"Gas limit required to complete the deposit on L2."}},"depositETHAndCall(address,uint256,bytes,uint256)":{"params":{"amount":"The amount of ETH to be deposited.","data":"Optional data to forward to recipient's account.","gasLimit":"Gas limit required to complete the deposit on L2.","to":"The address of recipient's account on L2."}},"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":{"details":"Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.","params":{"_amount":"The amount of the token to withdraw.","_data":"Optional data to forward to recipient's account.","_from":"The address of account who withdraw the token in L2.","_l1Token":"The address of corresponding L1 token.","_l2Token":"The address of corresponding L2 token.","_to":"The address of recipient in L1 to receive the token."}},"finalizeWithdrawETH(address,address,uint256,bytes)":{"details":"This function should only be called by L1ScrollMessenger. This function should also only be called by L1ETHGateway in L2.","params":{"amount":"The amount of ETH to withdraw.","data":"Optional data to forward to recipient's account.","from":"The address of account who withdraw ETH in L2.","to":"The address of recipient in L1 to receive ETH."}},"getERC20Gateway(address)":{"params":{"_token":"The address of token to query."}},"getL2ERC20Address(address)":{"params":{"_l1Token":"The address of l1 token."}},"initialize(address,address)":{"params":{"_defaultERC20Gateway":"The address of default ERC20 Gateway contract.","_ethGateway":"The address of L1ETHGateway contract."}},"owner()":{"details":"Returns the address of the current owner."},"renounceOwnership()":{"details":"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner."},"requestERC20(address,address,uint256)":{"details":"All the gateways should have reentrancy guard to prevent potential attack though this function.","params":{"amount":"The amount of token to request.","sender":"The address of sender to request fund.","token":"The address of token to request."}},"setDefaultERC20Gateway(address)":{"details":"This function should only be called by contract owner.","params":{"_defaultERC20Gateway":"The address to update."}},"setERC20Gateway(address[],address[])":{"details":"This function should only be called by contract owner.","params":{"_gateways":"The list of addresses of gateways to update.","_tokens":"The list of addresses of tokens to update."}},"setETHGateway(address)":{"details":"This function should only be called by contract owner.","params":{"_ethGateway":"The address to update."}},"transferOwnership(address)":{"details":"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner."}},"title":"L1GatewayRouter","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"inputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"DepositERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"DepositETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l1Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"l2Token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"FinalizeWithdrawERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"},{\"indexed\":false,\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"name\":\"FinalizeWithdrawETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RefundERC20\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"RefundETH\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldDefaultERC20Gateway\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newDefaultERC20Gateway\",\"type\":\"address\"}],\"name\":\"SetDefaultERC20Gateway\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"token\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldGateway\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newGateway\",\"type\":\"address\"}],\"name\":\"SetERC20Gateway\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"oldETHGateway\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newEthGateway\",\"type\":\"address\"}],\"name\":\"SetETHGateway\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"name\":\"ERC20Gateway\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"defaultERC20Gateway\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositERC20AndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_to\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"_data\",\"type\":\"bytes\"},{\"internalType\":\"uint256\",\"name\":\"_gasLimit\",\"type\":\"uint256\"}],\"name\":\"depositETHAndCall\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"ethGateway\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawERC20\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"},{\"internalType\":\"bytes\",\"name\":\"\",\"type\":\"bytes\"}],\"name\":\"finalizeWithdrawETH\",\"outputs\":[],\"stateMutability\":\"payable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"gatewayInContext\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"}],\"name\":\"getERC20Gateway\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_l1Address\",\"type\":\"address\"}],\"name\":\"getL2ERC20Address\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_ethGateway\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_defaultERC20Gateway\",\"type\":\"address\"}],\"name\":\"initialize\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"_token\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"_amount\",\"type\":\"uint256\"}],\"name\":\"requestERC20\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newDefaultERC20Gateway\",\"type\":\"address\"}],\"name\":\"setDefaultERC20Gateway\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address[]\",\"name\":\"_tokens\",\"type\":\"address[]\"},{\"internalType\":\"address[]\",\"name\":\"_gateways\",\"type\":\"address[]\"}],\"name\":\"setERC20Gateway\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"_newEthGateway\",\"type\":\"address\"}],\"name\":\"setETHGateway\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"One can also use this contract to query L1/L2 token address mapping. In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\",\"kind\":\"dev\",\"methods\":{\"depositERC20(address,address,uint256,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_to\":\"The address of recipient's account on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositERC20(address,uint256,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositERC20AndCall(address,address,uint256,bytes,uint256)\":{\"details\":\"Make this function payable to send relayer fee in Ether.\",\"params\":{\"_amount\":\"The amount of token to transfer.\",\"_data\":\"Optional data to forward to recipient's account.\",\"_gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"_to\":\"The address of recipient's account on L2.\",\"_token\":\"The address of token in L1.\"}},\"depositETH(address,uint256,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"to\":\"The address of recipient's account on L2.\"}},\"depositETH(uint256,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\"}},\"depositETHAndCall(address,uint256,bytes,uint256)\":{\"params\":{\"amount\":\"The amount of ETH to be deposited.\",\"data\":\"Optional data to forward to recipient's account.\",\"gasLimit\":\"Gas limit required to complete the deposit on L2.\",\"to\":\"The address of recipient's account on L2.\"}},\"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"details\":\"Make this function payable to handle WETH deposit/withdraw. The function should only be called by L1ScrollMessenger. The function should also only be called by L2ERC20Gateway in L2.\",\"params\":{\"_amount\":\"The amount of the token to withdraw.\",\"_data\":\"Optional data to forward to recipient's account.\",\"_from\":\"The address of account who withdraw the token in L2.\",\"_l1Token\":\"The address of corresponding L1 token.\",\"_l2Token\":\"The address of corresponding L2 token.\",\"_to\":\"The address of recipient in L1 to receive the token.\"}},\"finalizeWithdrawETH(address,address,uint256,bytes)\":{\"details\":\"This function should only be called by L1ScrollMessenger. This function should also only be called by L1ETHGateway in L2.\",\"params\":{\"amount\":\"The amount of ETH to withdraw.\",\"data\":\"Optional data to forward to recipient's account.\",\"from\":\"The address of account who withdraw ETH in L2.\",\"to\":\"The address of recipient in L1 to receive ETH.\"}},\"getERC20Gateway(address)\":{\"params\":{\"_token\":\"The address of token to query.\"}},\"getL2ERC20Address(address)\":{\"params\":{\"_l1Token\":\"The address of l1 token.\"}},\"initialize(address,address)\":{\"params\":{\"_defaultERC20Gateway\":\"The address of default ERC20 Gateway contract.\",\"_ethGateway\":\"The address of L1ETHGateway contract.\"}},\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"requestERC20(address,address,uint256)\":{\"details\":\"All the gateways should have reentrancy guard to prevent potential attack though this function.\",\"params\":{\"amount\":\"The amount of token to request.\",\"sender\":\"The address of sender to request fund.\",\"token\":\"The address of token to request.\"}},\"setDefaultERC20Gateway(address)\":{\"details\":\"This function should only be called by contract owner.\",\"params\":{\"_defaultERC20Gateway\":\"The address to update.\"}},\"setERC20Gateway(address[],address[])\":{\"details\":\"This function should only be called by contract owner.\",\"params\":{\"_gateways\":\"The list of addresses of gateways to update.\",\"_tokens\":\"The list of addresses of tokens to update.\"}},\"setETHGateway(address)\":{\"details\":\"This function should only be called by contract owner.\",\"params\":{\"_ethGateway\":\"The address to update.\"}},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"title\":\"L1GatewayRouter\",\"version\":1},\"userdoc\":{\"events\":{\"DepositERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Emitted when someone deposit ERC20 token from L1 to L2.\"},\"DepositETH(address,address,uint256,bytes)\":{\"notice\":\"Emitted when someone deposit ETH from L1 to L2.\"},\"FinalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\"},\"FinalizeWithdrawETH(address,address,uint256,bytes)\":{\"notice\":\"Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\"},\"RefundERC20(address,address,uint256)\":{\"notice\":\"Emitted when some ERC20 token is refunded.\"},\"RefundETH(address,uint256)\":{\"notice\":\"Emitted when some ETH is refunded.\"},\"SetDefaultERC20Gateway(address,address)\":{\"notice\":\"Emitted when the address of default ERC20 Gateway is updated.\"},\"SetERC20Gateway(address,address,address)\":{\"notice\":\"Emitted when the `gateway` for `token` is updated.\"},\"SetETHGateway(address,address)\":{\"notice\":\"Emitted when the address of ETH Gateway is updated.\"}},\"kind\":\"user\",\"methods\":{\"ERC20Gateway(address)\":{\"notice\":\"Mapping from ERC20 token address to corresponding L1ERC20Gateway.\"},\"defaultERC20Gateway()\":{\"notice\":\"The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\"},\"depositERC20(address,address,uint256,uint256)\":{\"notice\":\"Deposit some token to a recipient's account on L2.\"},\"depositERC20(address,uint256,uint256)\":{\"notice\":\"Deposit some token to a caller's account on L2.\"},\"depositERC20AndCall(address,address,uint256,bytes,uint256)\":{\"notice\":\"Deposit some token to a recipient's account on L2 and call.\"},\"depositETH(address,uint256,uint256)\":{\"notice\":\"Deposit ETH to some recipient's account in L2.\"},\"depositETH(uint256,uint256)\":{\"notice\":\"Deposit ETH to caller's account in L2.\"},\"depositETHAndCall(address,uint256,bytes,uint256)\":{\"notice\":\"Deposit ETH to some recipient's account in L2 and call the target contract.\"},\"ethGateway()\":{\"notice\":\"The address of L1ETHGateway.\"},\"finalizeWithdrawERC20(address,address,address,address,uint256,bytes)\":{\"notice\":\"Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\"},\"finalizeWithdrawETH(address,address,uint256,bytes)\":{\"notice\":\"Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\"},\"gatewayInContext()\":{\"notice\":\"The address of gateway in current execution context.\"},\"getERC20Gateway(address)\":{\"notice\":\"Return the corresponding gateway address for given token address.\"},\"getL2ERC20Address(address)\":{\"notice\":\"Return the corresponding l2 token address given l1 token address.\"},\"initialize(address,address)\":{\"notice\":\"Initialize the storage of L1GatewayRouter.\"},\"requestERC20(address,address,uint256)\":{\"notice\":\"Request ERC20 token transfer from users to gateways.\"},\"setDefaultERC20Gateway(address)\":{\"notice\":\"Update the address of default ERC20 gateway contract.\"},\"setERC20Gateway(address[],address[])\":{\"notice\":\"Update the mapping from token address to gateway address.\"},\"setETHGateway(address)\":{\"notice\":\"Update the address of ETH gateway contract.\"}},\"notice\":\"The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens. All deposited tokens are routed to corresponding gateways.\",\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"L1GatewayRouter\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{"ERC20Gateway(address)":"705b05b8","defaultERC20Gateway()":"ce8c3e06","depositERC20(address,address,uint256,uint256)":"f219fa66","depositERC20(address,uint256,uint256)":"21425ee0","depositERC20AndCall(address,address,uint256,bytes,uint256)":"0aea8c26","depositETH(address,uint256,uint256)":"ce0b63ce","depositETH(uint256,uint256)":"9f8420b3","depositETHAndCall(address,uint256,bytes,uint256)":"aac476f8","ethGateway()":"8c00ce73","finalizeWithdrawERC20(address,address,address,address,uint256,bytes)":"84bd13b0","finalizeWithdrawETH(address,address,uint256,bytes)":"8eaac8a3","gatewayInContext()":"3a9a7b20","getERC20Gateway(address)":"43c66741","getL2ERC20Address(address)":"c676ad29","initialize(address,address)":"485cc955","owner()":"8da5cb5b","renounceOwnership()":"715018a6","requestERC20(address,address,uint256)":"c52a3bbc","setDefaultERC20Gateway(address)":"5dfd5b9a","setERC20Gateway(address[],address[])":"635c8637","setETHGateway(address)":"3d1d31c7","transferOwnership(address)":"f2fde38b"}},"solidity/L1GatewayRouter.sol:OwnableUpgradeable":{"code":"0x","runtime-code":"0x","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"","srcMapRuntime":"","abiDefinition":[{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"}],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. By default, the owner account will be the one that deploys the contract. This can later be changed with {transferOwnership}. This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.","kind":"dev","methods":{"owner()":{"details":"Returns the address of the current owner."},"renounceOwnership()":{"details":"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner."},"transferOwnership(address)":{"details":"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner."}},"stateVariables":{"__gap":{"details":"This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps"}},"version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[{\"anonymous\":false,\"inputs\":[{\"indexed\":false,\"internalType\":\"uint8\",\"name\":\"version\",\"type\":\"uint8\"}],\"name\":\"Initialized\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"previousOwner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"OwnershipTransferred\",\"type\":\"event\"},{\"inputs\":[],\"name\":\"owner\",\"outputs\":[{\"internalType\":\"address\",\"name\":\"\",\"type\":\"address\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"renounceOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"newOwner\",\"type\":\"address\"}],\"name\":\"transferOwnership\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}],\"devdoc\":{\"details\":\"Contract module which provides a basic access control mechanism, where there is an account (an owner) that can be granted exclusive access to specific functions. By default, the owner account will be the one that deploys the contract. This can later be changed with {transferOwnership}. This module is used through inheritance. It will make available the modifier `onlyOwner`, which can be applied to your functions to restrict their use to the owner.\",\"kind\":\"dev\",\"methods\":{\"owner()\":{\"details\":\"Returns the address of the current owner.\"},\"renounceOwnership()\":{\"details\":\"Leaves the contract without owner. It will not be possible to call `onlyOwner` functions. Can only be called by the current owner. NOTE: Renouncing ownership will leave the contract without an owner, thereby disabling any functionality that is only available to the owner.\"},\"transferOwnership(address)\":{\"details\":\"Transfers ownership of the contract to a new account (`newOwner`). Can only be called by the current owner.\"}},\"stateVariables\":{\"__gap\":{\"details\":\"This empty reserved space is put in place to allow future versions to add new variables without shifting down storage in the inheritance chain. See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\"}},\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"OwnableUpgradeable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{"owner()":"8da5cb5b","renounceOwnership()":"715018a6","transferOwnership(address)":"f2fde38b"}},"solidity/L1GatewayRouter.sol:SafeERC20Upgradeable":{"code":"0x60566037600b82828239805160001a607314602a57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204327007a55064cdf512bb263b46eeb802871b1294e5c54164b635525f2f957f164736f6c63430008110033","runtime-code":"0x73000000000000000000000000000000000000000030146080604052600080fdfea26469706673582212204327007a55064cdf512bb263b46eeb802871b1294e5c54164b635525f2f957f164736f6c63430008110033","info":{"source":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/IERC20.sol)\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\n /**\n * @dev Emitted when `value` tokens are moved from one account (`from`) to\n * another (`to`).\n *\n * Note that `value` may be zero.\n */\n event Transfer(address indexed from, address indexed to, uint256 value);\n\n /**\n * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n * a call to {approve}. `value` is the new allowance.\n */\n event Approval(address indexed owner, address indexed spender, uint256 value);\n\n /**\n * @dev Returns the amount of tokens in existence.\n */\n function totalSupply() external view returns (uint256);\n\n /**\n * @dev Returns the amount of tokens owned by `account`.\n */\n function balanceOf(address account) external view returns (uint256);\n\n /**\n * @dev Moves `amount` tokens from the caller's account to `to`.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transfer(address to, uint256 amount) external returns (bool);\n\n /**\n * @dev Returns the remaining number of tokens that `spender` will be\n * allowed to spend on behalf of `owner` through {transferFrom}. This is\n * zero by default.\n *\n * This value changes when {approve} or {transferFrom} are called.\n */\n function allowance(address owner, address spender) external view returns (uint256);\n\n /**\n * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * IMPORTANT: Beware that changing an allowance with this method brings the risk\n * that someone may use both the old and the new allowance by unfortunate\n * transaction ordering. One possible solution to mitigate this race\n * condition is to first reduce the spender's allowance to 0 and set the\n * desired value afterwards:\n * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n *\n * Emits an {Approval} event.\n */\n function approve(address spender, uint256 amount) external returns (bool);\n\n /**\n * @dev Moves `amount` tokens from `from` to `to` using the\n * allowance mechanism. `amount` is then deducted from the caller's\n * allowance.\n *\n * Returns a boolean value indicating whether the operation succeeded.\n *\n * Emits a {Transfer} event.\n */\n function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20PermitUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20PermitUpgradeable {\n /**\n * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n * given ``owner``'s signed approval.\n *\n * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n * ordering also apply here.\n *\n * Emits an {Approval} event.\n *\n * Requirements:\n *\n * - `spender` cannot be the zero address.\n * - `deadline` must be a timestamp in the future.\n * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n * over the EIP712-formatted function arguments.\n * - the signature must use ``owner``'s current nonce (see {nonces}).\n *\n * For more information on the signature format, see the\n * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n * section].\n */\n function permit(\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) external;\n\n /**\n * @dev Returns the current nonce for `owner`. This value must be\n * included whenever a signature is generated for {permit}.\n *\n * Every successful call to {permit} increases ``owner``'s nonce by one. This\n * prevents a signature from being used multiple times.\n */\n function nonces(address owner) external view returns (uint256);\n\n /**\n * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n */\n // solhint-disable-next-line func-name-mixedcase\n function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Address.sol)\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n /**\n * @dev Returns true if `account` is a contract.\n *\n * [IMPORTANT]\n * ====\n * It is unsafe to assume that an address for which this function returns\n * false is an externally-owned account (EOA) and not a contract.\n *\n * Among others, `isContract` will return false for the following\n * types of addresses:\n *\n * - an externally-owned account\n * - a contract in construction\n * - an address where a contract will be created\n * - an address where a contract lived, but was destroyed\n *\n * Furthermore, `isContract` will also return true if the target contract within\n * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n * which only has an effect at the end of a transaction.\n * ====\n *\n * [IMPORTANT]\n * ====\n * You shouldn't rely on `isContract` to protect against flash loan attacks!\n *\n * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n * constructor.\n * ====\n */\n function isContract(address account) internal view returns (bool) {\n // This method relies on extcodesize/address.code.length, which returns 0\n // for contracts in construction, since the code is only stored at the end\n // of the constructor execution.\n\n return account.code.length \u003e 0;\n }\n\n /**\n * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n * `recipient`, forwarding all available gas and reverting on errors.\n *\n * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n * of certain opcodes, possibly making contracts go over the 2300 gas limit\n * imposed by `transfer`, making them unable to receive funds via\n * `transfer`. {sendValue} removes this limitation.\n *\n * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n *\n * IMPORTANT: because control is transferred to `recipient`, care must be\n * taken to not create reentrancy vulnerabilities. Consider using\n * {ReentrancyGuard} or the\n * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n */\n function sendValue(address payable recipient, uint256 amount) internal {\n require(address(this).balance \u003e= amount, \"Address: insufficient balance\");\n\n (bool success, ) = recipient.call{value: amount}(\"\");\n require(success, \"Address: unable to send value, recipient may have reverted\");\n }\n\n /**\n * @dev Performs a Solidity function call using a low level `call`. A\n * plain `call` is an unsafe replacement for a function call: use this\n * function instead.\n *\n * If `target` reverts with a revert reason, it is bubbled up by this\n * function (like regular Solidity function calls).\n *\n * Returns the raw returned data. To convert to the expected return value,\n * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n *\n * Requirements:\n *\n * - `target` must be a contract.\n * - calling `target` with `data` must not revert.\n *\n * _Available since v3.1._\n */\n function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n * `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n return functionCallWithValue(target, data, 0, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but also transferring `value` wei to `target`.\n *\n * Requirements:\n *\n * - the calling contract must have an ETH balance of at least `value`.\n * - the called Solidity function must be `payable`.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n * with `errorMessage` as a fallback revert reason when `target` reverts.\n *\n * _Available since v3.1._\n */\n function functionCallWithValue(\n address target,\n bytes memory data,\n uint256 value,\n string memory errorMessage\n ) internal returns (bytes memory) {\n require(address(this).balance \u003e= value, \"Address: insufficient balance for call\");\n (bool success, bytes memory returndata) = target.call{value: value}(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n return functionStaticCall(target, data, \"Address: low-level static call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a static call.\n *\n * _Available since v3.3._\n */\n function functionStaticCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n (bool success, bytes memory returndata) = target.staticcall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n }\n\n /**\n * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n * but performing a delegate call.\n *\n * _Available since v3.4._\n */\n function functionDelegateCall(\n address target,\n bytes memory data,\n string memory errorMessage\n ) internal returns (bytes memory) {\n (bool success, bytes memory returndata) = target.delegatecall(data);\n return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n }\n\n /**\n * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n *\n * _Available since v4.8._\n */\n function verifyCallResultFromTarget(\n address target,\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal view returns (bytes memory) {\n if (success) {\n if (returndata.length == 0) {\n // only check isContract if the call was successful and the return data is empty\n // otherwise we already know that it was a contract\n require(isContract(target), \"Address: call to non-contract\");\n }\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n /**\n * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n * revert reason or using the provided one.\n *\n * _Available since v4.3._\n */\n function verifyCallResult(\n bool success,\n bytes memory returndata,\n string memory errorMessage\n ) internal pure returns (bytes memory) {\n if (success) {\n return returndata;\n } else {\n _revert(returndata, errorMessage);\n }\n }\n\n function _revert(bytes memory returndata, string memory errorMessage) private pure {\n // Look for revert reason and bubble it up if present\n if (returndata.length \u003e 0) {\n // The easiest way to bubble the revert reason is using memory via assembly\n /// @solidity memory-safe-assembly\n assembly {\n let returndata_size := mload(returndata)\n revert(add(32, returndata), returndata_size)\n }\n } else {\n revert(errorMessage);\n }\n }\n}\n\n// src/L1/gateways/IL1ERC20Gateway.sol\n\ninterface IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ERC20 token is withdrawn from L2 to L1 and transfer to recipient.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of token withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when someone deposit ERC20 token from L1 to L2.\n /// @param l1Token The address of the token in L1.\n /// @param l2Token The address of the token in L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of token will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositERC20(\n address indexed l1Token,\n address indexed l2Token,\n address indexed from,\n address to,\n uint256 amount,\n bytes data\n );\n\n /// @notice Emitted when some ERC20 token is refunded.\n /// @param token The address of the token in L1.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of token refunded to receiver.\n event RefundERC20(address indexed token, address indexed recipient, uint256 amount);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding l2 token address given l1 token address.\n /// @param _l1Token The address of l1 token.\n function getL2ERC20Address(address _l1Token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit some token to a caller's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Deposit some token to a recipient's account on L2 and call.\n /// @dev Make this function payable to send relayer fee in Ether.\n /// @param _token The address of token in L1.\n /// @param _to The address of recipient's account on L2.\n /// @param _amount The amount of token to transfer.\n /// @param _data Optional data to forward to recipient's account.\n /// @param _gasLimit Gas limit required to complete the deposit on L2.\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) external payable;\n\n /// @notice Complete ERC20 withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev Make this function payable to handle WETH deposit/withdraw.\n /// The function should only be called by L1ScrollMessenger.\n /// The function should also only be called by L2ERC20Gateway in L2.\n /// @param _l1Token The address of corresponding L1 token.\n /// @param _l2Token The address of corresponding L2 token.\n /// @param _from The address of account who withdraw the token in L2.\n /// @param _to The address of recipient in L1 to receive the token.\n /// @param _amount The amount of the token to withdraw.\n /// @param _data Optional data to forward to recipient's account.\n function finalizeWithdrawERC20(\n address _l1Token,\n address _l2Token,\n address _from,\n address _to,\n uint256 _amount,\n bytes calldata _data\n ) external payable;\n}\n\n// src/L1/gateways/IL1ETHGateway.sol\n\ninterface IL1ETHGateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when ETH is withdrawn from L2 to L1 and transfer to recipient.\n /// @param from The address of sender in L2.\n /// @param to The address of recipient in L1.\n /// @param amount The amount of ETH withdrawn from L2 to L1.\n /// @param data The optional calldata passed to recipient in L1.\n event FinalizeWithdrawETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when someone deposit ETH from L1 to L2.\n /// @param from The address of sender in L1.\n /// @param to The address of recipient in L2.\n /// @param amount The amount of ETH will be deposited from L1 to L2.\n /// @param data The optional calldata passed to recipient in L2.\n event DepositETH(address indexed from, address indexed to, uint256 amount, bytes data);\n\n /// @notice Emitted when some ETH is refunded.\n /// @param recipient The address of receiver in L1.\n /// @param amount The amount of ETH refunded to receiver.\n event RefundETH(address indexed recipient, uint256 amount);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Deposit ETH to caller's account in L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(uint256 amount, uint256 gasLimit) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETH(\n address to,\n uint256 amount,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Deposit ETH to some recipient's account in L2 and call the target contract.\n /// @param to The address of recipient's account on L2.\n /// @param amount The amount of ETH to be deposited.\n /// @param data Optional data to forward to recipient's account.\n /// @param gasLimit Gas limit required to complete the deposit on L2.\n function depositETHAndCall(\n address to,\n uint256 amount,\n bytes calldata data,\n uint256 gasLimit\n ) external payable;\n\n /// @notice Complete ETH withdraw from L2 to L1 and send fund to recipient's account in L1.\n /// @dev This function should only be called by L1ScrollMessenger.\n /// This function should also only be called by L1ETHGateway in L2.\n /// @param from The address of account who withdraw ETH in L2.\n /// @param to The address of recipient in L1 to receive ETH.\n /// @param amount The amount of ETH to withdraw.\n /// @param data Optional data to forward to recipient's account.\n function finalizeWithdrawETH(\n address from,\n address to,\n uint256 amount,\n bytes calldata data\n ) external payable;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/utils/Initializable.sol)\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```solidity\n * contract MyToken is ERC20Upgradeable {\n * function initialize() initializer public {\n * __ERC20_init(\"MyToken\", \"MTK\");\n * }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n * function initializeV2() reinitializer(2) public {\n * __ERC20Permit_init(\"MyToken\");\n * }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n * _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n /**\n * @dev Indicates that the contract has been initialized.\n * @custom:oz-retyped-from bool\n */\n uint8 private _initialized;\n\n /**\n * @dev Indicates that the contract is in the process of being initialized.\n */\n bool private _initializing;\n\n /**\n * @dev Triggered when the contract has been initialized or reinitialized.\n */\n event Initialized(uint8 version);\n\n /**\n * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n * `onlyInitializing` functions can be used to initialize parent contracts.\n *\n * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n * constructor.\n *\n * Emits an {Initialized} event.\n */\n modifier initializer() {\n bool isTopLevelCall = !_initializing;\n require(\n (isTopLevelCall \u0026\u0026 _initialized \u003c 1) || (!AddressUpgradeable.isContract(address(this)) \u0026\u0026 _initialized == 1),\n \"Initializable: contract is already initialized\"\n );\n _initialized = 1;\n if (isTopLevelCall) {\n _initializing = true;\n }\n _;\n if (isTopLevelCall) {\n _initializing = false;\n emit Initialized(1);\n }\n }\n\n /**\n * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n * used to initialize parent contracts.\n *\n * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n * are added through upgrades and that require initialization.\n *\n * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n * cannot be nested. If one is invoked in the context of another, execution will revert.\n *\n * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n * a contract, executing them in the right order is up to the developer or operator.\n *\n * WARNING: setting the version to 255 will prevent any future reinitialization.\n *\n * Emits an {Initialized} event.\n */\n modifier reinitializer(uint8 version) {\n require(!_initializing \u0026\u0026 _initialized \u003c version, \"Initializable: contract is already initialized\");\n _initialized = version;\n _initializing = true;\n _;\n _initializing = false;\n emit Initialized(version);\n }\n\n /**\n * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n * {initializer} and {reinitializer} modifiers, directly or indirectly.\n */\n modifier onlyInitializing() {\n require(_initializing, \"Initializable: contract is not initializing\");\n _;\n }\n\n /**\n * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n * through proxies.\n *\n * Emits an {Initialized} event the first time it is successfully executed.\n */\n function _disableInitializers() internal virtual {\n require(!_initializing, \"Initializable: contract is initializing\");\n if (_initialized != type(uint8).max) {\n _initialized = type(uint8).max;\n emit Initialized(type(uint8).max);\n }\n }\n\n /**\n * @dev Returns the highest version that has been initialized. See {reinitializer}.\n */\n function _getInitializedVersion() internal view returns (uint8) {\n return _initialized;\n }\n\n /**\n * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n */\n function _isInitializing() internal view returns (bool) {\n return _initializing;\n }\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\n\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n function __Context_init() internal onlyInitializing {\n }\n\n function __Context_init_unchained() internal onlyInitializing {\n }\n function _msgSender() internal view virtual returns (address) {\n return msg.sender;\n }\n\n function _msgData() internal view virtual returns (bytes calldata) {\n return msg.data;\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[50] private __gap;\n}\n\n// src/L1/gateways/IL1GatewayRouter.sol\n\ninterface IL1GatewayRouter is IL1ETHGateway, IL1ERC20Gateway {\n /**********\n * Events *\n **********/\n\n /// @notice Emitted when the address of ETH Gateway is updated.\n /// @param oldETHGateway The address of the old ETH Gateway.\n /// @param newEthGateway The address of the new ETH Gateway.\n event SetETHGateway(address indexed oldETHGateway, address indexed newEthGateway);\n\n /// @notice Emitted when the address of default ERC20 Gateway is updated.\n /// @param oldDefaultERC20Gateway The address of the old default ERC20 Gateway.\n /// @param newDefaultERC20Gateway The address of the new default ERC20 Gateway.\n event SetDefaultERC20Gateway(address indexed oldDefaultERC20Gateway, address indexed newDefaultERC20Gateway);\n\n /// @notice Emitted when the `gateway` for `token` is updated.\n /// @param token The address of token updated.\n /// @param oldGateway The corresponding address of the old gateway.\n /// @param newGateway The corresponding address of the new gateway.\n event SetERC20Gateway(address indexed token, address indexed oldGateway, address indexed newGateway);\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @notice Return the corresponding gateway address for given token address.\n /// @param _token The address of token to query.\n function getERC20Gateway(address _token) external view returns (address);\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @notice Request ERC20 token transfer from users to gateways.\n /// @param sender The address of sender to request fund.\n /// @param token The address of token to request.\n /// @param amount The amount of token to request.\n function requestERC20(\n address sender,\n address token,\n uint256 amount\n ) external returns (uint256);\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @notice Update the address of ETH gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _ethGateway The address to update.\n function setETHGateway(address _ethGateway) external;\n\n /// @notice Update the address of default ERC20 gateway contract.\n /// @dev This function should only be called by contract owner.\n /// @param _defaultERC20Gateway The address to update.\n function setDefaultERC20Gateway(address _defaultERC20Gateway) external;\n\n /// @notice Update the mapping from token address to gateway address.\n /// @dev This function should only be called by contract owner.\n /// @param _tokens The list of addresses of tokens to update.\n /// @param _gateways The list of addresses of gateways to update.\n function setERC20Gateway(address[] calldata _tokens, address[] calldata _gateways) external;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n address private _owner;\n\n event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n /**\n * @dev Initializes the contract setting the deployer as the initial owner.\n */\n function __Ownable_init() internal onlyInitializing {\n __Ownable_init_unchained();\n }\n\n function __Ownable_init_unchained() internal onlyInitializing {\n _transferOwnership(_msgSender());\n }\n\n /**\n * @dev Throws if called by any account other than the owner.\n */\n modifier onlyOwner() {\n _checkOwner();\n _;\n }\n\n /**\n * @dev Returns the address of the current owner.\n */\n function owner() public view virtual returns (address) {\n return _owner;\n }\n\n /**\n * @dev Throws if the sender is not the owner.\n */\n function _checkOwner() internal view virtual {\n require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n }\n\n /**\n * @dev Leaves the contract without owner. It will not be possible to call\n * `onlyOwner` functions. Can only be called by the current owner.\n *\n * NOTE: Renouncing ownership will leave the contract without an owner,\n * thereby disabling any functionality that is only available to the owner.\n */\n function renounceOwnership() public virtual onlyOwner {\n _transferOwnership(address(0));\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Can only be called by the current owner.\n */\n function transferOwnership(address newOwner) public virtual onlyOwner {\n require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n _transferOwnership(newOwner);\n }\n\n /**\n * @dev Transfers ownership of the contract to a new account (`newOwner`).\n * Internal function without access restriction.\n */\n function _transferOwnership(address newOwner) internal virtual {\n address oldOwner = _owner;\n _owner = newOwner;\n emit OwnershipTransferred(oldOwner, newOwner);\n }\n\n /**\n * @dev This empty reserved space is put in place to allow future versions to add new\n * variables without shifting down storage in the inheritance chain.\n * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n */\n uint256[49] private __gap;\n}\n\n// node_modules/@openzeppelin/contracts-upgradeable/token/ERC20/utils/SafeERC20Upgradeable.sol\n\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20Upgradeable {\n using AddressUpgradeable for address;\n\n /**\n * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeTransfer(IERC20Upgradeable token, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n }\n\n /**\n * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n */\n function safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) internal {\n _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n }\n\n /**\n * @dev Deprecated. This function has issues similar to the ones found in\n * {IERC20-approve}, and its usage is discouraged.\n *\n * Whenever possible, use {safeIncreaseAllowance} and\n * {safeDecreaseAllowance} instead.\n */\n function safeApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n // safeApprove should only be called when setting an initial allowance,\n // or when resetting it to zero. To increase and decrease it, use\n // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n require(\n (value == 0) || (token.allowance(address(this), spender) == 0),\n \"SafeERC20: approve from non-zero to non-zero allowance\"\n );\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n }\n\n /**\n * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeIncreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n uint256 oldAllowance = token.allowance(address(this), spender);\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n }\n\n /**\n * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful.\n */\n function safeDecreaseAllowance(IERC20Upgradeable token, address spender, uint256 value) internal {\n unchecked {\n uint256 oldAllowance = token.allowance(address(this), spender);\n require(oldAllowance \u003e= value, \"SafeERC20: decreased allowance below zero\");\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n }\n }\n\n /**\n * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n * to be set to zero before setting it to a non-zero value, such as USDT.\n */\n function forceApprove(IERC20Upgradeable token, address spender, uint256 value) internal {\n bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n if (!_callOptionalReturnBool(token, approvalCall)) {\n _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n _callOptionalReturn(token, approvalCall);\n }\n }\n\n /**\n * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n * Revert on invalid signature.\n */\n function safePermit(\n IERC20PermitUpgradeable token,\n address owner,\n address spender,\n uint256 value,\n uint256 deadline,\n uint8 v,\n bytes32 r,\n bytes32 s\n ) internal {\n uint256 nonceBefore = token.nonces(owner);\n token.permit(owner, spender, value, deadline, v, r, s);\n uint256 nonceAfter = token.nonces(owner);\n require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n */\n function _callOptionalReturn(IERC20Upgradeable token, bytes memory data) private {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We use {Address-functionCall} to perform this call, which verifies that\n // the target address contains contract code and also asserts for success in the low-level call.\n\n bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n }\n\n /**\n * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n * on the return value: the return value is optional (but if data is returned, it must not be false).\n * @param token The token targeted by the call.\n * @param data The call data (encoded using abi.encode or one of its variants).\n *\n * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n */\n function _callOptionalReturnBool(IERC20Upgradeable token, bytes memory data) private returns (bool) {\n // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n // and not revert is the subcall reverts.\n\n (bool success, bytes memory returndata) = address(token).call(data);\n return\n success \u0026\u0026 (returndata.length == 0 || abi.decode(returndata, (bool))) \u0026\u0026 AddressUpgradeable.isContract(address(token));\n }\n}\n\n// src/L1/gateways/L1GatewayRouter.sol\n\n/// @title L1GatewayRouter\n/// @notice The `L1GatewayRouter` is the main entry for depositing Ether and ERC20 tokens.\n/// All deposited tokens are routed to corresponding gateways.\n/// @dev One can also use this contract to query L1/L2 token address mapping.\n/// In the future, ERC-721 and ERC-1155 tokens will be added to the router too.\ncontract L1GatewayRouter is OwnableUpgradeable, IL1GatewayRouter {\n using SafeERC20Upgradeable for IERC20Upgradeable;\n\n /*************\n * Variables *\n *************/\n\n /// @notice The address of L1ETHGateway.\n address public ethGateway;\n\n /// @notice The addess of default ERC20 gateway, normally the L1StandardERC20Gateway contract.\n address public defaultERC20Gateway;\n\n /// @notice Mapping from ERC20 token address to corresponding L1ERC20Gateway.\n // solhint-disable-next-line var-name-mixedcase\n mapping(address =\u003e address) public ERC20Gateway;\n\n /// @notice The address of gateway in current execution context.\n address public gatewayInContext;\n\n /**********************\n * Function Modifiers *\n **********************/\n\n modifier onlyNotInContext() {\n require(gatewayInContext == address(0), \"Only not in context\");\n _;\n }\n\n modifier onlyInContext() {\n require(_msgSender() == gatewayInContext, \"Only in deposit context\");\n _;\n }\n\n /***************\n * Constructor *\n ***************/\n\n constructor() {\n _disableInitializers();\n }\n\n /// @notice Initialize the storage of L1GatewayRouter.\n /// @param _ethGateway The address of L1ETHGateway contract.\n /// @param _defaultERC20Gateway The address of default ERC20 Gateway contract.\n function initialize(address _ethGateway, address _defaultERC20Gateway) external initializer {\n OwnableUpgradeable.__Ownable_init();\n\n // it can be zero during initialization\n if (_defaultERC20Gateway != address(0)) {\n defaultERC20Gateway = _defaultERC20Gateway;\n emit SetDefaultERC20Gateway(address(0), _defaultERC20Gateway);\n }\n\n // it can be zero during initialization\n if (_ethGateway != address(0)) {\n ethGateway = _ethGateway;\n emit SetETHGateway(address(0), _ethGateway);\n }\n }\n\n /*************************\n * Public View Functions *\n *************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function getL2ERC20Address(address _l1Address) external view override returns (address) {\n address _gateway = getERC20Gateway(_l1Address);\n if (_gateway == address(0)) {\n return address(0);\n }\n\n return IL1ERC20Gateway(_gateway).getL2ERC20Address(_l1Address);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function getERC20Gateway(address _token) public view returns (address) {\n address _gateway = ERC20Gateway[_token];\n if (_gateway == address(0)) {\n _gateway = defaultERC20Gateway;\n }\n return _gateway;\n }\n\n /*****************************\n * Public Mutating Functions *\n *****************************/\n\n /// @inheritdoc IL1GatewayRouter\n /// @dev All the gateways should have reentrancy guard to prevent potential attack though this function.\n function requestERC20(\n address _sender,\n address _token,\n uint256 _amount\n ) external onlyInContext returns (uint256) {\n address _caller = _msgSender();\n uint256 _balance = IERC20Upgradeable(_token).balanceOf(_caller);\n IERC20Upgradeable(_token).safeTransferFrom(_sender, _caller, _amount);\n _amount = IERC20Upgradeable(_token).balanceOf(_caller) - _balance;\n return _amount;\n }\n\n /*************************************************\n * Public Mutating Functions from L1ERC20Gateway *\n *************************************************/\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20(\n address _token,\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositERC20AndCall(_token, _to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function depositERC20AndCall(\n address _token,\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = getERC20Gateway(_token);\n require(_gateway != address(0), \"no gateway available\");\n\n // enter deposit context\n gatewayInContext = _gateway;\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ERC20Gateway(_gateway).depositERC20AndCall{value: msg.value}(_token, _to, _amount, _routerData, _gasLimit);\n\n // leave deposit context\n gatewayInContext = address(0);\n }\n\n /// @inheritdoc IL1ERC20Gateway\n function finalizeWithdrawERC20(\n address,\n address,\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /***********************************************\n * Public Mutating Functions from L1ETHGateway *\n ***********************************************/\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(uint256 _amount, uint256 _gasLimit) external payable override {\n depositETHAndCall(_msgSender(), _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETH(\n address _to,\n uint256 _amount,\n uint256 _gasLimit\n ) external payable override {\n depositETHAndCall(_to, _amount, new bytes(0), _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function depositETHAndCall(\n address _to,\n uint256 _amount,\n bytes memory _data,\n uint256 _gasLimit\n ) public payable override onlyNotInContext {\n address _gateway = ethGateway;\n require(_gateway != address(0), \"eth gateway available\");\n\n // encode msg.sender with _data\n bytes memory _routerData = abi.encode(_msgSender(), _data);\n\n IL1ETHGateway(_gateway).depositETHAndCall{value: msg.value}(_to, _amount, _routerData, _gasLimit);\n }\n\n /// @inheritdoc IL1ETHGateway\n function finalizeWithdrawETH(\n address,\n address,\n uint256,\n bytes calldata\n ) external payable virtual override {\n revert(\"should never be called\");\n }\n\n /************************\n * Restricted Functions *\n ************************/\n\n /// @inheritdoc IL1GatewayRouter\n function setETHGateway(address _newEthGateway) external onlyOwner {\n address _oldETHGateway = ethGateway;\n ethGateway = _newEthGateway;\n\n emit SetETHGateway(_oldETHGateway, _newEthGateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setDefaultERC20Gateway(address _newDefaultERC20Gateway) external onlyOwner {\n address _oldDefaultERC20Gateway = defaultERC20Gateway;\n defaultERC20Gateway = _newDefaultERC20Gateway;\n\n emit SetDefaultERC20Gateway(_oldDefaultERC20Gateway, _newDefaultERC20Gateway);\n }\n\n /// @inheritdoc IL1GatewayRouter\n function setERC20Gateway(address[] memory _tokens, address[] memory _gateways) external onlyOwner {\n require(_tokens.length == _gateways.length, \"length mismatch\");\n\n for (uint256 i = 0; i \u003c _tokens.length; i++) {\n address _oldGateway = ERC20Gateway[_tokens[i]];\n ERC20Gateway[_tokens[i]] = _gateways[i];\n\n emit SetERC20Gateway(_tokens[i], _oldGateway, _gateways[i]);\n }\n }\n}\n","language":"Solidity","languageVersion":"0.8.17","compilerVersion":"0.8.17","compilerOptions":"--combined-json bin,bin-runtime,srcmap,srcmap-runtime,abi,userdoc,devdoc,metadata,hashes --optimize --optimize-runs 10000 --allow-paths ., ./, ../","srcMap":"36896:6366:0:-:0;;;;;;;;;;;;;;;-1:-1:-1;;;36896:6366:0;;;;;;;;;;;;;;;;;","srcMapRuntime":"36896:6366:0:-:0;;;;;;;;","abiDefinition":[],"userDoc":{"kind":"user","methods":{},"version":1},"developerDoc":{"details":"Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, which allows you to call the safe operations as `token.safeTransfer(...)`, etc.","kind":"dev","methods":{},"title":"SafeERC20","version":1},"metadata":"{\"compiler\":{\"version\":\"0.8.17+commit.8df45f5f\"},\"language\":\"Solidity\",\"output\":{\"abi\":[],\"devdoc\":{\"details\":\"Wrappers around ERC20 operations that throw on failure (when the token contract returns false). Tokens that return no value (and instead revert or throw on failure) are also supported, non-reverting calls are assumed to be successful. To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract, which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\",\"kind\":\"dev\",\"methods\":{},\"title\":\"SafeERC20\",\"version\":1},\"userdoc\":{\"kind\":\"user\",\"methods\":{},\"version\":1}},\"settings\":{\"compilationTarget\":{\"solidity/L1GatewayRouter.sol\":\"SafeERC20Upgradeable\"},\"evmVersion\":\"london\",\"libraries\":{},\"metadata\":{\"bytecodeHash\":\"ipfs\"},\"optimizer\":{\"enabled\":true,\"runs\":10000},\"remappings\":[]},\"sources\":{\"solidity/L1GatewayRouter.sol\":{\"keccak256\":\"0x8c5fc2648637501410a878f7335e7d5b89b06fdf2847f4a7a85c878190a4332a\",\"license\":\"MIT\",\"urls\":[\"bzz-raw://1d64a3bfc10a52284498d60fe99caa0ba6188e912f7be3d96943d48adc2ce148\",\"dweb:/ipfs/QmfNyraosVn3DAAooQVb3Wqwx9ftYyMVKJspRnUtbWReb1\"]}},\"version\":1}"},"hashes":{}}}