ETH Price: $3,482.30 (+3.24%)

Transaction Decoder

Block:
22911864 at Jul-13-2025 05:51:23 PM +UTC
Transaction Fee:
0.000720092011484664 ETH $2.51
Gas Used:
530,712 Gas / 1.356841397 Gwei

Emitted Events:

348 FiatTokenProxy.0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef( 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef, 0x00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67, 0x00000000000000000000000099c9fc46f92e8a1c0dec1b1747d010903e884be1, 0000000000000000000000000000000000000000000000000000001632a04d9b )
349 L1ChugSplashProxy.0x718594027abd4eaed59f95162563e0cc6d0e8d5b86b1c7be8b1b0ac3343d0396( 0x718594027abd4eaed59f95162563e0cc6d0e8d5b86b1c7be8b1b0ac3343d0396, 0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0x0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607, 0x00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67, 00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67, 0000000000000000000000000000000000000000000000000000001632a04d9b, 0000000000000000000000000000000000000000000000000000000000000060, 0000000000000000000000000000000000000000000000000000000000000000 )
350 L1ChugSplashProxy.0x7ff126db8024424bbfd9826e8ab82ff59136289ea440b04b39a0df1b03b9cabf( 0x7ff126db8024424bbfd9826e8ab82ff59136289ea440b04b39a0df1b03b9cabf, 0x000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48, 0x0000000000000000000000007f5c764cbc14f9669b88837ca1490cca17c31607, 0x00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67, 00000000000000000000000007ae8551be970cb1cca11dd7a11f47ae82e70e67, 0000000000000000000000000000000000000000000000000000001632a04d9b, 0000000000000000000000000000000000000000000000000000000000000060, 0000000000000000000000000000000000000000000000000000000000000000 )
351 Proxy.0xb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32( 0xb3813568d9991fc951961fcb4c784893574240a28925604d09fc577c55bb7c32, 0x00000000000000000000000036bde71c97b33cc4729cf772ae268934f7ab70b2, 0x0000000000000000000000004200000000000000000000000000000000000007, 0x0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000020, 000000000000000000000000000000000000000000000000000000000000022d, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000000, 000000000007e37600d764ad0b00010000000000000000000000000000000000, 0000000000000000000002cb7700000000000000000000000099c9fc46f92e8a, 1c0dec1b1747d010903e884be100000000000000000000000042000000000000, 0000000000000000000000001000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000000, 00000000000000000000030d4000000000000000000000000000000000000000, 000000000000000000000000c000000000000000000000000000000000000000, 000000000000000000000000e40166a07a0000000000000000000000007f5c76, 4cbc14f9669b88837ca1490cca17c31607000000000000000000000000a0b869, 91c6218b36c1d19d4a2e9eb0ce3606eb4800000000000000000000000007ae85, 51be970cb1cca11dd7a11f47ae82e70e6700000000000000000000000007ae85, 51be970cb1cca11dd7a11f47ae82e70e67000000000000000000000000000000, 0000000000000000000000001632a04d9b000000000000000000000000000000, 00000000000000000000000000000000c0000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000000 )
352 Lib_ResolvedDelegateProxy.0xcb0f7ffd78f9aee47a248fae8db181db6eee833039123e026dcbff529522e52a( 0xcb0f7ffd78f9aee47a248fae8db181db6eee833039123e026dcbff529522e52a, 0x0000000000000000000000004200000000000000000000000000000000000010, 00000000000000000000000099c9fc46f92e8a1c0dec1b1747d010903e884be1, 0000000000000000000000000000000000000000000000000000000000000080, 000100000000000000000000000000000000000000000000000000000002cb77, 0000000000000000000000000000000000000000000000000000000000030d40, 00000000000000000000000000000000000000000000000000000000000000e4, 0166a07a0000000000000000000000007f5c764cbc14f9669b88837ca1490cca, 17c31607000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce, 3606eb4800000000000000000000000007ae8551be970cb1cca11dd7a11f47ae, 82e70e6700000000000000000000000007ae8551be970cb1cca11dd7a11f47ae, 82e70e6700000000000000000000000000000000000000000000000000000016, 32a04d9b00000000000000000000000000000000000000000000000000000000, 000000c000000000000000000000000000000000000000000000000000000000, 0000000000000000000000000000000000000000000000000000000000000000 )
353 Lib_ResolvedDelegateProxy.0x8ebb2ec2465bdb2a06a66fc37a0963af8a2a6a1479d81d56fdb8cbb98096d546( 0x8ebb2ec2465bdb2a06a66fc37a0963af8a2a6a1479d81d56fdb8cbb98096d546, 0x00000000000000000000000099c9fc46f92e8a1c0dec1b1747d010903e884be1, 0000000000000000000000000000000000000000000000000000000000000000 )

Account State Difference:

  Address   Before After State Difference Code
0x07aE8551...e82e70E67
3.498303087195134016 Eth
Nonce: 347963
3.497582995183649352 Eth
Nonce: 347964
0.000720092011484664
0x25ace71c...4F7ab5fA1
(Optimism: Proxy OVM L1 Cross Domain Messenger)
0x99C9fc46...03E884bE1
(Optimism: Gateway)
0xA0b86991...E3606eB48
0xbEb5Fc57...e41f106Ed
(Optimism: Portal)
(BuilderNet)
74.192638291223922973 Eth74.192638291248335725 Eth0.000000000024412752

Execution Trace

L1ChugSplashProxy.58a997f6( )
  • ProxyAdmin.STATICCALL( )
  • L1StandardBridge.depositERC20( _l1Token=0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48, _l2Token=0x7F5c764cBc14f9669B88837ca1490cCa17c31607, _amount=95338646939, _minGasLimit=200000, _extraData=0x )
    • FiatTokenProxy.01ffc9a7( )
      • FiatTokenV2_2.01ffc9a7( )
      • FiatTokenProxy.01ffc9a7( )
        • FiatTokenV2_2.01ffc9a7( )
        • FiatTokenProxy.23b872dd( )
          • FiatTokenV2_2.transferFrom( from=0x07aE8551Be970cB1cCa11Dd7a11F47Ae82e70E67, to=0x99C9fc46f92E8a1c0deC1b1747d010903E884bE1, value=95338646939 ) => ( True )
          • Lib_ResolvedDelegateProxy.3dbb202b( )
            • Lib_AddressManager.getAddress( _name=OVM_L1CrossDomainMessenger ) => ( 0x5D5a095665886119693F0B41d8DFeE78da033e8B )
            • L1CrossDomainMessenger.sendMessage( _target=0x4200000000000000000000000000000000000010, _message=0x0166A07A0000000000000000000000007F5C764CBC14F9669B88837CA1490CCA17C31607000000000000000000000000A0B86991C6218B36C1D19D4A2E9EB0CE3606EB4800000000000000000000000007AE8551BE970CB1CCA11DD7A11F47AE82E70E6700000000000000000000000007AE8551BE970CB1CCA11DD7A11F47AE82E70E670000000000000000000000000000000000000000000000000000001632A04D9B00000000000000000000000000000000000000000000000000000000000000C00000000000000000000000000000000000000000000000000000000000000000, _minGasLimit=200000 )
              • Proxy.e9e05c42( )
                • OptimismPortal2.depositTransaction( _to=0x4200000000000000000000000000000000000007, _value=0, _gasLimit=516982, _isCreation=False, _data=0xD764AD0B000100000000000000000000000000000000000000000000000000000002CB7700000000000000000000000099C9FC46F92E8A1C0DEC1B1747D010903E884BE1000000000000000000000000420000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030D4000000000000000000000000000000000000000000000000000000000000000C000000000000000000000000000000000000000000000000000000000000000E40166A07A0000000000000000000000007F5C764CBC14F9669B88837CA1490CCA17C31607000000000000000000000000A0B86991C6218B36C1D19D4A2E9EB0CE3606EB4800000000000000000000000007AE8551BE970CB1CCA11DD7A11F47AE82E70E6700000000000000000000000007AE8551BE970CB1CCA11DD7A11F47AE82E70E670000000000000000000000000000000000000000000000000000001632A04D9B00000000000000000000000000000000000000000000000000000000000000C0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 )
                  • Proxy.STATICCALL( )
                    File 1 of 11: L1ChugSplashProxy
                    // SPDX-License-Identifier: MIT
                    pragma solidity >0.5.0 <0.8.0;
                    import { iL1ChugSplashDeployer } from "./interfaces/iL1ChugSplashDeployer.sol";
                    /**
                     * @title L1ChugSplashProxy
                     * @dev Basic ChugSplash proxy contract for L1. Very close to being a normal proxy but has added
                     * functions `setCode` and `setStorage` for changing the code or storage of the contract. Nifty!
                     *
                     * Note for future developers: do NOT make anything in this contract 'public' unless you know what
                     * you're doing. Anything public can potentially have a function signature that conflicts with a
                     * signature attached to the implementation contract. Public functions SHOULD always have the
                     * 'proxyCallIfNotOwner' modifier unless there's some *really* good reason not to have that
                     * modifier. And there almost certainly is not a good reason to not have that modifier. Beware!
                     */
                    contract L1ChugSplashProxy {
                        /*************
                         * Constants *
                         *************/
                        // "Magic" prefix. When prepended to some arbitrary bytecode and used to create a contract, the
                        // appended bytecode will be deployed as given.
                        bytes13 constant internal DEPLOY_CODE_PREFIX = 0x600D380380600D6000396000f3;
                        // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
                        bytes32 constant internal IMPLEMENTATION_KEY = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                        // bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
                        bytes32 constant internal OWNER_KEY = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                        /***************
                         * Constructor *
                         ***************/
                        
                        /**
                         * @param _owner Address of the initial contract owner.
                         */
                        constructor(
                            address _owner
                        ) {
                            _setOwner(_owner);
                        }
                        /**********************
                         * Function Modifiers *
                         **********************/
                        /**
                         * Blocks a function from being called when the parent signals that the system should be paused
                         * via an isUpgrading function.
                         */
                        modifier onlyWhenNotPaused() {
                            address owner = _getOwner();
                            // We do a low-level call because there's no guarantee that the owner actually *is* an
                            // L1ChugSplashDeployer contract and Solidity will throw errors if we do a normal call and
                            // it turns out that it isn't the right type of contract.
                            (bool success, bytes memory returndata) = owner.staticcall(
                                abi.encodeWithSelector(
                                    iL1ChugSplashDeployer.isUpgrading.selector
                                )
                            );
                            // If the call was unsuccessful then we assume that there's no "isUpgrading" method and we
                            // can just continue as normal. We also expect that the return value is exactly 32 bytes
                            // long. If this isn't the case then we can safely ignore the result.
                            if (success && returndata.length == 32) {
                                // Although the expected value is a *boolean*, it's safer to decode as a uint256 in the
                                // case that the isUpgrading function returned something other than 0 or 1. But we only
                                // really care about the case where this value is 0 (= false).
                                uint256 ret = abi.decode(returndata, (uint256));
                                require(
                                    ret == 0,
                                    "L1ChugSplashProxy: system is currently being upgraded"
                                );
                            }
                            _;
                        }
                        /**
                         * Makes a proxy call instead of triggering the given function when the caller is either the
                         * owner or the zero address. Caller can only ever be the zero address if this function is
                         * being called off-chain via eth_call, which is totally fine and can be convenient for
                         * client-side tooling. Avoids situations where the proxy and implementation share a sighash
                         * and the proxy function ends up being called instead of the implementation one.
                         *
                         * Note: msg.sender == address(0) can ONLY be triggered off-chain via eth_call. If there's a
                         * way for someone to send a transaction with msg.sender == address(0) in any real context then
                         * we have much bigger problems. Primary reason to include this additional allowed sender is
                         * because the owner address can be changed dynamically and we do not want clients to have to
                         * keep track of the current owner in order to make an eth_call that doesn't trigger the
                         * proxied contract.
                         */
                        modifier proxyCallIfNotOwner() {
                            if (msg.sender == _getOwner() || msg.sender == address(0)) {
                                _;
                            } else {
                                // This WILL halt the call frame on completion.
                                _doProxyCall();
                            }
                        }
                        /*********************
                         * Fallback Function *
                         *********************/
                        fallback()
                            external
                            payable
                        {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        /********************
                         * Public Functions *
                         ********************/
                        /**
                         * Sets the code that should be running behind this proxy. Note that this scheme is a bit
                         * different from the standard proxy scheme where one would typically deploy the code
                         * separately and then set the implementation address. We're doing it this way because it gives
                         * us a lot more freedom on the client side. Can only be triggered by the contract owner.
                         * @param _code New contract code to run inside this contract.
                         */
                        function setCode(
                            bytes memory _code
                        )
                            proxyCallIfNotOwner
                            public
                        {
                            // Get the code hash of the current implementation.
                            address implementation = _getImplementation();
                            // If the code hash matches the new implementation then we return early.
                            if (keccak256(_code) == _getAccountCodeHash(implementation)) {
                                return;
                            }
                            // Create the deploycode by appending the magic prefix.
                            bytes memory deploycode = abi.encodePacked(
                                DEPLOY_CODE_PREFIX,
                                _code
                            );
                            // Deploy the code and set the new implementation address.
                            address newImplementation;
                            assembly {
                                newImplementation := create(0x0, add(deploycode, 0x20), mload(deploycode))
                            }
                            // Check that the code was actually deployed correctly. I'm not sure if you can ever
                            // actually fail this check. Should only happen if the contract creation from above runs
                            // out of gas but this parent execution thread does NOT run out of gas. Seems like we
                            // should be doing this check anyway though.
                            require(
                                _getAccountCodeHash(newImplementation) == keccak256(_code),
                                "L1ChugSplashProxy: code was not correctly deployed."
                            );
                            _setImplementation(newImplementation);
                        }
                        /**
                         * Modifies some storage slot within the proxy contract. Gives us a lot of power to perform
                         * upgrades in a more transparent way. Only callable by the owner.
                         * @param _key Storage key to modify.
                         * @param _value New value for the storage key.
                         */
                        function setStorage(
                            bytes32 _key,
                            bytes32 _value
                        )
                            proxyCallIfNotOwner
                            public
                        {
                            assembly {
                                sstore(_key, _value)
                            }
                        }
                        /**
                         * Changes the owner of the proxy contract. Only callable by the owner.
                         * @param _owner New owner of the proxy contract.
                         */
                        function setOwner(
                            address _owner
                        )
                            proxyCallIfNotOwner
                            public
                        {
                            _setOwner(_owner);
                        }
                        /**
                         * Queries the owner of the proxy contract. Can only be called by the owner OR by making an
                         * eth_call and setting the "from" address to address(0).
                         * @return Owner address.
                         */
                        function getOwner()
                            proxyCallIfNotOwner
                            public
                            returns (
                                address
                            )
                        {
                            return _getOwner();
                        }
                        /**
                         * Queries the implementation address. Can only be called by the owner OR by making an
                         * eth_call and setting the "from" address to address(0).
                         * @return Implementation address.
                         */
                        function getImplementation()
                            proxyCallIfNotOwner
                            public
                            returns (
                                address
                            )
                        {
                            return _getImplementation();
                        }
                        /**********************
                         * Internal Functions *
                         **********************/
                        /**
                         * Sets the implementation address.
                         * @param _implementation New implementation address.
                         */
                        function _setImplementation(
                            address _implementation
                        )
                            internal
                        {
                            assembly {
                                sstore(IMPLEMENTATION_KEY, _implementation)
                            }
                        }
                        /**
                         * Queries the implementation address.
                         * @return Implementation address.
                         */
                        function _getImplementation()
                            internal
                            view
                            returns (
                                address
                            )
                        {
                            address implementation;
                            assembly {
                                implementation := sload(IMPLEMENTATION_KEY)
                            }
                            return implementation;
                        }
                        /**
                         * Changes the owner of the proxy contract.
                         * @param _owner New owner of the proxy contract.
                         */
                        function _setOwner(
                            address _owner
                        )
                            internal
                        {
                            assembly {
                                sstore(OWNER_KEY, _owner)
                            }
                        }
                        /**
                         * Queries the owner of the proxy contract.
                         * @return Owner address.
                         */
                        function _getOwner()
                            internal
                            view 
                            returns (
                                address
                            )
                        {
                            address owner;
                            assembly {
                                owner := sload(OWNER_KEY)
                            }
                            return owner;
                        }
                        /**
                         * Gets the code hash for a given account.
                         * @param _account Address of the account to get a code hash for.
                         * @return Code hash for the account.
                         */
                        function _getAccountCodeHash(
                            address _account
                        )
                            internal
                            view
                            returns (
                                bytes32
                            )
                        {
                            bytes32 codeHash;
                            assembly {
                                codeHash := extcodehash(_account)
                            }
                            return codeHash;
                        }
                        /**
                         * Performs the proxy call via a delegatecall.
                         */
                        function _doProxyCall()
                            onlyWhenNotPaused
                            internal
                        {
                            address implementation = _getImplementation();
                            require(
                                implementation != address(0),
                                "L1ChugSplashProxy: implementation is not set yet"
                            );
                            assembly {
                                // Copy calldata into memory at 0x0....calldatasize.
                                calldatacopy(0x0, 0x0, calldatasize())
                                // Perform the delegatecall, make sure to pass all available gas.
                                let success := delegatecall(gas(), implementation, 0x0, calldatasize(), 0x0, 0x0)
                                // Copy returndata into memory at 0x0....returndatasize. Note that this *will*
                                // overwrite the calldata that we just copied into memory but that doesn't really
                                // matter because we'll be returning in a second anyway.
                                returndatacopy(0x0, 0x0, returndatasize())
                                
                                // Success == 0 means a revert. We'll revert too and pass the data up.
                                if iszero(success) {
                                    revert(0x0, returndatasize())
                                }
                                // Otherwise we'll just return and pass the data up.
                                return(0x0, returndatasize())
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >0.5.0 <0.8.0;
                    /**
                     * @title iL1ChugSplashDeployer
                     */
                    interface iL1ChugSplashDeployer {
                        function isUpgrading()
                            external
                            view
                            returns (
                                bool
                            );
                    }
                    

                    File 2 of 11: FiatTokenProxy
                    pragma solidity ^0.4.24;
                    
                    // File: zos-lib/contracts/upgradeability/Proxy.sol
                    
                    /**
                     * @title Proxy
                     * @dev Implements delegation of calls to other contracts, with proper
                     * forwarding of return values and bubbling of failures.
                     * It defines a fallback function that delegates all calls to the address
                     * returned by the abstract _implementation() internal function.
                     */
                    contract Proxy {
                      /**
                       * @dev Fallback function.
                       * Implemented entirely in `_fallback`.
                       */
                      function () payable external {
                        _fallback();
                      }
                    
                      /**
                       * @return The Address of the implementation.
                       */
                      function _implementation() internal view returns (address);
                    
                      /**
                       * @dev Delegates execution to an implementation contract.
                       * This is a low level function that doesn't return to its internal call site.
                       * It will return to the external caller whatever the implementation returns.
                       * @param implementation Address to delegate.
                       */
                      function _delegate(address implementation) internal {
                        assembly {
                          // Copy msg.data. We take full control of memory in this inline assembly
                          // block because it will not return to Solidity code. We overwrite the
                          // Solidity scratch pad at memory position 0.
                          calldatacopy(0, 0, calldatasize)
                    
                          // Call the implementation.
                          // out and outsize are 0 because we don't know the size yet.
                          let result := delegatecall(gas, implementation, 0, calldatasize, 0, 0)
                    
                          // Copy the returned data.
                          returndatacopy(0, 0, returndatasize)
                    
                          switch result
                          // delegatecall returns 0 on error.
                          case 0 { revert(0, returndatasize) }
                          default { return(0, returndatasize) }
                        }
                      }
                    
                      /**
                       * @dev Function that is run as the first thing in the fallback function.
                       * Can be redefined in derived contracts to add functionality.
                       * Redefinitions must call super._willFallback().
                       */
                      function _willFallback() internal {
                      }
                    
                      /**
                       * @dev fallback implementation.
                       * Extracted to enable manual triggering.
                       */
                      function _fallback() internal {
                        _willFallback();
                        _delegate(_implementation());
                      }
                    }
                    
                    // File: openzeppelin-solidity/contracts/AddressUtils.sol
                    
                    /**
                     * Utility library of inline functions on addresses
                     */
                    library AddressUtils {
                    
                      /**
                       * Returns whether the target address is a contract
                       * @dev This function will return false if invoked during the constructor of a contract,
                       * as the code is not actually created until after the constructor finishes.
                       * @param addr address to check
                       * @return whether the target address is a contract
                       */
                      function isContract(address addr) internal view returns (bool) {
                        uint256 size;
                        // XXX Currently there is no better way to check if there is a contract in an address
                        // than to check the size of the code at that address.
                        // See https://ethereum.stackexchange.com/a/14016/36603
                        // for more details about how this works.
                        // TODO Check this again before the Serenity release, because all addresses will be
                        // contracts then.
                        // solium-disable-next-line security/no-inline-assembly
                        assembly { size := extcodesize(addr) }
                        return size > 0;
                      }
                    
                    }
                    
                    // File: zos-lib/contracts/upgradeability/UpgradeabilityProxy.sol
                    
                    /**
                     * @title UpgradeabilityProxy
                     * @dev This contract implements a proxy that allows to change the
                     * implementation address to which it will delegate.
                     * Such a change is called an implementation upgrade.
                     */
                    contract UpgradeabilityProxy is Proxy {
                      /**
                       * @dev Emitted when the implementation is upgraded.
                       * @param implementation Address of the new implementation.
                       */
                      event Upgraded(address implementation);
                    
                      /**
                       * @dev Storage slot with the address of the current implementation.
                       * This is the keccak-256 hash of "org.zeppelinos.proxy.implementation", and is
                       * validated in the constructor.
                       */
                      bytes32 private constant IMPLEMENTATION_SLOT = 0x7050c9e0f4ca769c69bd3a8ef740bc37934f8e2c036e5a723fd8ee048ed3f8c3;
                    
                      /**
                       * @dev Contract constructor.
                       * @param _implementation Address of the initial implementation.
                       */
                      constructor(address _implementation) public {
                        assert(IMPLEMENTATION_SLOT == keccak256("org.zeppelinos.proxy.implementation"));
                    
                        _setImplementation(_implementation);
                      }
                    
                      /**
                       * @dev Returns the current implementation.
                       * @return Address of the current implementation
                       */
                      function _implementation() internal view returns (address impl) {
                        bytes32 slot = IMPLEMENTATION_SLOT;
                        assembly {
                          impl := sload(slot)
                        }
                      }
                    
                      /**
                       * @dev Upgrades the proxy to a new implementation.
                       * @param newImplementation Address of the new implementation.
                       */
                      function _upgradeTo(address newImplementation) internal {
                        _setImplementation(newImplementation);
                        emit Upgraded(newImplementation);
                      }
                    
                      /**
                       * @dev Sets the implementation address of the proxy.
                       * @param newImplementation Address of the new implementation.
                       */
                      function _setImplementation(address newImplementation) private {
                        require(AddressUtils.isContract(newImplementation), "Cannot set a proxy implementation to a non-contract address");
                    
                        bytes32 slot = IMPLEMENTATION_SLOT;
                    
                        assembly {
                          sstore(slot, newImplementation)
                        }
                      }
                    }
                    
                    // File: zos-lib/contracts/upgradeability/AdminUpgradeabilityProxy.sol
                    
                    /**
                     * @title AdminUpgradeabilityProxy
                     * @dev This contract combines an upgradeability proxy with an authorization
                     * mechanism for administrative tasks.
                     * All external functions in this contract must be guarded by the
                     * `ifAdmin` modifier. See ethereum/solidity#3864 for a Solidity
                     * feature proposal that would enable this to be done automatically.
                     */
                    contract AdminUpgradeabilityProxy is UpgradeabilityProxy {
                      /**
                       * @dev Emitted when the administration has been transferred.
                       * @param previousAdmin Address of the previous admin.
                       * @param newAdmin Address of the new admin.
                       */
                      event AdminChanged(address previousAdmin, address newAdmin);
                    
                      /**
                       * @dev Storage slot with the admin of the contract.
                       * This is the keccak-256 hash of "org.zeppelinos.proxy.admin", and is
                       * validated in the constructor.
                       */
                      bytes32 private constant ADMIN_SLOT = 0x10d6a54a4754c8869d6886b5f5d7fbfa5b4522237ea5c60d11bc4e7a1ff9390b;
                    
                      /**
                       * @dev Modifier to check whether the `msg.sender` is the admin.
                       * If it is, it will run the function. Otherwise, it will delegate the call
                       * to the implementation.
                       */
                      modifier ifAdmin() {
                        if (msg.sender == _admin()) {
                          _;
                        } else {
                          _fallback();
                        }
                      }
                    
                      /**
                       * Contract constructor.
                       * It sets the `msg.sender` as the proxy administrator.
                       * @param _implementation address of the initial implementation.
                       */
                      constructor(address _implementation) UpgradeabilityProxy(_implementation) public {
                        assert(ADMIN_SLOT == keccak256("org.zeppelinos.proxy.admin"));
                    
                        _setAdmin(msg.sender);
                      }
                    
                      /**
                       * @return The address of the proxy admin.
                       */
                      function admin() external view ifAdmin returns (address) {
                        return _admin();
                      }
                    
                      /**
                       * @return The address of the implementation.
                       */
                      function implementation() external view ifAdmin returns (address) {
                        return _implementation();
                      }
                    
                      /**
                       * @dev Changes the admin of the proxy.
                       * Only the current admin can call this function.
                       * @param newAdmin Address to transfer proxy administration to.
                       */
                      function changeAdmin(address newAdmin) external ifAdmin {
                        require(newAdmin != address(0), "Cannot change the admin of a proxy to the zero address");
                        emit AdminChanged(_admin(), newAdmin);
                        _setAdmin(newAdmin);
                      }
                    
                      /**
                       * @dev Upgrade the backing implementation of the proxy.
                       * Only the admin can call this function.
                       * @param newImplementation Address of the new implementation.
                       */
                      function upgradeTo(address newImplementation) external ifAdmin {
                        _upgradeTo(newImplementation);
                      }
                    
                      /**
                       * @dev Upgrade the backing implementation of the proxy and call a function
                       * on the new implementation.
                       * This is useful to initialize the proxied contract.
                       * @param newImplementation Address of the new implementation.
                       * @param data Data to send as msg.data in the low level call.
                       * It should include the signature and the parameters of the function to be
                       * called, as described in
                       * https://solidity.readthedocs.io/en/develop/abi-spec.html#function-selector-and-argument-encoding.
                       */
                      function upgradeToAndCall(address newImplementation, bytes data) payable external ifAdmin {
                        _upgradeTo(newImplementation);
                        require(address(this).call.value(msg.value)(data));
                      }
                    
                      /**
                       * @return The admin slot.
                       */
                      function _admin() internal view returns (address adm) {
                        bytes32 slot = ADMIN_SLOT;
                        assembly {
                          adm := sload(slot)
                        }
                      }
                    
                      /**
                       * @dev Sets the address of the proxy admin.
                       * @param newAdmin Address of the new proxy admin.
                       */
                      function _setAdmin(address newAdmin) internal {
                        bytes32 slot = ADMIN_SLOT;
                    
                        assembly {
                          sstore(slot, newAdmin)
                        }
                      }
                    
                      /**
                       * @dev Only fall back when the sender is not the admin.
                       */
                      function _willFallback() internal {
                        require(msg.sender != _admin(), "Cannot call fallback function from the proxy admin");
                        super._willFallback();
                      }
                    }
                    
                    // File: contracts/FiatTokenProxy.sol
                    
                    /**
                    * Copyright CENTRE SECZ 2018
                    *
                    * Permission is hereby granted, free of charge, to any person obtaining a copy 
                    * of this software and associated documentation files (the "Software"), to deal 
                    * in the Software without restriction, including without limitation the rights 
                    * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 
                    * copies of the Software, and to permit persons to whom the Software is furnished to 
                    * do so, subject to the following conditions:
                    *
                    * The above copyright notice and this permission notice shall be included in all 
                    * copies or substantial portions of the Software.
                    *
                    * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 
                    * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 
                    * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 
                    * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
                    * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 
                    * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
                    */
                    
                    pragma solidity ^0.4.24;
                    
                    
                    /**
                     * @title FiatTokenProxy
                     * @dev This contract proxies FiatToken calls and enables FiatToken upgrades
                    */ 
                    contract FiatTokenProxy is AdminUpgradeabilityProxy {
                        constructor(address _implementation) public AdminUpgradeabilityProxy(_implementation) {
                        }
                    }

                    File 3 of 11: Proxy
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    /**
                     * @title Proxy
                     * @notice Proxy is a transparent proxy that passes through the call if the caller is the owner or
                     *         if the caller is address(0), meaning that the call originated from an off-chain
                     *         simulation.
                     */
                    contract Proxy {
                        /**
                         * @notice The storage slot that holds the address of the implementation.
                         *         bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
                         */
                        bytes32 internal constant IMPLEMENTATION_KEY =
                            0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                        /**
                         * @notice The storage slot that holds the address of the owner.
                         *         bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
                         */
                        bytes32 internal constant OWNER_KEY =
                            0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                        /**
                         * @notice An event that is emitted each time the implementation is changed. This event is part
                         *         of the EIP-1967 specification.
                         *
                         * @param implementation The address of the implementation contract
                         */
                        event Upgraded(address indexed implementation);
                        /**
                         * @notice An event that is emitted each time the owner is upgraded. This event is part of the
                         *         EIP-1967 specification.
                         *
                         * @param previousAdmin The previous owner of the contract
                         * @param newAdmin      The new owner of the contract
                         */
                        event AdminChanged(address previousAdmin, address newAdmin);
                        /**
                         * @notice A modifier that reverts if not called by the owner or by address(0) to allow
                         *         eth_call to interact with this proxy without needing to use low-level storage
                         *         inspection. We assume that nobody is able to trigger calls from address(0) during
                         *         normal EVM execution.
                         */
                        modifier proxyCallIfNotAdmin() {
                            if (msg.sender == _getAdmin() || msg.sender == address(0)) {
                                _;
                            } else {
                                // This WILL halt the call frame on completion.
                                _doProxyCall();
                            }
                        }
                        /**
                         * @notice Sets the initial admin during contract deployment. Admin address is stored at the
                         *         EIP-1967 admin storage slot so that accidental storage collision with the
                         *         implementation is not possible.
                         *
                         * @param _admin Address of the initial contract admin. Admin as the ability to access the
                         *               transparent proxy interface.
                         */
                        constructor(address _admin) {
                            _changeAdmin(_admin);
                        }
                        // slither-disable-next-line locked-ether
                        receive() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        // slither-disable-next-line locked-ether
                        fallback() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        /**
                         * @notice Set the implementation contract address. The code at the given address will execute
                         *         when this contract is called.
                         *
                         * @param _implementation Address of the implementation contract.
                         */
                        function upgradeTo(address _implementation) public virtual proxyCallIfNotAdmin {
                            _setImplementation(_implementation);
                        }
                        /**
                         * @notice Set the implementation and call a function in a single transaction. Useful to ensure
                         *         atomic execution of initialization-based upgrades.
                         *
                         * @param _implementation Address of the implementation contract.
                         * @param _data           Calldata to delegatecall the new implementation with.
                         */
                        function upgradeToAndCall(address _implementation, bytes calldata _data)
                            public
                            payable
                            virtual
                            proxyCallIfNotAdmin
                            returns (bytes memory)
                        {
                            _setImplementation(_implementation);
                            (bool success, bytes memory returndata) = _implementation.delegatecall(_data);
                            require(success, "Proxy: delegatecall to new implementation contract failed");
                            return returndata;
                        }
                        /**
                         * @notice Changes the owner of the proxy contract. Only callable by the owner.
                         *
                         * @param _admin New owner of the proxy contract.
                         */
                        function changeAdmin(address _admin) public virtual proxyCallIfNotAdmin {
                            _changeAdmin(_admin);
                        }
                        /**
                         * @notice Gets the owner of the proxy contract.
                         *
                         * @return Owner address.
                         */
                        function admin() public virtual proxyCallIfNotAdmin returns (address) {
                            return _getAdmin();
                        }
                        /**
                         * @notice Queries the implementation address.
                         *
                         * @return Implementation address.
                         */
                        function implementation() public virtual proxyCallIfNotAdmin returns (address) {
                            return _getImplementation();
                        }
                        /**
                         * @notice Sets the implementation address.
                         *
                         * @param _implementation New implementation address.
                         */
                        function _setImplementation(address _implementation) internal {
                            assembly {
                                sstore(IMPLEMENTATION_KEY, _implementation)
                            }
                            emit Upgraded(_implementation);
                        }
                        /**
                         * @notice Changes the owner of the proxy contract.
                         *
                         * @param _admin New owner of the proxy contract.
                         */
                        function _changeAdmin(address _admin) internal {
                            address previous = _getAdmin();
                            assembly {
                                sstore(OWNER_KEY, _admin)
                            }
                            emit AdminChanged(previous, _admin);
                        }
                        /**
                         * @notice Performs the proxy call via a delegatecall.
                         */
                        function _doProxyCall() internal {
                            address impl = _getImplementation();
                            require(impl != address(0), "Proxy: implementation not initialized");
                            assembly {
                                // Copy calldata into memory at 0x0....calldatasize.
                                calldatacopy(0x0, 0x0, calldatasize())
                                // Perform the delegatecall, make sure to pass all available gas.
                                let success := delegatecall(gas(), impl, 0x0, calldatasize(), 0x0, 0x0)
                                // Copy returndata into memory at 0x0....returndatasize. Note that this *will*
                                // overwrite the calldata that we just copied into memory but that doesn't really
                                // matter because we'll be returning in a second anyway.
                                returndatacopy(0x0, 0x0, returndatasize())
                                // Success == 0 means a revert. We'll revert too and pass the data up.
                                if iszero(success) {
                                    revert(0x0, returndatasize())
                                }
                                // Otherwise we'll just return and pass the data up.
                                return(0x0, returndatasize())
                            }
                        }
                        /**
                         * @notice Queries the implementation address.
                         *
                         * @return Implementation address.
                         */
                        function _getImplementation() internal view returns (address) {
                            address impl;
                            assembly {
                                impl := sload(IMPLEMENTATION_KEY)
                            }
                            return impl;
                        }
                        /**
                         * @notice Queries the owner of the proxy contract.
                         *
                         * @return Owner address.
                         */
                        function _getAdmin() internal view returns (address) {
                            address owner;
                            assembly {
                                owner := sload(OWNER_KEY)
                            }
                            return owner;
                        }
                    }
                    

                    File 4 of 11: Lib_ResolvedDelegateProxy
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.0 <0.8.0;
                    import "../utils/Context.sol";
                    /**
                     * @dev 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.
                     */
                    abstract contract Ownable is Context {
                        address private _owner;
                        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                        /**
                         * @dev Initializes the contract setting the deployer as the initial owner.
                         */
                        constructor () internal {
                            address msgSender = _msgSender();
                            _owner = msgSender;
                            emit OwnershipTransferred(address(0), msgSender);
                        }
                        /**
                         * @dev Returns the address of the current owner.
                         */
                        function owner() public view virtual returns (address) {
                            return _owner;
                        }
                        /**
                         * @dev Throws if called by any account other than the owner.
                         */
                        modifier onlyOwner() {
                            require(owner() == _msgSender(), "Ownable: caller is not the owner");
                            _;
                        }
                        /**
                         * @dev Leaves the contract without owner. It will not be possible to call
                         * `onlyOwner` functions anymore. Can only be called by the current owner.
                         *
                         * NOTE: Renouncing ownership will leave the contract without an owner,
                         * thereby removing any functionality that is only available to the owner.
                         */
                        function renounceOwnership() public virtual onlyOwner {
                            emit OwnershipTransferred(_owner, address(0));
                            _owner = address(0);
                        }
                        /**
                         * @dev Transfers ownership of the contract to a new account (`newOwner`).
                         * Can only be called by the current owner.
                         */
                        function transferOwnership(address newOwner) public virtual onlyOwner {
                            require(newOwner != address(0), "Ownable: new owner is the zero address");
                            emit OwnershipTransferred(_owner, newOwner);
                            _owner = newOwner;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.0 <0.8.0;
                    /*
                     * @dev 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 GSN 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.
                     */
                    abstract contract Context {
                        function _msgSender() internal view virtual returns (address payable) {
                            return msg.sender;
                        }
                        function _msgData() internal view virtual returns (bytes memory) {
                            this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                            return msg.data;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >0.5.0 <0.8.0;
                    /* External Imports */
                    import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
                    /**
                     * @title Lib_AddressManager
                     */
                    contract Lib_AddressManager is Ownable {
                        /**********
                         * Events *
                         **********/
                        event AddressSet(
                            string indexed _name,
                            address _newAddress,
                            address _oldAddress
                        );
                        /*************
                         * Variables *
                         *************/
                        mapping (bytes32 => address) private addresses;
                        /********************
                         * Public Functions *
                         ********************/
                        /**
                         * Changes the address associated with a particular name.
                         * @param _name String name to associate an address with.
                         * @param _address Address to associate with the name.
                         */
                        function setAddress(
                            string memory _name,
                            address _address
                        )
                            external
                            onlyOwner
                        {
                            bytes32 nameHash = _getNameHash(_name);
                            address oldAddress = addresses[nameHash];
                            addresses[nameHash] = _address;
                            emit AddressSet(
                                _name,
                                _address,
                                oldAddress
                            );
                        }
                        /**
                         * Retrieves the address associated with a given name.
                         * @param _name Name to retrieve an address for.
                         * @return Address associated with the given name.
                         */
                        function getAddress(
                            string memory _name
                        )
                            external
                            view
                            returns (
                                address
                            )
                        {
                            return addresses[_getNameHash(_name)];
                        }
                        /**********************
                         * Internal Functions *
                         **********************/
                        /**
                         * Computes the hash of a name.
                         * @param _name Name to compute a hash for.
                         * @return Hash of the given name.
                         */
                        function _getNameHash(
                            string memory _name
                        )
                            internal
                            pure
                            returns (
                                bytes32
                            )
                        {
                            return keccak256(abi.encodePacked(_name));
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >0.5.0 <0.8.0;
                    /* Library Imports */
                    import { Lib_AddressManager } from "./Lib_AddressManager.sol";
                    /**
                     * @title Lib_ResolvedDelegateProxy
                     */
                    contract Lib_ResolvedDelegateProxy {
                        /*************
                         * Variables *
                         *************/
                        // Using mappings to store fields to avoid overwriting storage slots in the
                        // implementation contract. For example, instead of storing these fields at
                        // storage slot `0` & `1`, they are stored at `keccak256(key + slot)`.
                        // See: https://solidity.readthedocs.io/en/v0.7.0/internals/layout_in_storage.html
                        // NOTE: Do not use this code in your own contract system.
                        //      There is a known flaw in this contract, and we will remove it from the repository
                        //      in the near future. Due to the very limited way that we are using it, this flaw is
                        //      not an issue in our system.
                        mapping (address => string) private implementationName;
                        mapping (address => Lib_AddressManager) private addressManager;
                        /***************
                         * Constructor *
                         ***************/
                        /**
                         * @param _libAddressManager Address of the Lib_AddressManager.
                         * @param _implementationName implementationName of the contract to proxy to.
                         */
                        constructor(
                            address _libAddressManager,
                            string memory _implementationName
                        ) {
                            addressManager[address(this)] = Lib_AddressManager(_libAddressManager);
                            implementationName[address(this)] = _implementationName;
                        }
                        /*********************
                         * Fallback Function *
                         *********************/
                        fallback()
                            external
                            payable
                        {
                            address target = addressManager[address(this)].getAddress(
                                (implementationName[address(this)])
                            );
                            require(
                                target != address(0),
                                "Target address must be initialized."
                            );
                            (bool success, bytes memory returndata) = target.delegatecall(msg.data);
                            if (success == true) {
                                assembly {
                                    return(add(returndata, 0x20), mload(returndata))
                                }
                            } else {
                                assembly {
                                    revert(add(returndata, 0x20), mload(returndata))
                                }
                            }
                        }
                    }
                    

                    File 5 of 11: ProxyAdmin
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
                    /**
                     * @custom:legacy
                     * @title AddressManager
                     * @notice AddressManager is a legacy contract that was used in the old version of the Optimism
                     *         system to manage a registry of string names to addresses. We now use a more standard
                     *         proxy system instead, but this contract is still necessary for backwards compatibility
                     *         with several older contracts.
                     */
                    contract AddressManager is Ownable {
                        /**
                         * @notice Mapping of the hashes of string names to addresses.
                         */
                        mapping(bytes32 => address) private addresses;
                        /**
                         * @notice Emitted when an address is modified in the registry.
                         *
                         * @param name       String name being set in the registry.
                         * @param newAddress Address set for the given name.
                         * @param oldAddress Address that was previously set for the given name.
                         */
                        event AddressSet(string indexed name, address newAddress, address oldAddress);
                        /**
                         * @notice Changes the address associated with a particular name.
                         *
                         * @param _name    String name to associate an address with.
                         * @param _address Address to associate with the name.
                         */
                        function setAddress(string memory _name, address _address) external onlyOwner {
                            bytes32 nameHash = _getNameHash(_name);
                            address oldAddress = addresses[nameHash];
                            addresses[nameHash] = _address;
                            emit AddressSet(_name, _address, oldAddress);
                        }
                        /**
                         * @notice Retrieves the address associated with a given name.
                         *
                         * @param _name Name to retrieve an address for.
                         *
                         * @return Address associated with the given name.
                         */
                        function getAddress(string memory _name) external view returns (address) {
                            return addresses[_getNameHash(_name)];
                        }
                        /**
                         * @notice Computes the hash of a name.
                         *
                         * @param _name Name to compute a hash for.
                         *
                         * @return Hash of the given name.
                         */
                        function _getNameHash(string memory _name) internal pure returns (bytes32) {
                            return keccak256(abi.encodePacked(_name));
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    /**
                     * @title IL1ChugSplashDeployer
                     */
                    interface IL1ChugSplashDeployer {
                        function isUpgrading() external view returns (bool);
                    }
                    /**
                     * @custom:legacy
                     * @title L1ChugSplashProxy
                     * @notice Basic ChugSplash proxy contract for L1. Very close to being a normal proxy but has added
                     *         functions `setCode` and `setStorage` for changing the code or storage of the contract.
                     *
                     *         Note for future developers: do NOT make anything in this contract 'public' unless you
                     *         know what you're doing. Anything public can potentially have a function signature that
                     *         conflicts with a signature attached to the implementation contract. Public functions
                     *         SHOULD always have the `proxyCallIfNotOwner` modifier unless there's some *really* good
                     *         reason not to have that modifier. And there almost certainly is not a good reason to not
                     *         have that modifier. Beware!
                     */
                    contract L1ChugSplashProxy {
                        /**
                         * @notice "Magic" prefix. When prepended to some arbitrary bytecode and used to create a
                         *         contract, the appended bytecode will be deployed as given.
                         */
                        bytes13 internal constant DEPLOY_CODE_PREFIX = 0x600D380380600D6000396000f3;
                        /**
                         * @notice bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
                         */
                        bytes32 internal constant IMPLEMENTATION_KEY =
                            0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                        /**
                         * @notice bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
                         */
                        bytes32 internal constant OWNER_KEY =
                            0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                        /**
                         * @notice Blocks a function from being called when the parent signals that the system should
                         *         be paused via an isUpgrading function.
                         */
                        modifier onlyWhenNotPaused() {
                            address owner = _getOwner();
                            // We do a low-level call because there's no guarantee that the owner actually *is* an
                            // L1ChugSplashDeployer contract and Solidity will throw errors if we do a normal call and
                            // it turns out that it isn't the right type of contract.
                            (bool success, bytes memory returndata) = owner.staticcall(
                                abi.encodeWithSelector(IL1ChugSplashDeployer.isUpgrading.selector)
                            );
                            // If the call was unsuccessful then we assume that there's no "isUpgrading" method and we
                            // can just continue as normal. We also expect that the return value is exactly 32 bytes
                            // long. If this isn't the case then we can safely ignore the result.
                            if (success && returndata.length == 32) {
                                // Although the expected value is a *boolean*, it's safer to decode as a uint256 in the
                                // case that the isUpgrading function returned something other than 0 or 1. But we only
                                // really care about the case where this value is 0 (= false).
                                uint256 ret = abi.decode(returndata, (uint256));
                                require(ret == 0, "L1ChugSplashProxy: system is currently being upgraded");
                            }
                            _;
                        }
                        /**
                         * @notice Makes a proxy call instead of triggering the given function when the caller is
                         *         either the owner or the zero address. Caller can only ever be the zero address if
                         *         this function is being called off-chain via eth_call, which is totally fine and can
                         *         be convenient for client-side tooling. Avoids situations where the proxy and
                         *         implementation share a sighash and the proxy function ends up being called instead
                         *         of the implementation one.
                         *
                         *         Note: msg.sender == address(0) can ONLY be triggered off-chain via eth_call. If
                         *         there's a way for someone to send a transaction with msg.sender == address(0) in any
                         *         real context then we have much bigger problems. Primary reason to include this
                         *         additional allowed sender is because the owner address can be changed dynamically
                         *         and we do not want clients to have to keep track of the current owner in order to
                         *         make an eth_call that doesn't trigger the proxied contract.
                         */
                        // slither-disable-next-line incorrect-modifier
                        modifier proxyCallIfNotOwner() {
                            if (msg.sender == _getOwner() || msg.sender == address(0)) {
                                _;
                            } else {
                                // This WILL halt the call frame on completion.
                                _doProxyCall();
                            }
                        }
                        /**
                         * @param _owner Address of the initial contract owner.
                         */
                        constructor(address _owner) {
                            _setOwner(_owner);
                        }
                        // slither-disable-next-line locked-ether
                        receive() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        // slither-disable-next-line locked-ether
                        fallback() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        /**
                         * @notice Sets the code that should be running behind this proxy.
                         *
                         *         Note: This scheme is a bit different from the standard proxy scheme where one would
                         *         typically deploy the code separately and then set the implementation address. We're
                         *         doing it this way because it gives us a lot more freedom on the client side. Can
                         *         only be triggered by the contract owner.
                         *
                         * @param _code New contract code to run inside this contract.
                         */
                        function setCode(bytes memory _code) external proxyCallIfNotOwner {
                            // Get the code hash of the current implementation.
                            address implementation = _getImplementation();
                            // If the code hash matches the new implementation then we return early.
                            if (keccak256(_code) == _getAccountCodeHash(implementation)) {
                                return;
                            }
                            // Create the deploycode by appending the magic prefix.
                            bytes memory deploycode = abi.encodePacked(DEPLOY_CODE_PREFIX, _code);
                            // Deploy the code and set the new implementation address.
                            address newImplementation;
                            assembly {
                                newImplementation := create(0x0, add(deploycode, 0x20), mload(deploycode))
                            }
                            // Check that the code was actually deployed correctly. I'm not sure if you can ever
                            // actually fail this check. Should only happen if the contract creation from above runs
                            // out of gas but this parent execution thread does NOT run out of gas. Seems like we
                            // should be doing this check anyway though.
                            require(
                                _getAccountCodeHash(newImplementation) == keccak256(_code),
                                "L1ChugSplashProxy: code was not correctly deployed"
                            );
                            _setImplementation(newImplementation);
                        }
                        /**
                         * @notice Modifies some storage slot within the proxy contract. Gives us a lot of power to
                         *         perform upgrades in a more transparent way. Only callable by the owner.
                         *
                         * @param _key   Storage key to modify.
                         * @param _value New value for the storage key.
                         */
                        function setStorage(bytes32 _key, bytes32 _value) external proxyCallIfNotOwner {
                            assembly {
                                sstore(_key, _value)
                            }
                        }
                        /**
                         * @notice Changes the owner of the proxy contract. Only callable by the owner.
                         *
                         * @param _owner New owner of the proxy contract.
                         */
                        function setOwner(address _owner) external proxyCallIfNotOwner {
                            _setOwner(_owner);
                        }
                        /**
                         * @notice Queries the owner of the proxy contract. Can only be called by the owner OR by
                         *         making an eth_call and setting the "from" address to address(0).
                         *
                         * @return Owner address.
                         */
                        function getOwner() external proxyCallIfNotOwner returns (address) {
                            return _getOwner();
                        }
                        /**
                         * @notice Queries the implementation address. Can only be called by the owner OR by making an
                         *         eth_call and setting the "from" address to address(0).
                         *
                         * @return Implementation address.
                         */
                        function getImplementation() external proxyCallIfNotOwner returns (address) {
                            return _getImplementation();
                        }
                        /**
                         * @notice Sets the implementation address.
                         *
                         * @param _implementation New implementation address.
                         */
                        function _setImplementation(address _implementation) internal {
                            assembly {
                                sstore(IMPLEMENTATION_KEY, _implementation)
                            }
                        }
                        /**
                         * @notice Changes the owner of the proxy contract.
                         *
                         * @param _owner New owner of the proxy contract.
                         */
                        function _setOwner(address _owner) internal {
                            assembly {
                                sstore(OWNER_KEY, _owner)
                            }
                        }
                        /**
                         * @notice Performs the proxy call via a delegatecall.
                         */
                        function _doProxyCall() internal onlyWhenNotPaused {
                            address implementation = _getImplementation();
                            require(implementation != address(0), "L1ChugSplashProxy: implementation is not set yet");
                            assembly {
                                // Copy calldata into memory at 0x0....calldatasize.
                                calldatacopy(0x0, 0x0, calldatasize())
                                // Perform the delegatecall, make sure to pass all available gas.
                                let success := delegatecall(gas(), implementation, 0x0, calldatasize(), 0x0, 0x0)
                                // Copy returndata into memory at 0x0....returndatasize. Note that this *will*
                                // overwrite the calldata that we just copied into memory but that doesn't really
                                // matter because we'll be returning in a second anyway.
                                returndatacopy(0x0, 0x0, returndatasize())
                                // Success == 0 means a revert. We'll revert too and pass the data up.
                                if iszero(success) {
                                    revert(0x0, returndatasize())
                                }
                                // Otherwise we'll just return and pass the data up.
                                return(0x0, returndatasize())
                            }
                        }
                        /**
                         * @notice Queries the implementation address.
                         *
                         * @return Implementation address.
                         */
                        function _getImplementation() internal view returns (address) {
                            address implementation;
                            assembly {
                                implementation := sload(IMPLEMENTATION_KEY)
                            }
                            return implementation;
                        }
                        /**
                         * @notice Queries the owner of the proxy contract.
                         *
                         * @return Owner address.
                         */
                        function _getOwner() internal view returns (address) {
                            address owner;
                            assembly {
                                owner := sload(OWNER_KEY)
                            }
                            return owner;
                        }
                        /**
                         * @notice Gets the code hash for a given account.
                         *
                         * @param _account Address of the account to get a code hash for.
                         *
                         * @return Code hash for the account.
                         */
                        function _getAccountCodeHash(address _account) internal view returns (bytes32) {
                            bytes32 codeHash;
                            assembly {
                                codeHash := extcodehash(_account)
                            }
                            return codeHash;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    /**
                     * @title Proxy
                     * @notice Proxy is a transparent proxy that passes through the call if the caller is the owner or
                     *         if the caller is address(0), meaning that the call originated from an off-chain
                     *         simulation.
                     */
                    contract Proxy {
                        /**
                         * @notice The storage slot that holds the address of the implementation.
                         *         bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
                         */
                        bytes32 internal constant IMPLEMENTATION_KEY =
                            0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                        /**
                         * @notice The storage slot that holds the address of the owner.
                         *         bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
                         */
                        bytes32 internal constant OWNER_KEY =
                            0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                        /**
                         * @notice An event that is emitted each time the implementation is changed. This event is part
                         *         of the EIP-1967 specification.
                         *
                         * @param implementation The address of the implementation contract
                         */
                        event Upgraded(address indexed implementation);
                        /**
                         * @notice An event that is emitted each time the owner is upgraded. This event is part of the
                         *         EIP-1967 specification.
                         *
                         * @param previousAdmin The previous owner of the contract
                         * @param newAdmin      The new owner of the contract
                         */
                        event AdminChanged(address previousAdmin, address newAdmin);
                        /**
                         * @notice A modifier that reverts if not called by the owner or by address(0) to allow
                         *         eth_call to interact with this proxy without needing to use low-level storage
                         *         inspection. We assume that nobody is able to trigger calls from address(0) during
                         *         normal EVM execution.
                         */
                        modifier proxyCallIfNotAdmin() {
                            if (msg.sender == _getAdmin() || msg.sender == address(0)) {
                                _;
                            } else {
                                // This WILL halt the call frame on completion.
                                _doProxyCall();
                            }
                        }
                        /**
                         * @notice Sets the initial admin during contract deployment. Admin address is stored at the
                         *         EIP-1967 admin storage slot so that accidental storage collision with the
                         *         implementation is not possible.
                         *
                         * @param _admin Address of the initial contract admin. Admin as the ability to access the
                         *               transparent proxy interface.
                         */
                        constructor(address _admin) {
                            _changeAdmin(_admin);
                        }
                        // slither-disable-next-line locked-ether
                        receive() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        // slither-disable-next-line locked-ether
                        fallback() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        /**
                         * @notice Set the implementation contract address. The code at the given address will execute
                         *         when this contract is called.
                         *
                         * @param _implementation Address of the implementation contract.
                         */
                        function upgradeTo(address _implementation) public virtual proxyCallIfNotAdmin {
                            _setImplementation(_implementation);
                        }
                        /**
                         * @notice Set the implementation and call a function in a single transaction. Useful to ensure
                         *         atomic execution of initialization-based upgrades.
                         *
                         * @param _implementation Address of the implementation contract.
                         * @param _data           Calldata to delegatecall the new implementation with.
                         */
                        function upgradeToAndCall(address _implementation, bytes calldata _data)
                            public
                            payable
                            virtual
                            proxyCallIfNotAdmin
                            returns (bytes memory)
                        {
                            _setImplementation(_implementation);
                            (bool success, bytes memory returndata) = _implementation.delegatecall(_data);
                            require(success, "Proxy: delegatecall to new implementation contract failed");
                            return returndata;
                        }
                        /**
                         * @notice Changes the owner of the proxy contract. Only callable by the owner.
                         *
                         * @param _admin New owner of the proxy contract.
                         */
                        function changeAdmin(address _admin) public virtual proxyCallIfNotAdmin {
                            _changeAdmin(_admin);
                        }
                        /**
                         * @notice Gets the owner of the proxy contract.
                         *
                         * @return Owner address.
                         */
                        function admin() public virtual proxyCallIfNotAdmin returns (address) {
                            return _getAdmin();
                        }
                        /**
                         * @notice Queries the implementation address.
                         *
                         * @return Implementation address.
                         */
                        function implementation() public virtual proxyCallIfNotAdmin returns (address) {
                            return _getImplementation();
                        }
                        /**
                         * @notice Sets the implementation address.
                         *
                         * @param _implementation New implementation address.
                         */
                        function _setImplementation(address _implementation) internal {
                            assembly {
                                sstore(IMPLEMENTATION_KEY, _implementation)
                            }
                            emit Upgraded(_implementation);
                        }
                        /**
                         * @notice Changes the owner of the proxy contract.
                         *
                         * @param _admin New owner of the proxy contract.
                         */
                        function _changeAdmin(address _admin) internal {
                            address previous = _getAdmin();
                            assembly {
                                sstore(OWNER_KEY, _admin)
                            }
                            emit AdminChanged(previous, _admin);
                        }
                        /**
                         * @notice Performs the proxy call via a delegatecall.
                         */
                        function _doProxyCall() internal {
                            address impl = _getImplementation();
                            require(impl != address(0), "Proxy: implementation not initialized");
                            assembly {
                                // Copy calldata into memory at 0x0....calldatasize.
                                calldatacopy(0x0, 0x0, calldatasize())
                                // Perform the delegatecall, make sure to pass all available gas.
                                let success := delegatecall(gas(), impl, 0x0, calldatasize(), 0x0, 0x0)
                                // Copy returndata into memory at 0x0....returndatasize. Note that this *will*
                                // overwrite the calldata that we just copied into memory but that doesn't really
                                // matter because we'll be returning in a second anyway.
                                returndatacopy(0x0, 0x0, returndatasize())
                                // Success == 0 means a revert. We'll revert too and pass the data up.
                                if iszero(success) {
                                    revert(0x0, returndatasize())
                                }
                                // Otherwise we'll just return and pass the data up.
                                return(0x0, returndatasize())
                            }
                        }
                        /**
                         * @notice Queries the implementation address.
                         *
                         * @return Implementation address.
                         */
                        function _getImplementation() internal view returns (address) {
                            address impl;
                            assembly {
                                impl := sload(IMPLEMENTATION_KEY)
                            }
                            return impl;
                        }
                        /**
                         * @notice Queries the owner of the proxy contract.
                         *
                         * @return Owner address.
                         */
                        function _getAdmin() internal view returns (address) {
                            address owner;
                            assembly {
                                owner := sload(OWNER_KEY)
                            }
                            return owner;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
                    import { Proxy } from "./Proxy.sol";
                    import { AddressManager } from "../legacy/AddressManager.sol";
                    import { L1ChugSplashProxy } from "../legacy/L1ChugSplashProxy.sol";
                    /**
                     * @title IStaticERC1967Proxy
                     * @notice IStaticERC1967Proxy is a static version of the ERC1967 proxy interface.
                     */
                    interface IStaticERC1967Proxy {
                        function implementation() external view returns (address);
                        function admin() external view returns (address);
                    }
                    /**
                     * @title IStaticL1ChugSplashProxy
                     * @notice IStaticL1ChugSplashProxy is a static version of the ChugSplash proxy interface.
                     */
                    interface IStaticL1ChugSplashProxy {
                        function getImplementation() external view returns (address);
                        function getOwner() external view returns (address);
                    }
                    /**
                     * @title ProxyAdmin
                     * @notice This is an auxiliary contract meant to be assigned as the admin of an ERC1967 Proxy,
                     *         based on the OpenZeppelin implementation. It has backwards compatibility logic to work
                     *         with the various types of proxies that have been deployed by Optimism in the past.
                     */
                    contract ProxyAdmin is Ownable {
                        /**
                         * @notice The proxy types that the ProxyAdmin can manage.
                         *
                         * @custom:value ERC1967    Represents an ERC1967 compliant transparent proxy interface.
                         * @custom:value CHUGSPLASH Represents the Chugsplash proxy interface (legacy).
                         * @custom:value RESOLVED   Represents the ResolvedDelegate proxy (legacy).
                         */
                        enum ProxyType {
                            ERC1967,
                            CHUGSPLASH,
                            RESOLVED
                        }
                        /**
                         * @notice A mapping of proxy types, used for backwards compatibility.
                         */
                        mapping(address => ProxyType) public proxyType;
                        /**
                         * @notice A reverse mapping of addresses to names held in the AddressManager. This must be
                         *         manually kept up to date with changes in the AddressManager for this contract
                         *         to be able to work as an admin for the ResolvedDelegateProxy type.
                         */
                        mapping(address => string) public implementationName;
                        /**
                         * @notice The address of the address manager, this is required to manage the
                         *         ResolvedDelegateProxy type.
                         */
                        AddressManager public addressManager;
                        /**
                         * @notice A legacy upgrading indicator used by the old Chugsplash Proxy.
                         */
                        bool internal upgrading;
                        /**
                         * @param _owner Address of the initial owner of this contract.
                         */
                        constructor(address _owner) Ownable() {
                            _transferOwnership(_owner);
                        }
                        /**
                         * @notice Sets the proxy type for a given address. Only required for non-standard (legacy)
                         *         proxy types.
                         *
                         * @param _address Address of the proxy.
                         * @param _type    Type of the proxy.
                         */
                        function setProxyType(address _address, ProxyType _type) external onlyOwner {
                            proxyType[_address] = _type;
                        }
                        /**
                         * @notice Sets the implementation name for a given address. Only required for
                         *         ResolvedDelegateProxy type proxies that have an implementation name.
                         *
                         * @param _address Address of the ResolvedDelegateProxy.
                         * @param _name    Name of the implementation for the proxy.
                         */
                        function setImplementationName(address _address, string memory _name) external onlyOwner {
                            implementationName[_address] = _name;
                        }
                        /**
                         * @notice Set the address of the AddressManager. This is required to manage legacy
                         *         ResolvedDelegateProxy type proxy contracts.
                         *
                         * @param _address Address of the AddressManager.
                         */
                        function setAddressManager(AddressManager _address) external onlyOwner {
                            addressManager = _address;
                        }
                        /**
                         * @custom:legacy
                         * @notice Set an address in the address manager. Since only the owner of the AddressManager
                         *         can directly modify addresses and the ProxyAdmin will own the AddressManager, this
                         *         gives the owner of the ProxyAdmin the ability to modify addresses directly.
                         *
                         * @param _name    Name to set within the AddressManager.
                         * @param _address Address to attach to the given name.
                         */
                        function setAddress(string memory _name, address _address) external onlyOwner {
                            addressManager.setAddress(_name, _address);
                        }
                        /**
                         * @custom:legacy
                         * @notice Set the upgrading status for the Chugsplash proxy type.
                         *
                         * @param _upgrading Whether or not the system is upgrading.
                         */
                        function setUpgrading(bool _upgrading) external onlyOwner {
                            upgrading = _upgrading;
                        }
                        /**
                         * @custom:legacy
                         * @notice Legacy function used to tell ChugSplashProxy contracts if an upgrade is happening.
                         *
                         * @return Whether or not there is an upgrade going on. May not actually tell you whether an
                         *         upgrade is going on, since we don't currently plan to use this variable for anything
                         *         other than a legacy indicator to fix a UX bug in the ChugSplash proxy.
                         */
                        function isUpgrading() external view returns (bool) {
                            return upgrading;
                        }
                        /**
                         * @notice Returns the implementation of the given proxy address.
                         *
                         * @param _proxy Address of the proxy to get the implementation of.
                         *
                         * @return Address of the implementation of the proxy.
                         */
                        function getProxyImplementation(address _proxy) external view returns (address) {
                            ProxyType ptype = proxyType[_proxy];
                            if (ptype == ProxyType.ERC1967) {
                                return IStaticERC1967Proxy(_proxy).implementation();
                            } else if (ptype == ProxyType.CHUGSPLASH) {
                                return IStaticL1ChugSplashProxy(_proxy).getImplementation();
                            } else if (ptype == ProxyType.RESOLVED) {
                                return addressManager.getAddress(implementationName[_proxy]);
                            } else {
                                revert("ProxyAdmin: unknown proxy type");
                            }
                        }
                        /**
                         * @notice Returns the admin of the given proxy address.
                         *
                         * @param _proxy Address of the proxy to get the admin of.
                         *
                         * @return Address of the admin of the proxy.
                         */
                        function getProxyAdmin(address payable _proxy) external view returns (address) {
                            ProxyType ptype = proxyType[_proxy];
                            if (ptype == ProxyType.ERC1967) {
                                return IStaticERC1967Proxy(_proxy).admin();
                            } else if (ptype == ProxyType.CHUGSPLASH) {
                                return IStaticL1ChugSplashProxy(_proxy).getOwner();
                            } else if (ptype == ProxyType.RESOLVED) {
                                return addressManager.owner();
                            } else {
                                revert("ProxyAdmin: unknown proxy type");
                            }
                        }
                        /**
                         * @notice Updates the admin of the given proxy address.
                         *
                         * @param _proxy    Address of the proxy to update.
                         * @param _newAdmin Address of the new proxy admin.
                         */
                        function changeProxyAdmin(address payable _proxy, address _newAdmin) external onlyOwner {
                            ProxyType ptype = proxyType[_proxy];
                            if (ptype == ProxyType.ERC1967) {
                                Proxy(_proxy).changeAdmin(_newAdmin);
                            } else if (ptype == ProxyType.CHUGSPLASH) {
                                L1ChugSplashProxy(_proxy).setOwner(_newAdmin);
                            } else if (ptype == ProxyType.RESOLVED) {
                                addressManager.transferOwnership(_newAdmin);
                            } else {
                                revert("ProxyAdmin: unknown proxy type");
                            }
                        }
                        /**
                         * @notice Changes a proxy's implementation contract.
                         *
                         * @param _proxy          Address of the proxy to upgrade.
                         * @param _implementation Address of the new implementation address.
                         */
                        function upgrade(address payable _proxy, address _implementation) public onlyOwner {
                            ProxyType ptype = proxyType[_proxy];
                            if (ptype == ProxyType.ERC1967) {
                                Proxy(_proxy).upgradeTo(_implementation);
                            } else if (ptype == ProxyType.CHUGSPLASH) {
                                L1ChugSplashProxy(_proxy).setStorage(
                                    // bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
                                    0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc,
                                    bytes32(uint256(uint160(_implementation)))
                                );
                            } else if (ptype == ProxyType.RESOLVED) {
                                string memory name = implementationName[_proxy];
                                addressManager.setAddress(name, _implementation);
                            } else {
                                // It should not be possible to retrieve a ProxyType value which is not matched by
                                // one of the previous conditions.
                                assert(false);
                            }
                        }
                        /**
                         * @notice Changes a proxy's implementation contract and delegatecalls the new implementation
                         *         with some given data. Useful for atomic upgrade-and-initialize calls.
                         *
                         * @param _proxy          Address of the proxy to upgrade.
                         * @param _implementation Address of the new implementation address.
                         * @param _data           Data to trigger the new implementation with.
                         */
                        function upgradeAndCall(
                            address payable _proxy,
                            address _implementation,
                            bytes memory _data
                        ) external payable onlyOwner {
                            ProxyType ptype = proxyType[_proxy];
                            if (ptype == ProxyType.ERC1967) {
                                Proxy(_proxy).upgradeToAndCall{ value: msg.value }(_implementation, _data);
                            } else {
                                // reverts if proxy type is unknown
                                upgrade(_proxy, _implementation);
                                (bool success, ) = _proxy.call{ value: msg.value }(_data);
                                require(success, "ProxyAdmin: call to proxy after upgrade failed");
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
                    pragma solidity ^0.8.0;
                    import "../utils/Context.sol";
                    /**
                     * @dev 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.
                     */
                    abstract contract Ownable is Context {
                        address private _owner;
                        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                        /**
                         * @dev Initializes the contract setting the deployer as the initial owner.
                         */
                        constructor() {
                            _transferOwnership(_msgSender());
                        }
                        /**
                         * @dev Throws if called by any account other than the owner.
                         */
                        modifier onlyOwner() {
                            _checkOwner();
                            _;
                        }
                        /**
                         * @dev Returns the address of the current owner.
                         */
                        function owner() public view virtual returns (address) {
                            return _owner;
                        }
                        /**
                         * @dev Throws if the sender is not the owner.
                         */
                        function _checkOwner() internal view virtual {
                            require(owner() == _msgSender(), "Ownable: caller is not the owner");
                        }
                        /**
                         * @dev Leaves the contract without owner. It will not be possible to call
                         * `onlyOwner` functions anymore. Can only be called by the current owner.
                         *
                         * NOTE: Renouncing ownership will leave the contract without an owner,
                         * thereby removing any functionality that is only available to the owner.
                         */
                        function renounceOwnership() public virtual onlyOwner {
                            _transferOwnership(address(0));
                        }
                        /**
                         * @dev Transfers ownership of the contract to a new account (`newOwner`).
                         * Can only be called by the current owner.
                         */
                        function transferOwnership(address newOwner) public virtual onlyOwner {
                            require(newOwner != address(0), "Ownable: new owner is the zero address");
                            _transferOwnership(newOwner);
                        }
                        /**
                         * @dev Transfers ownership of the contract to a new account (`newOwner`).
                         * Internal function without access restriction.
                         */
                        function _transferOwnership(address newOwner) internal virtual {
                            address oldOwner = _owner;
                            _owner = newOwner;
                            emit OwnershipTransferred(oldOwner, newOwner);
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev 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.
                     */
                    abstract contract Context {
                        function _msgSender() internal view virtual returns (address) {
                            return msg.sender;
                        }
                        function _msgData() internal view virtual returns (bytes calldata) {
                            return msg.data;
                        }
                    }
                    

                    File 6 of 11: L1StandardBridge
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    // Contracts
                    import { StandardBridge } from "src/universal/StandardBridge.sol";
                    // Libraries
                    import { Predeploys } from "src/libraries/Predeploys.sol";
                    // Interfaces
                    import { ISemver } from "interfaces/universal/ISemver.sol";
                    import { ICrossDomainMessenger } from "interfaces/universal/ICrossDomainMessenger.sol";
                    import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
                    /// @custom:proxied true
                    /// @title L1StandardBridge
                    /// @notice The L1StandardBridge is responsible for transfering ETH and ERC20 tokens between L1 and
                    ///         L2. In the case that an ERC20 token is native to L1, it will be escrowed within this
                    ///         contract. If the ERC20 token is native to L2, it will be burnt. Before Bedrock, ETH was
                    ///         stored within this contract. After Bedrock, ETH is instead stored inside the
                    ///         OptimismPortal contract.
                    ///         NOTE: this contract is not intended to support all variations of ERC20 tokens. Examples
                    ///         of some token types that may not be properly supported by this contract include, but are
                    ///         not limited to: tokens with transfer fees, rebasing tokens, and tokens with blocklists.
                    contract L1StandardBridge is StandardBridge, ISemver {
                        /// @custom:legacy
                        /// @notice Emitted whenever a deposit of ETH from L1 into L2 is initiated.
                        /// @param from      Address of the depositor.
                        /// @param to        Address of the recipient on L2.
                        /// @param amount    Amount of ETH deposited.
                        /// @param extraData Extra data attached to the deposit.
                        event ETHDepositInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData);
                        /// @custom:legacy
                        /// @notice Emitted whenever a withdrawal of ETH from L2 to L1 is finalized.
                        /// @param from      Address of the withdrawer.
                        /// @param to        Address of the recipient on L1.
                        /// @param amount    Amount of ETH withdrawn.
                        /// @param extraData Extra data attached to the withdrawal.
                        event ETHWithdrawalFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData);
                        /// @custom:legacy
                        /// @notice Emitted whenever an ERC20 deposit is initiated.
                        /// @param l1Token   Address of the token on L1.
                        /// @param l2Token   Address of the corresponding token on L2.
                        /// @param from      Address of the depositor.
                        /// @param to        Address of the recipient on L2.
                        /// @param amount    Amount of the ERC20 deposited.
                        /// @param extraData Extra data attached to the deposit.
                        event ERC20DepositInitiated(
                            address indexed l1Token,
                            address indexed l2Token,
                            address indexed from,
                            address to,
                            uint256 amount,
                            bytes extraData
                        );
                        /// @custom:legacy
                        /// @notice Emitted whenever an ERC20 withdrawal is finalized.
                        /// @param l1Token   Address of the token on L1.
                        /// @param l2Token   Address of the corresponding token on L2.
                        /// @param from      Address of the withdrawer.
                        /// @param to        Address of the recipient on L1.
                        /// @param amount    Amount of the ERC20 withdrawn.
                        /// @param extraData Extra data attached to the withdrawal.
                        event ERC20WithdrawalFinalized(
                            address indexed l1Token,
                            address indexed l2Token,
                            address indexed from,
                            address to,
                            uint256 amount,
                            bytes extraData
                        );
                        /// @notice Semantic version.
                        /// @custom:semver 2.3.0
                        string public constant version = "2.3.0";
                        /// @notice Address of the SuperchainConfig contract.
                        ISuperchainConfig public superchainConfig;
                        /// @custom:legacy
                        /// @custom:spacer systemConfig
                        /// @notice Spacer taking up the legacy `systemConfig` slot.
                        address private spacer_51_0_20;
                        /// @notice Constructs the L1StandardBridge contract.
                        constructor() StandardBridge() {
                            _disableInitializers();
                        }
                        /// @notice Initializer.
                        /// @param _messenger        Contract for the CrossDomainMessenger on this network.
                        /// @param _superchainConfig Contract for the SuperchainConfig on this network.
                        function initialize(ICrossDomainMessenger _messenger, ISuperchainConfig _superchainConfig) external initializer {
                            superchainConfig = _superchainConfig;
                            __StandardBridge_init({
                                _messenger: _messenger,
                                _otherBridge: StandardBridge(payable(Predeploys.L2_STANDARD_BRIDGE))
                            });
                        }
                        /// @inheritdoc StandardBridge
                        function paused() public view override returns (bool) {
                            return superchainConfig.paused();
                        }
                        /// @notice Allows EOAs to bridge ETH by sending directly to the bridge.
                        receive() external payable override onlyEOA {
                            _initiateETHDeposit(msg.sender, msg.sender, RECEIVE_DEFAULT_GAS_LIMIT, bytes(""));
                        }
                        /// @custom:legacy
                        /// @notice Deposits some amount of ETH into the sender's account on L2.
                        /// @param _minGasLimit Minimum gas limit for the deposit message on L2.
                        /// @param _extraData   Optional data to forward to L2.
                        ///                     Data supplied here will not be used to execute any code on L2 and is
                        ///                     only emitted as extra data for the convenience of off-chain tooling.
                        function depositETH(uint32 _minGasLimit, bytes calldata _extraData) external payable onlyEOA {
                            _initiateETHDeposit(msg.sender, msg.sender, _minGasLimit, _extraData);
                        }
                        /// @custom:legacy
                        /// @notice Deposits some amount of ETH into a target account on L2.
                        ///         Note that if ETH is sent to a contract on L2 and the call fails, then that ETH will
                        ///         be locked in the L2StandardBridge. ETH may be recoverable if the call can be
                        ///         successfully replayed by increasing the amount of gas supplied to the call. If the
                        ///         call will fail for any amount of gas, then the ETH will be locked permanently.
                        /// @param _to          Address of the recipient on L2.
                        /// @param _minGasLimit Minimum gas limit for the deposit message on L2.
                        /// @param _extraData   Optional data to forward to L2.
                        ///                     Data supplied here will not be used to execute any code on L2 and is
                        ///                     only emitted as extra data for the convenience of off-chain tooling.
                        function depositETHTo(address _to, uint32 _minGasLimit, bytes calldata _extraData) external payable {
                            _initiateETHDeposit(msg.sender, _to, _minGasLimit, _extraData);
                        }
                        /// @custom:legacy
                        /// @notice Deposits some amount of ERC20 tokens into the sender's account on L2.
                        /// @param _l1Token     Address of the L1 token being deposited.
                        /// @param _l2Token     Address of the corresponding token on L2.
                        /// @param _amount      Amount of the ERC20 to deposit.
                        /// @param _minGasLimit Minimum gas limit for the deposit message on L2.
                        /// @param _extraData   Optional data to forward to L2.
                        ///                     Data supplied here will not be used to execute any code on L2 and is
                        ///                     only emitted as extra data for the convenience of off-chain tooling.
                        function depositERC20(
                            address _l1Token,
                            address _l2Token,
                            uint256 _amount,
                            uint32 _minGasLimit,
                            bytes calldata _extraData
                        )
                            external
                            virtual
                            onlyEOA
                        {
                            _initiateERC20Deposit(_l1Token, _l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _extraData);
                        }
                        /// @custom:legacy
                        /// @notice Deposits some amount of ERC20 tokens into a target account on L2.
                        /// @param _l1Token     Address of the L1 token being deposited.
                        /// @param _l2Token     Address of the corresponding token on L2.
                        /// @param _to          Address of the recipient on L2.
                        /// @param _amount      Amount of the ERC20 to deposit.
                        /// @param _minGasLimit Minimum gas limit for the deposit message on L2.
                        /// @param _extraData   Optional data to forward to L2.
                        ///                     Data supplied here will not be used to execute any code on L2 and is
                        ///                     only emitted as extra data for the convenience of off-chain tooling.
                        function depositERC20To(
                            address _l1Token,
                            address _l2Token,
                            address _to,
                            uint256 _amount,
                            uint32 _minGasLimit,
                            bytes calldata _extraData
                        )
                            external
                            virtual
                        {
                            _initiateERC20Deposit(_l1Token, _l2Token, msg.sender, _to, _amount, _minGasLimit, _extraData);
                        }
                        /// @custom:legacy
                        /// @notice Finalizes a withdrawal of ETH from L2.
                        /// @param _from      Address of the withdrawer on L2.
                        /// @param _to        Address of the recipient on L1.
                        /// @param _amount    Amount of ETH to withdraw.
                        /// @param _extraData Optional data forwarded from L2.
                        function finalizeETHWithdrawal(
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes calldata _extraData
                        )
                            external
                            payable
                        {
                            finalizeBridgeETH(_from, _to, _amount, _extraData);
                        }
                        /// @custom:legacy
                        /// @notice Finalizes a withdrawal of ERC20 tokens from L2.
                        /// @param _l1Token   Address of the token on L1.
                        /// @param _l2Token   Address of the corresponding token on L2.
                        /// @param _from      Address of the withdrawer on L2.
                        /// @param _to        Address of the recipient on L1.
                        /// @param _amount    Amount of the ERC20 to withdraw.
                        /// @param _extraData Optional data forwarded from L2.
                        function finalizeERC20Withdrawal(
                            address _l1Token,
                            address _l2Token,
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes calldata _extraData
                        )
                            external
                        {
                            finalizeBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _extraData);
                        }
                        /// @custom:legacy
                        /// @notice Retrieves the access of the corresponding L2 bridge contract.
                        /// @return Address of the corresponding L2 bridge contract.
                        function l2TokenBridge() external view returns (address) {
                            return address(otherBridge);
                        }
                        /// @notice Internal function for initiating an ETH deposit.
                        /// @param _from        Address of the sender on L1.
                        /// @param _to          Address of the recipient on L2.
                        /// @param _minGasLimit Minimum gas limit for the deposit message on L2.
                        /// @param _extraData   Optional data to forward to L2.
                        function _initiateETHDeposit(address _from, address _to, uint32 _minGasLimit, bytes memory _extraData) internal {
                            _initiateBridgeETH(_from, _to, msg.value, _minGasLimit, _extraData);
                        }
                        /// @notice Internal function for initiating an ERC20 deposit.
                        /// @param _l1Token     Address of the L1 token being deposited.
                        /// @param _l2Token     Address of the corresponding token on L2.
                        /// @param _from        Address of the sender on L1.
                        /// @param _to          Address of the recipient on L2.
                        /// @param _amount      Amount of the ERC20 to deposit.
                        /// @param _minGasLimit Minimum gas limit for the deposit message on L2.
                        /// @param _extraData   Optional data to forward to L2.
                        function _initiateERC20Deposit(
                            address _l1Token,
                            address _l2Token,
                            address _from,
                            address _to,
                            uint256 _amount,
                            uint32 _minGasLimit,
                            bytes memory _extraData
                        )
                            internal
                        {
                            _initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _extraData);
                        }
                        /// @inheritdoc StandardBridge
                        /// @notice Emits the legacy ETHDepositInitiated event followed by the ETHBridgeInitiated event.
                        ///         This is necessary for backwards compatibility with the legacy bridge.
                        function _emitETHBridgeInitiated(
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            override
                        {
                            emit ETHDepositInitiated(_from, _to, _amount, _extraData);
                            super._emitETHBridgeInitiated(_from, _to, _amount, _extraData);
                        }
                        /// @inheritdoc StandardBridge
                        /// @notice Emits the legacy ERC20DepositInitiated event followed by the ERC20BridgeInitiated
                        ///         event. This is necessary for backwards compatibility with the legacy bridge.
                        function _emitETHBridgeFinalized(
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            override
                        {
                            emit ETHWithdrawalFinalized(_from, _to, _amount, _extraData);
                            super._emitETHBridgeFinalized(_from, _to, _amount, _extraData);
                        }
                        /// @inheritdoc StandardBridge
                        /// @notice Emits the legacy ERC20WithdrawalFinalized event followed by the ERC20BridgeFinalized
                        ///         event. This is necessary for backwards compatibility with the legacy bridge.
                        function _emitERC20BridgeInitiated(
                            address _localToken,
                            address _remoteToken,
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            override
                        {
                            emit ERC20DepositInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                            super._emitERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                        }
                        /// @inheritdoc StandardBridge
                        /// @notice Emits the legacy ERC20WithdrawalFinalized event followed by the ERC20BridgeFinalized
                        ///         event. This is necessary for backwards compatibility with the legacy bridge.
                        function _emitERC20BridgeFinalized(
                            address _localToken,
                            address _remoteToken,
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            override
                        {
                            emit ERC20WithdrawalFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                            super._emitERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    // Contracts
                    import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
                    // Libraries
                    import { ERC165Checker } from "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
                    import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
                    import { SafeCall } from "src/libraries/SafeCall.sol";
                    import { EOA } from "src/libraries/EOA.sol";
                    // Interfaces
                    import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
                    import { IOptimismMintableERC20 } from "interfaces/universal/IOptimismMintableERC20.sol";
                    import { ILegacyMintableERC20 } from "interfaces/legacy/ILegacyMintableERC20.sol";
                    import { ICrossDomainMessenger } from "interfaces/universal/ICrossDomainMessenger.sol";
                    /// @custom:upgradeable
                    /// @title StandardBridge
                    /// @notice StandardBridge is a base contract for the L1 and L2 standard ERC20 bridges. It handles
                    ///         the core bridging logic, including escrowing tokens that are native to the local chain
                    ///         and minting/burning tokens that are native to the remote chain.
                    abstract contract StandardBridge is Initializable {
                        using SafeERC20 for IERC20;
                        /// @notice The L2 gas limit set when eth is depoisited using the receive() function.
                        uint32 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 200_000;
                        /// @custom:legacy
                        /// @custom:spacer messenger
                        /// @notice Spacer for backwards compatibility.
                        bytes30 private spacer_0_2_30;
                        /// @custom:legacy
                        /// @custom:spacer l2TokenBridge
                        /// @notice Spacer for backwards compatibility.
                        address private spacer_1_0_20;
                        /// @notice Mapping that stores deposits for a given pair of local and remote tokens.
                        mapping(address => mapping(address => uint256)) public deposits;
                        /// @notice Messenger contract on this domain.
                        /// @custom:network-specific
                        ICrossDomainMessenger public messenger;
                        /// @notice Corresponding bridge on the other domain.
                        /// @custom:network-specific
                        StandardBridge public otherBridge;
                        /// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.
                        ///         A gap size of 45 was chosen here, so that the first slot used in a child contract
                        ///         would be a multiple of 50.
                        uint256[45] private __gap;
                        /// @notice Emitted when an ETH bridge is initiated to the other chain.
                        /// @param from      Address of the sender.
                        /// @param to        Address of the receiver.
                        /// @param amount    Amount of ETH sent.
                        /// @param extraData Extra data sent with the transaction.
                        event ETHBridgeInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData);
                        /// @notice Emitted when an ETH bridge is finalized on this chain.
                        /// @param from      Address of the sender.
                        /// @param to        Address of the receiver.
                        /// @param amount    Amount of ETH sent.
                        /// @param extraData Extra data sent with the transaction.
                        event ETHBridgeFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData);
                        /// @notice Emitted when an ERC20 bridge is initiated to the other chain.
                        /// @param localToken  Address of the ERC20 on this chain.
                        /// @param remoteToken Address of the ERC20 on the remote chain.
                        /// @param from        Address of the sender.
                        /// @param to          Address of the receiver.
                        /// @param amount      Amount of the ERC20 sent.
                        /// @param extraData   Extra data sent with the transaction.
                        event ERC20BridgeInitiated(
                            address indexed localToken,
                            address indexed remoteToken,
                            address indexed from,
                            address to,
                            uint256 amount,
                            bytes extraData
                        );
                        /// @notice Emitted when an ERC20 bridge is finalized on this chain.
                        /// @param localToken  Address of the ERC20 on this chain.
                        /// @param remoteToken Address of the ERC20 on the remote chain.
                        /// @param from        Address of the sender.
                        /// @param to          Address of the receiver.
                        /// @param amount      Amount of the ERC20 sent.
                        /// @param extraData   Extra data sent with the transaction.
                        event ERC20BridgeFinalized(
                            address indexed localToken,
                            address indexed remoteToken,
                            address indexed from,
                            address to,
                            uint256 amount,
                            bytes extraData
                        );
                        /// @notice Only allow EOAs to call the functions. Note that this is not safe against contracts
                        ///         calling code within their constructors, but also doesn't really matter since we're
                        ///         just trying to prevent users accidentally depositing with smart contract wallets.
                        modifier onlyEOA() {
                            require(EOA.isSenderEOA(), "StandardBridge: function can only be called from an EOA");
                            _;
                        }
                        /// @notice Ensures that the caller is a cross-chain message from the other bridge.
                        modifier onlyOtherBridge() {
                            require(
                                msg.sender == address(messenger) && messenger.xDomainMessageSender() == address(otherBridge),
                                "StandardBridge: function can only be called from the other bridge"
                            );
                            _;
                        }
                        /// @notice Initializer.
                        /// @param _messenger   Contract for CrossDomainMessenger on this network.
                        /// @param _otherBridge Contract for the other StandardBridge contract.
                        function __StandardBridge_init(
                            ICrossDomainMessenger _messenger,
                            StandardBridge _otherBridge
                        )
                            internal
                            onlyInitializing
                        {
                            messenger = _messenger;
                            otherBridge = _otherBridge;
                        }
                        /// @notice Allows EOAs to bridge ETH by sending directly to the bridge.
                        ///         Must be implemented by contracts that inherit.
                        receive() external payable virtual;
                        /// @notice Getter for messenger contract.
                        ///         Public getter is legacy and will be removed in the future. Use `messenger` instead.
                        /// @return Contract of the messenger on this domain.
                        /// @custom:legacy
                        function MESSENGER() external view returns (ICrossDomainMessenger) {
                            return messenger;
                        }
                        /// @notice Getter for the other bridge contract.
                        ///         Public getter is legacy and will be removed in the future. Use `otherBridge` instead.
                        /// @return Contract of the bridge on the other network.
                        /// @custom:legacy
                        function OTHER_BRIDGE() external view returns (StandardBridge) {
                            return otherBridge;
                        }
                        /// @notice This function should return true if the contract is paused.
                        ///         On L1 this function will check the SuperchainConfig for its paused status.
                        ///         On L2 this function should be a no-op.
                        /// @return Whether or not the contract is paused.
                        function paused() public view virtual returns (bool) {
                            return false;
                        }
                        /// @notice Sends ETH to the sender's address on the other chain.
                        /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
                        /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will
                        ///                     not be triggered with this data, but it will be emitted and can be used
                        ///                     to identify the transaction.
                        function bridgeETH(uint32 _minGasLimit, bytes calldata _extraData) public payable onlyEOA {
                            _initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _extraData);
                        }
                        /// @notice Sends ETH to a receiver's address on the other chain. Note that if ETH is sent to a
                        ///         smart contract and the call fails, the ETH will be temporarily locked in the
                        ///         StandardBridge on the other chain until the call is replayed. If the call cannot be
                        ///         replayed with any amount of gas (call always reverts), then the ETH will be
                        ///         permanently locked in the StandardBridge on the other chain. ETH will also
                        ///         be locked if the receiver is the other bridge, because finalizeBridgeETH will revert
                        ///         in that case.
                        /// @param _to          Address of the receiver.
                        /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
                        /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will
                        ///                     not be triggered with this data, but it will be emitted and can be used
                        ///                     to identify the transaction.
                        function bridgeETHTo(address _to, uint32 _minGasLimit, bytes calldata _extraData) public payable {
                            _initiateBridgeETH(msg.sender, _to, msg.value, _minGasLimit, _extraData);
                        }
                        /// @notice Sends ERC20 tokens to the sender's address on the other chain.
                        /// @param _localToken  Address of the ERC20 on this chain.
                        /// @param _remoteToken Address of the corresponding token on the remote chain.
                        /// @param _amount      Amount of local tokens to deposit.
                        /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
                        /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will
                        ///                     not be triggered with this data, but it will be emitted and can be used
                        ///                     to identify the transaction.
                        function bridgeERC20(
                            address _localToken,
                            address _remoteToken,
                            uint256 _amount,
                            uint32 _minGasLimit,
                            bytes calldata _extraData
                        )
                            public
                            virtual
                            onlyEOA
                        {
                            _initiateBridgeERC20(_localToken, _remoteToken, msg.sender, msg.sender, _amount, _minGasLimit, _extraData);
                        }
                        /// @notice Sends ERC20 tokens to a receiver's address on the other chain.
                        /// @param _localToken  Address of the ERC20 on this chain.
                        /// @param _remoteToken Address of the corresponding token on the remote chain.
                        /// @param _to          Address of the receiver.
                        /// @param _amount      Amount of local tokens to deposit.
                        /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
                        /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will
                        ///                     not be triggered with this data, but it will be emitted and can be used
                        ///                     to identify the transaction.
                        function bridgeERC20To(
                            address _localToken,
                            address _remoteToken,
                            address _to,
                            uint256 _amount,
                            uint32 _minGasLimit,
                            bytes calldata _extraData
                        )
                            public
                            virtual
                        {
                            _initiateBridgeERC20(_localToken, _remoteToken, msg.sender, _to, _amount, _minGasLimit, _extraData);
                        }
                        /// @notice Finalizes an ETH bridge on this chain. Can only be triggered by the other
                        ///         StandardBridge contract on the remote chain.
                        /// @param _from      Address of the sender.
                        /// @param _to        Address of the receiver.
                        /// @param _amount    Amount of ETH being bridged.
                        /// @param _extraData Extra data to be sent with the transaction. Note that the recipient will
                        ///                   not be triggered with this data, but it will be emitted and can be used
                        ///                   to identify the transaction.
                        function finalizeBridgeETH(
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes calldata _extraData
                        )
                            public
                            payable
                            onlyOtherBridge
                        {
                            require(paused() == false, "StandardBridge: paused");
                            require(msg.value == _amount, "StandardBridge: amount sent does not match amount required");
                            require(_to != address(this), "StandardBridge: cannot send to self");
                            require(_to != address(messenger), "StandardBridge: cannot send to messenger");
                            // Emit the correct events. By default this will be _amount, but child
                            // contracts may override this function in order to emit legacy events as well.
                            _emitETHBridgeFinalized(_from, _to, _amount, _extraData);
                            bool success = SafeCall.call(_to, gasleft(), _amount, hex"");
                            require(success, "StandardBridge: ETH transfer failed");
                        }
                        /// @notice Finalizes an ERC20 bridge on this chain. Can only be triggered by the other
                        ///         StandardBridge contract on the remote chain.
                        /// @param _localToken  Address of the ERC20 on this chain.
                        /// @param _remoteToken Address of the corresponding token on the remote chain.
                        /// @param _from        Address of the sender.
                        /// @param _to          Address of the receiver.
                        /// @param _amount      Amount of the ERC20 being bridged.
                        /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will
                        ///                     not be triggered with this data, but it will be emitted and can be used
                        ///                     to identify the transaction.
                        function finalizeBridgeERC20(
                            address _localToken,
                            address _remoteToken,
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes calldata _extraData
                        )
                            public
                            onlyOtherBridge
                        {
                            require(paused() == false, "StandardBridge: paused");
                            if (_isOptimismMintableERC20(_localToken)) {
                                require(
                                    _isCorrectTokenPair(_localToken, _remoteToken),
                                    "StandardBridge: wrong remote token for Optimism Mintable ERC20 local token"
                                );
                                IOptimismMintableERC20(_localToken).mint(_to, _amount);
                            } else {
                                deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] - _amount;
                                IERC20(_localToken).safeTransfer(_to, _amount);
                            }
                            // Emit the correct events. By default this will be ERC20BridgeFinalized, but child
                            // contracts may override this function in order to emit legacy events as well.
                            _emitERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                        }
                        /// @notice Initiates a bridge of ETH through the CrossDomainMessenger.
                        /// @param _from        Address of the sender.
                        /// @param _to          Address of the receiver.
                        /// @param _amount      Amount of ETH being bridged.
                        /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
                        /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will
                        ///                     not be triggered with this data, but it will be emitted and can be used
                        ///                     to identify the transaction.
                        function _initiateBridgeETH(
                            address _from,
                            address _to,
                            uint256 _amount,
                            uint32 _minGasLimit,
                            bytes memory _extraData
                        )
                            internal
                        {
                            require(msg.value == _amount, "StandardBridge: bridging ETH must include sufficient ETH value");
                            // Emit the correct events. By default this will be _amount, but child
                            // contracts may override this function in order to emit legacy events as well.
                            _emitETHBridgeInitiated(_from, _to, _amount, _extraData);
                            messenger.sendMessage{ value: _amount }({
                                _target: address(otherBridge),
                                _message: abi.encodeWithSelector(this.finalizeBridgeETH.selector, _from, _to, _amount, _extraData),
                                _minGasLimit: _minGasLimit
                            });
                        }
                        /// @notice Sends ERC20 tokens to a receiver's address on the other chain.
                        /// @param _localToken  Address of the ERC20 on this chain.
                        /// @param _remoteToken Address of the corresponding token on the remote chain.
                        /// @param _to          Address of the receiver.
                        /// @param _amount      Amount of local tokens to deposit.
                        /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.
                        /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will
                        ///                     not be triggered with this data, but it will be emitted and can be used
                        ///                     to identify the transaction.
                        function _initiateBridgeERC20(
                            address _localToken,
                            address _remoteToken,
                            address _from,
                            address _to,
                            uint256 _amount,
                            uint32 _minGasLimit,
                            bytes memory _extraData
                        )
                            internal
                        {
                            require(msg.value == 0, "StandardBridge: cannot send value");
                            if (_isOptimismMintableERC20(_localToken)) {
                                require(
                                    _isCorrectTokenPair(_localToken, _remoteToken),
                                    "StandardBridge: wrong remote token for Optimism Mintable ERC20 local token"
                                );
                                IOptimismMintableERC20(_localToken).burn(_from, _amount);
                            } else {
                                IERC20(_localToken).safeTransferFrom(_from, address(this), _amount);
                                deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] + _amount;
                            }
                            // Emit the correct events. By default this will be ERC20BridgeInitiated, but child
                            // contracts may override this function in order to emit legacy events as well.
                            _emitERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                            messenger.sendMessage({
                                _target: address(otherBridge),
                                _message: abi.encodeWithSelector(
                                    this.finalizeBridgeERC20.selector,
                                    // Because this call will be executed on the remote chain, we reverse the order of
                                    // the remote and local token addresses relative to their order in the
                                    // finalizeBridgeERC20 function.
                                    _remoteToken,
                                    _localToken,
                                    _from,
                                    _to,
                                    _amount,
                                    _extraData
                                ),
                                _minGasLimit: _minGasLimit
                            });
                        }
                        /// @notice Checks if a given address is an OptimismMintableERC20. Not perfect, but good enough.
                        ///         Just the way we like it.
                        /// @param _token Address of the token to check.
                        /// @return True if the token is an OptimismMintableERC20.
                        function _isOptimismMintableERC20(address _token) internal view returns (bool) {
                            return ERC165Checker.supportsInterface(_token, type(ILegacyMintableERC20).interfaceId)
                                || ERC165Checker.supportsInterface(_token, type(IOptimismMintableERC20).interfaceId);
                        }
                        /// @notice Checks if the "other token" is the correct pair token for the OptimismMintableERC20.
                        ///         Calls can be saved in the future by combining this logic with
                        ///         `_isOptimismMintableERC20`.
                        /// @param _mintableToken OptimismMintableERC20 to check against.
                        /// @param _otherToken    Pair token to check.
                        /// @return True if the other token is the correct pair token for the OptimismMintableERC20.
                        function _isCorrectTokenPair(address _mintableToken, address _otherToken) internal view returns (bool) {
                            if (ERC165Checker.supportsInterface(_mintableToken, type(ILegacyMintableERC20).interfaceId)) {
                                return _otherToken == ILegacyMintableERC20(_mintableToken).l1Token();
                            } else {
                                return _otherToken == IOptimismMintableERC20(_mintableToken).remoteToken();
                            }
                        }
                        /// @notice Emits the ETHBridgeInitiated event and if necessary the appropriate legacy event
                        ///         when an ETH bridge is finalized on this chain.
                        /// @param _from      Address of the sender.
                        /// @param _to        Address of the receiver.
                        /// @param _amount    Amount of ETH sent.
                        /// @param _extraData Extra data sent with the transaction.
                        function _emitETHBridgeInitiated(
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            virtual
                        {
                            emit ETHBridgeInitiated(_from, _to, _amount, _extraData);
                        }
                        /// @notice Emits the ETHBridgeFinalized and if necessary the appropriate legacy event when an
                        ///         ETH bridge is finalized on this chain.
                        /// @param _from      Address of the sender.
                        /// @param _to        Address of the receiver.
                        /// @param _amount    Amount of ETH sent.
                        /// @param _extraData Extra data sent with the transaction.
                        function _emitETHBridgeFinalized(
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            virtual
                        {
                            emit ETHBridgeFinalized(_from, _to, _amount, _extraData);
                        }
                        /// @notice Emits the ERC20BridgeInitiated event and if necessary the appropriate legacy
                        ///         event when an ERC20 bridge is initiated to the other chain.
                        /// @param _localToken  Address of the ERC20 on this chain.
                        /// @param _remoteToken Address of the ERC20 on the remote chain.
                        /// @param _from        Address of the sender.
                        /// @param _to          Address of the receiver.
                        /// @param _amount      Amount of the ERC20 sent.
                        /// @param _extraData   Extra data sent with the transaction.
                        function _emitERC20BridgeInitiated(
                            address _localToken,
                            address _remoteToken,
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            virtual
                        {
                            emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                        }
                        /// @notice Emits the ERC20BridgeFinalized event and if necessary the appropriate legacy
                        ///         event when an ERC20 bridge is initiated to the other chain.
                        /// @param _localToken  Address of the ERC20 on this chain.
                        /// @param _remoteToken Address of the ERC20 on the remote chain.
                        /// @param _from        Address of the sender.
                        /// @param _to          Address of the receiver.
                        /// @param _amount      Amount of the ERC20 sent.
                        /// @param _extraData   Extra data sent with the transaction.
                        function _emitERC20BridgeFinalized(
                            address _localToken,
                            address _remoteToken,
                            address _from,
                            address _to,
                            uint256 _amount,
                            bytes memory _extraData
                        )
                            internal
                            virtual
                        {
                            emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title Predeploys
                    /// @notice Contains constant addresses for protocol contracts that are pre-deployed to the L2 system.
                    //          This excludes the preinstalls (non-protocol contracts).
                    library Predeploys {
                        /// @notice Number of predeploy-namespace addresses reserved for protocol usage.
                        uint256 internal constant PREDEPLOY_COUNT = 2048;
                        /// @custom:legacy
                        /// @notice Address of the LegacyMessagePasser predeploy. Deprecate. Use the updated
                        ///         L2ToL1MessagePasser contract instead.
                        address internal constant LEGACY_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
                        /// @custom:legacy
                        /// @notice Address of the L1MessageSender predeploy. Deprecated. Use L2CrossDomainMessenger
                        ///         or access tx.origin (or msg.sender) in a L1 to L2 transaction instead.
                        ///         Not embedded into new OP-Stack chains.
                        address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
                        /// @custom:legacy
                        /// @notice Address of the DeployerWhitelist predeploy. No longer active.
                        address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
                        /// @notice Address of the canonical WETH contract.
                        address internal constant WETH = 0x4200000000000000000000000000000000000006;
                        /// @notice Address of the L2CrossDomainMessenger predeploy.
                        address internal constant L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007;
                        /// @notice Address of the GasPriceOracle predeploy. Includes fee information
                        ///         and helpers for computing the L1 portion of the transaction fee.
                        address internal constant GAS_PRICE_ORACLE = 0x420000000000000000000000000000000000000F;
                        /// @notice Address of the L2StandardBridge predeploy.
                        address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;
                        //// @notice Address of the SequencerFeeWallet predeploy.
                        address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
                        /// @notice Address of the OptimismMintableERC20Factory predeploy.
                        address internal constant OPTIMISM_MINTABLE_ERC20_FACTORY = 0x4200000000000000000000000000000000000012;
                        /// @custom:legacy
                        /// @notice Address of the L1BlockNumber predeploy. Deprecated. Use the L1Block predeploy
                        ///         instead, which exposes more information about the L1 state.
                        address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;
                        /// @notice Address of the L2ERC721Bridge predeploy.
                        address internal constant L2_ERC721_BRIDGE = 0x4200000000000000000000000000000000000014;
                        /// @notice Address of the L1Block predeploy.
                        address internal constant L1_BLOCK_ATTRIBUTES = 0x4200000000000000000000000000000000000015;
                        /// @notice Address of the L2ToL1MessagePasser predeploy.
                        address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000016;
                        /// @notice Address of the OptimismMintableERC721Factory predeploy.
                        address internal constant OPTIMISM_MINTABLE_ERC721_FACTORY = 0x4200000000000000000000000000000000000017;
                        /// @notice Address of the ProxyAdmin predeploy.
                        address internal constant PROXY_ADMIN = 0x4200000000000000000000000000000000000018;
                        /// @notice Address of the BaseFeeVault predeploy.
                        address internal constant BASE_FEE_VAULT = 0x4200000000000000000000000000000000000019;
                        /// @notice Address of the L1FeeVault predeploy.
                        address internal constant L1_FEE_VAULT = 0x420000000000000000000000000000000000001A;
                        /// @notice Address of the OperatorFeeVault predeploy.
                        address internal constant OPERATOR_FEE_VAULT = 0x420000000000000000000000000000000000001b;
                        /// @notice Address of the SchemaRegistry predeploy.
                        address internal constant SCHEMA_REGISTRY = 0x4200000000000000000000000000000000000020;
                        /// @notice Address of the EAS predeploy.
                        address internal constant EAS = 0x4200000000000000000000000000000000000021;
                        /// @notice Address of the GovernanceToken predeploy.
                        address internal constant GOVERNANCE_TOKEN = 0x4200000000000000000000000000000000000042;
                        /// @custom:legacy
                        /// @notice Address of the LegacyERC20ETH predeploy. Deprecated. Balances are migrated to the
                        ///         state trie as of the Bedrock upgrade. Contract has been locked and write functions
                        ///         can no longer be accessed.
                        address internal constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
                        /// @notice Address of the CrossL2Inbox predeploy.
                        address internal constant CROSS_L2_INBOX = 0x4200000000000000000000000000000000000022;
                        /// @notice Address of the L2ToL2CrossDomainMessenger predeploy.
                        address internal constant L2_TO_L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000023;
                        /// @notice Address of the SuperchainWETH predeploy.
                        address internal constant SUPERCHAIN_WETH = 0x4200000000000000000000000000000000000024;
                        /// @notice Address of the ETHLiquidity predeploy.
                        address internal constant ETH_LIQUIDITY = 0x4200000000000000000000000000000000000025;
                        /// @notice Address of the OptimismSuperchainERC20Factory predeploy.
                        address internal constant OPTIMISM_SUPERCHAIN_ERC20_FACTORY = 0x4200000000000000000000000000000000000026;
                        /// @notice Address of the OptimismSuperchainERC20Beacon predeploy.
                        address internal constant OPTIMISM_SUPERCHAIN_ERC20_BEACON = 0x4200000000000000000000000000000000000027;
                        // TODO: Precalculate the address of the implementation contract
                        /// @notice Arbitrary address of the OptimismSuperchainERC20 implementation contract.
                        address internal constant OPTIMISM_SUPERCHAIN_ERC20 = 0xB9415c6cA93bdC545D4c5177512FCC22EFa38F28;
                        /// @notice Address of the SuperchainTokenBridge predeploy.
                        address internal constant SUPERCHAIN_TOKEN_BRIDGE = 0x4200000000000000000000000000000000000028;
                        /// @notice Returns the name of the predeploy at the given address.
                        function getName(address _addr) internal pure returns (string memory out_) {
                            require(isPredeployNamespace(_addr), "Predeploys: address must be a predeploy");
                            if (_addr == LEGACY_MESSAGE_PASSER) return "LegacyMessagePasser";
                            if (_addr == L1_MESSAGE_SENDER) return "L1MessageSender";
                            if (_addr == DEPLOYER_WHITELIST) return "DeployerWhitelist";
                            if (_addr == WETH) return "WETH";
                            if (_addr == L2_CROSS_DOMAIN_MESSENGER) return "L2CrossDomainMessenger";
                            if (_addr == GAS_PRICE_ORACLE) return "GasPriceOracle";
                            if (_addr == L2_STANDARD_BRIDGE) return "L2StandardBridge";
                            if (_addr == SEQUENCER_FEE_WALLET) return "SequencerFeeVault";
                            if (_addr == OPTIMISM_MINTABLE_ERC20_FACTORY) return "OptimismMintableERC20Factory";
                            if (_addr == L1_BLOCK_NUMBER) return "L1BlockNumber";
                            if (_addr == L2_ERC721_BRIDGE) return "L2ERC721Bridge";
                            if (_addr == L1_BLOCK_ATTRIBUTES) return "L1Block";
                            if (_addr == L2_TO_L1_MESSAGE_PASSER) return "L2ToL1MessagePasser";
                            if (_addr == OPTIMISM_MINTABLE_ERC721_FACTORY) return "OptimismMintableERC721Factory";
                            if (_addr == PROXY_ADMIN) return "ProxyAdmin";
                            if (_addr == BASE_FEE_VAULT) return "BaseFeeVault";
                            if (_addr == L1_FEE_VAULT) return "L1FeeVault";
                            if (_addr == OPERATOR_FEE_VAULT) return "OperatorFeeVault";
                            if (_addr == SCHEMA_REGISTRY) return "SchemaRegistry";
                            if (_addr == EAS) return "EAS";
                            if (_addr == GOVERNANCE_TOKEN) return "GovernanceToken";
                            if (_addr == LEGACY_ERC20_ETH) return "LegacyERC20ETH";
                            if (_addr == CROSS_L2_INBOX) return "CrossL2Inbox";
                            if (_addr == L2_TO_L2_CROSS_DOMAIN_MESSENGER) return "L2ToL2CrossDomainMessenger";
                            if (_addr == SUPERCHAIN_WETH) return "SuperchainWETH";
                            if (_addr == ETH_LIQUIDITY) return "ETHLiquidity";
                            if (_addr == OPTIMISM_SUPERCHAIN_ERC20_FACTORY) return "OptimismSuperchainERC20Factory";
                            if (_addr == OPTIMISM_SUPERCHAIN_ERC20_BEACON) return "OptimismSuperchainERC20Beacon";
                            if (_addr == SUPERCHAIN_TOKEN_BRIDGE) return "SuperchainTokenBridge";
                            revert("Predeploys: unnamed predeploy");
                        }
                        /// @notice Returns true if the predeploy is not proxied.
                        function notProxied(address _addr) internal pure returns (bool) {
                            return _addr == GOVERNANCE_TOKEN || _addr == WETH;
                        }
                        /// @notice Returns true if the address is a defined predeploy that is embedded into new OP-Stack chains.
                        function isSupportedPredeploy(address _addr, bool _useInterop) internal pure returns (bool) {
                            return _addr == LEGACY_MESSAGE_PASSER || _addr == DEPLOYER_WHITELIST || _addr == WETH
                                || _addr == L2_CROSS_DOMAIN_MESSENGER || _addr == GAS_PRICE_ORACLE || _addr == L2_STANDARD_BRIDGE
                                || _addr == SEQUENCER_FEE_WALLET || _addr == OPTIMISM_MINTABLE_ERC20_FACTORY || _addr == L1_BLOCK_NUMBER
                                || _addr == L2_ERC721_BRIDGE || _addr == L1_BLOCK_ATTRIBUTES || _addr == L2_TO_L1_MESSAGE_PASSER
                                || _addr == OPTIMISM_MINTABLE_ERC721_FACTORY || _addr == PROXY_ADMIN || _addr == BASE_FEE_VAULT
                                || _addr == L1_FEE_VAULT || _addr == OPERATOR_FEE_VAULT || _addr == SCHEMA_REGISTRY || _addr == EAS
                                || _addr == GOVERNANCE_TOKEN || (_useInterop && _addr == CROSS_L2_INBOX)
                                || (_useInterop && _addr == L2_TO_L2_CROSS_DOMAIN_MESSENGER) || (_useInterop && _addr == SUPERCHAIN_WETH)
                                || (_useInterop && _addr == ETH_LIQUIDITY) || (_useInterop && _addr == SUPERCHAIN_TOKEN_BRIDGE);
                        }
                        function isPredeployNamespace(address _addr) internal pure returns (bool) {
                            return uint160(_addr) >> 11 == uint160(0x4200000000000000000000000000000000000000) >> 11;
                        }
                        /// @notice Function to compute the expected address of the predeploy implementation
                        ///         in the genesis state.
                        function predeployToCodeNamespace(address _addr) internal pure returns (address) {
                            require(
                                isPredeployNamespace(_addr), "Predeploys: can only derive code-namespace address for predeploy addresses"
                            );
                            return address(
                                uint160(uint256(uint160(_addr)) & 0xffff | uint256(uint160(0xc0D3C0d3C0d3C0D3c0d3C0d3c0D3C0d3c0d30000)))
                            );
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title ISemver
                    /// @notice ISemver is a simple contract for ensuring that contracts are
                    ///         versioned using semantic versioning.
                    interface ISemver {
                        /// @notice Getter for the semantic version of the contract. This is not
                        ///         meant to be used onchain but instead meant to be used by offchain
                        ///         tooling.
                        /// @return Semver contract version as a string.
                        function version() external view returns (string memory);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface ICrossDomainMessenger {
                        event FailedRelayedMessage(bytes32 indexed msgHash);
                        event Initialized(uint8 version);
                        event RelayedMessage(bytes32 indexed msgHash);
                        event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit);
                        event SentMessageExtension1(address indexed sender, uint256 value);
                        function MESSAGE_VERSION() external view returns (uint16);
                        function MIN_GAS_CALLDATA_OVERHEAD() external view returns (uint64);
                        function MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR() external view returns (uint64);
                        function MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR() external view returns (uint64);
                        function OTHER_MESSENGER() external view returns (ICrossDomainMessenger);
                        function RELAY_CALL_OVERHEAD() external view returns (uint64);
                        function RELAY_CONSTANT_OVERHEAD() external view returns (uint64);
                        function RELAY_GAS_CHECK_BUFFER() external view returns (uint64);
                        function RELAY_RESERVED_GAS() external view returns (uint64);
                        function TX_BASE_GAS() external view returns (uint64);
                        function FLOOR_CALLDATA_OVERHEAD() external view returns (uint64);
                        function ENCODING_OVERHEAD() external view returns (uint64);
                        function baseGas(bytes memory _message, uint32 _minGasLimit) external pure returns (uint64);
                        function failedMessages(bytes32) external view returns (bool);
                        function messageNonce() external view returns (uint256);
                        function otherMessenger() external view returns (ICrossDomainMessenger);
                        function paused() external view returns (bool);
                        function relayMessage(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _minGasLimit,
                            bytes memory _message
                        )
                            external
                            payable;
                        function sendMessage(address _target, bytes memory _message, uint32 _minGasLimit) external payable;
                        function successfulMessages(bytes32) external view returns (bool);
                        function xDomainMessageSender() external view returns (address);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface ISuperchainConfig {
                        enum UpdateType {
                            GUARDIAN
                        }
                        event ConfigUpdate(UpdateType indexed updateType, bytes data);
                        event Initialized(uint8 version);
                        event Paused(string identifier);
                        event Unpaused();
                        function GUARDIAN_SLOT() external view returns (bytes32);
                        function PAUSED_SLOT() external view returns (bytes32);
                        function guardian() external view returns (address guardian_);
                        function initialize(address _guardian, bool _paused) external;
                        function pause(string memory _identifier) external;
                        function paused() external view returns (bool paused_);
                        function unpause() external;
                        function version() external view returns (string memory);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
                    pragma solidity ^0.8.2;
                    import "../../utils/Address.sol";
                    /**
                     * @dev 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]
                     * ```
                     * 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]
                     * ```
                     * /// @custom:oz-upgrades-unsafe-allow constructor
                     * constructor() {
                     *     _disableInitializers();
                     * }
                     * ```
                     * ====
                     */
                    abstract contract Initializable {
                        /**
                         * @dev Indicates that the contract has been initialized.
                         * @custom:oz-retyped-from bool
                         */
                        uint8 private _initialized;
                        /**
                         * @dev Indicates that the contract is in the process of being initialized.
                         */
                        bool private _initializing;
                        /**
                         * @dev Triggered when the contract has been initialized or reinitialized.
                         */
                        event Initialized(uint8 version);
                        /**
                         * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
                         * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
                         */
                        modifier initializer() {
                            bool isTopLevelCall = !_initializing;
                            require(
                                (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
                                "Initializable: contract is already initialized"
                            );
                            _initialized = 1;
                            if (isTopLevelCall) {
                                _initializing = true;
                            }
                            _;
                            if (isTopLevelCall) {
                                _initializing = false;
                                emit Initialized(1);
                            }
                        }
                        /**
                         * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
                         * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
                         * used to initialize parent contracts.
                         *
                         * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
                         * initialization step. This is essential to configure modules that are added through upgrades and that require
                         * initialization.
                         *
                         * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
                         * a contract, executing them in the right order is up to the developer or operator.
                         */
                        modifier reinitializer(uint8 version) {
                            require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                            _initialized = version;
                            _initializing = true;
                            _;
                            _initializing = false;
                            emit Initialized(version);
                        }
                        /**
                         * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
                         * {initializer} and {reinitializer} modifiers, directly or indirectly.
                         */
                        modifier onlyInitializing() {
                            require(_initializing, "Initializable: contract is not initializing");
                            _;
                        }
                        /**
                         * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
                         * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
                         * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
                         * through proxies.
                         */
                        function _disableInitializers() internal virtual {
                            require(!_initializing, "Initializable: contract is initializing");
                            if (_initialized < type(uint8).max) {
                                _initialized = type(uint8).max;
                                emit Initialized(type(uint8).max);
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.2) (utils/introspection/ERC165Checker.sol)
                    pragma solidity ^0.8.0;
                    import "./IERC165.sol";
                    /**
                     * @dev Library used to query support of an interface declared via {IERC165}.
                     *
                     * Note that these functions return the actual result of the query: they do not
                     * `revert` if an interface is not supported. It is up to the caller to decide
                     * what to do in these cases.
                     */
                    library ERC165Checker {
                        // As per the EIP-165 spec, no interface should ever match 0xffffffff
                        bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;
                        /**
                         * @dev Returns true if `account` supports the {IERC165} interface,
                         */
                        function supportsERC165(address account) internal view returns (bool) {
                            // Any contract that implements ERC165 must explicitly indicate support of
                            // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
                            return
                                _supportsERC165Interface(account, type(IERC165).interfaceId) &&
                                !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);
                        }
                        /**
                         * @dev Returns true if `account` supports the interface defined by
                         * `interfaceId`. Support for {IERC165} itself is queried automatically.
                         *
                         * See {IERC165-supportsInterface}.
                         */
                        function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
                            // query support of both ERC165 as per the spec and support of _interfaceId
                            return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);
                        }
                        /**
                         * @dev Returns a boolean array where each value corresponds to the
                         * interfaces passed in and whether they're supported or not. This allows
                         * you to batch check interfaces for a contract where your expectation
                         * is that some interfaces may not be supported.
                         *
                         * See {IERC165-supportsInterface}.
                         *
                         * _Available since v3.4._
                         */
                        function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
                            internal
                            view
                            returns (bool[] memory)
                        {
                            // an array of booleans corresponding to interfaceIds and whether they're supported or not
                            bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);
                            // query support of ERC165 itself
                            if (supportsERC165(account)) {
                                // query support of each interface in interfaceIds
                                for (uint256 i = 0; i < interfaceIds.length; i++) {
                                    interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);
                                }
                            }
                            return interfaceIdsSupported;
                        }
                        /**
                         * @dev Returns true if `account` supports all the interfaces defined in
                         * `interfaceIds`. Support for {IERC165} itself is queried automatically.
                         *
                         * Batch-querying can lead to gas savings by skipping repeated checks for
                         * {IERC165} support.
                         *
                         * See {IERC165-supportsInterface}.
                         */
                        function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
                            // query support of ERC165 itself
                            if (!supportsERC165(account)) {
                                return false;
                            }
                            // query support of each interface in _interfaceIds
                            for (uint256 i = 0; i < interfaceIds.length; i++) {
                                if (!_supportsERC165Interface(account, interfaceIds[i])) {
                                    return false;
                                }
                            }
                            // all interfaces supported
                            return true;
                        }
                        /**
                         * @notice Query if a contract implements an interface, does not check ERC165 support
                         * @param account The address of the contract to query for support of an interface
                         * @param interfaceId The interface identifier, as specified in ERC-165
                         * @return true if the contract at account indicates support of the interface with
                         * identifier interfaceId, false otherwise
                         * @dev Assumes that account contains a contract that supports ERC165, otherwise
                         * the behavior of this method is undefined. This precondition can be checked
                         * with {supportsERC165}.
                         * Interface identification is specified in ERC-165.
                         */
                        function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {
                            // prepare call
                            bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);
                            // perform static call
                            bool success;
                            uint256 returnSize;
                            uint256 returnValue;
                            assembly {
                                success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
                                returnSize := returndatasize()
                                returnValue := mload(0x00)
                            }
                            return success && returnSize >= 0x20 && returnValue > 0;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
                    pragma solidity ^0.8.0;
                    import "../IERC20.sol";
                    import "../extensions/draft-IERC20Permit.sol";
                    import "../../../utils/Address.sol";
                    /**
                     * @title SafeERC20
                     * @dev 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.
                     */
                    library SafeERC20 {
                        using Address for address;
                        function safeTransfer(
                            IERC20 token,
                            address to,
                            uint256 value
                        ) internal {
                            _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
                        }
                        function safeTransferFrom(
                            IERC20 token,
                            address from,
                            address to,
                            uint256 value
                        ) internal {
                            _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
                        }
                        /**
                         * @dev Deprecated. This function has issues similar to the ones found in
                         * {IERC20-approve}, and its usage is discouraged.
                         *
                         * Whenever possible, use {safeIncreaseAllowance} and
                         * {safeDecreaseAllowance} instead.
                         */
                        function safeApprove(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            // safeApprove should only be called when setting an initial allowance,
                            // or when resetting it to zero. To increase and decrease it, use
                            // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                            require(
                                (value == 0) || (token.allowance(address(this), spender) == 0),
                                "SafeERC20: approve from non-zero to non-zero allowance"
                            );
                            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
                        }
                        function safeIncreaseAllowance(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            uint256 newAllowance = token.allowance(address(this), spender) + value;
                            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                        }
                        function safeDecreaseAllowance(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            unchecked {
                                uint256 oldAllowance = token.allowance(address(this), spender);
                                require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
                                uint256 newAllowance = oldAllowance - value;
                                _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                            }
                        }
                        function safePermit(
                            IERC20Permit token,
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            uint256 nonceBefore = token.nonces(owner);
                            token.permit(owner, spender, value, deadline, v, r, s);
                            uint256 nonceAfter = token.nonces(owner);
                            require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
                        }
                        /**
                         * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
                         * on the return value: the return value is optional (but if data is returned, it must not be false).
                         * @param token The token targeted by the call.
                         * @param data The call data (encoded using abi.encode or one of its variants).
                         */
                        function _callOptionalReturn(IERC20 token, bytes memory data) private {
                            // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                            // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                            // the target address contains contract code and also asserts for success in the low-level call.
                            bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
                            if (returndata.length > 0) {
                                // Return data is optional
                                require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title SafeCall
                    /// @notice Perform low level safe calls
                    library SafeCall {
                        /// @notice Performs a low level call without copying any returndata.
                        /// @dev Passes no calldata to the call context.
                        /// @param _target   Address to call
                        /// @param _gas      Amount of gas to pass to the call
                        /// @param _value    Amount of value to pass to the call
                        function send(address _target, uint256 _gas, uint256 _value) internal returns (bool success_) {
                            assembly {
                                success_ :=
                                    call(
                                        _gas, // gas
                                        _target, // recipient
                                        _value, // ether value
                                        0, // inloc
                                        0, // inlen
                                        0, // outloc
                                        0 // outlen
                                    )
                            }
                        }
                        /// @notice Perform a low level call with all gas without copying any returndata
                        /// @param _target   Address to call
                        /// @param _value    Amount of value to pass to the call
                        function send(address _target, uint256 _value) internal returns (bool success_) {
                            success_ = send(_target, gasleft(), _value);
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _gas      Amount of gas to pass to the call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function call(
                            address _target,
                            uint256 _gas,
                            uint256 _value,
                            bytes memory _calldata
                        )
                            internal
                            returns (bool success_)
                        {
                            assembly {
                                success_ :=
                                    call(
                                        _gas, // gas
                                        _target, // recipient
                                        _value, // ether value
                                        add(_calldata, 32), // inloc
                                        mload(_calldata), // inlen
                                        0, // outloc
                                        0 // outlen
                                    )
                            }
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function call(address _target, uint256 _value, bytes memory _calldata) internal returns (bool success_) {
                            success_ = call({ _target: _target, _gas: gasleft(), _value: _value, _calldata: _calldata });
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _calldata Calldata to pass to the call
                        function call(address _target, bytes memory _calldata) internal returns (bool success_) {
                            success_ = call({ _target: _target, _gas: gasleft(), _value: 0, _calldata: _calldata });
                        }
                        /// @notice Helper function to determine if there is sufficient gas remaining within the context
                        ///         to guarantee that the minimum gas requirement for a call will be met as well as
                        ///         optionally reserving a specified amount of gas for after the call has concluded.
                        /// @param _minGas      The minimum amount of gas that may be passed to the target context.
                        /// @param _reservedGas Optional amount of gas to reserve for the caller after the execution
                        ///                     of the target context.
                        /// @return `true` if there is enough gas remaining to safely supply `_minGas` to the target
                        ///         context as well as reserve `_reservedGas` for the caller after the execution of
                        ///         the target context.
                        /// @dev !!!!! FOOTGUN ALERT !!!!!
                        ///      1.) The 40_000 base buffer is to account for the worst case of the dynamic cost of the
                        ///          `CALL` opcode's `address_access_cost`, `positive_value_cost`, and
                        ///          `value_to_empty_account_cost` factors with an added buffer of 5,700 gas. It is
                        ///          still possible to self-rekt by initiating a withdrawal with a minimum gas limit
                        ///          that does not account for the `memory_expansion_cost` & `code_execution_cost`
                        ///          factors of the dynamic cost of the `CALL` opcode.
                        ///      2.) This function should *directly* precede the external call if possible. There is an
                        ///          added buffer to account for gas consumed between this check and the call, but it
                        ///          is only 5,700 gas.
                        ///      3.) Because EIP-150 ensures that a maximum of 63/64ths of the remaining gas in the call
                        ///          frame may be passed to a subcontext, we need to ensure that the gas will not be
                        ///          truncated.
                        ///      4.) Use wisely. This function is not a silver bullet.
                        function hasMinGas(uint256 _minGas, uint256 _reservedGas) internal view returns (bool) {
                            bool _hasMinGas;
                            assembly {
                                // Equation: gas × 63 ≥ minGas × 64 + 63(40_000 + reservedGas)
                                _hasMinGas := iszero(lt(mul(gas(), 63), add(mul(_minGas, 64), mul(add(40000, _reservedGas), 63))))
                            }
                            return _hasMinGas;
                        }
                        /// @notice Perform a low level call without copying any returndata. This function
                        ///         will revert if the call cannot be performed with the specified minimum
                        ///         gas.
                        /// @param _target   Address to call
                        /// @param _minGas   The minimum amount of gas that may be passed to the call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function callWithMinGas(
                            address _target,
                            uint256 _minGas,
                            uint256 _value,
                            bytes memory _calldata
                        )
                            internal
                            returns (bool)
                        {
                            bool _success;
                            bool _hasMinGas = hasMinGas(_minGas, 0);
                            assembly {
                                // Assertion: gasleft() >= (_minGas * 64) / 63 + 40_000
                                if iszero(_hasMinGas) {
                                    // Store the "Error(string)" selector in scratch space.
                                    mstore(0, 0x08c379a0)
                                    // Store the pointer to the string length in scratch space.
                                    mstore(32, 32)
                                    // Store the string.
                                    //
                                    // SAFETY:
                                    // - We pad the beginning of the string with two zero bytes as well as the
                                    // length (24) to ensure that we override the free memory pointer at offset
                                    // 0x40. This is necessary because the free memory pointer is likely to
                                    // be greater than 1 byte when this function is called, but it is incredibly
                                    // unlikely that it will be greater than 3 bytes. As for the data within
                                    // 0x60, it is ensured that it is 0 due to 0x60 being the zero offset.
                                    // - It's fine to clobber the free memory pointer, we're reverting.
                                    mstore(88, 0x0000185361666543616c6c3a204e6f7420656e6f75676820676173)
                                    // Revert with 'Error("SafeCall: Not enough gas")'
                                    revert(28, 100)
                                }
                                // The call will be supplied at least ((_minGas * 64) / 63) gas due to the
                                // above assertion. This ensures that, in all circumstances (except for when the
                                // `_minGas` does not account for the `memory_expansion_cost` and `code_execution_cost`
                                // factors of the dynamic cost of the `CALL` opcode), the call will receive at least
                                // the minimum amount of gas specified.
                                _success :=
                                    call(
                                        gas(), // gas
                                        _target, // recipient
                                        _value, // ether value
                                        add(_calldata, 32), // inloc
                                        mload(_calldata), // inlen
                                        0x00, // outloc
                                        0x00 // outlen
                                    )
                            }
                            return _success;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title EOA
                    /// @notice A library for detecting if an address is an EOA.
                    library EOA {
                        /// @notice Returns true if sender address is an EOA.
                        /// @return isEOA_ True if the sender address is an EOA.
                        function isSenderEOA() internal view returns (bool isEOA_) {
                            if (msg.sender == tx.origin) {
                                isEOA_ = true;
                            } else if (address(msg.sender).code.length == 23) {
                                // If the sender is not the origin, check for 7702 delegated EOAs.
                                assembly {
                                    let ptr := mload(0x40)
                                    mstore(0x40, add(ptr, 0x20))
                                    extcodecopy(caller(), ptr, 0, 0x20)
                                    isEOA_ := eq(shr(232, mload(ptr)), 0xEF0100)
                                }
                            } else {
                                // If more or less than 23 bytes of code, not a 7702 delegated EOA.
                                isEOA_ = false;
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev Interface of the ERC20 standard as defined in the EIP.
                     */
                    interface IERC20 {
                        /**
                         * @dev Emitted when `value` tokens are moved from one account (`from`) to
                         * another (`to`).
                         *
                         * Note that `value` may be zero.
                         */
                        event Transfer(address indexed from, address indexed to, uint256 value);
                        /**
                         * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                         * a call to {approve}. `value` is the new allowance.
                         */
                        event Approval(address indexed owner, address indexed spender, uint256 value);
                        /**
                         * @dev Returns the amount of tokens in existence.
                         */
                        function totalSupply() external view returns (uint256);
                        /**
                         * @dev Returns the amount of tokens owned by `account`.
                         */
                        function balanceOf(address account) external view returns (uint256);
                        /**
                         * @dev Moves `amount` tokens from the caller's account to `to`.
                         *
                         * Returns a boolean value indicating whether the operation succeeded.
                         *
                         * Emits a {Transfer} event.
                         */
                        function transfer(address to, uint256 amount) external returns (bool);
                        /**
                         * @dev 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.
                         */
                        function allowance(address owner, address spender) external view returns (uint256);
                        /**
                         * @dev 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.
                         */
                        function approve(address spender, uint256 amount) external returns (bool);
                        /**
                         * @dev 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.
                         */
                        function transferFrom(
                            address from,
                            address to,
                            uint256 amount
                        ) external returns (bool);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
                    /// @title IOptimismMintableERC20
                    /// @notice This interface is available on the OptimismMintableERC20 contract.
                    ///         We declare it as a separate interface so that it can be used in
                    ///         custom implementations of OptimismMintableERC20.
                    interface IOptimismMintableERC20 is IERC165 {
                        function remoteToken() external view returns (address);
                        function bridge() external returns (address);
                        function mint(address _to, uint256 _amount) external;
                        function burn(address _from, uint256 _amount) external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IERC165 } from "@openzeppelin/contracts/utils/introspection/IERC165.sol";
                    /// @custom:legacy
                    /// @title ILegacyMintableERC20
                    /// @notice This interface was available on the legacy L2StandardERC20 contract.
                    ///         It remains available on the OptimismMintableERC20 contract for
                    ///         backwards compatibility.
                    interface ILegacyMintableERC20 is IERC165 {
                        function l1Token() external view returns (address);
                        function mint(address _to, uint256 _amount) external;
                        function burn(address _from, uint256 _amount) external;
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
                    pragma solidity ^0.8.1;
                    /**
                     * @dev Collection of functions related to the address type
                     */
                    library Address {
                        /**
                         * @dev Returns true if `account` is a contract.
                         *
                         * [IMPORTANT]
                         * ====
                         * It is unsafe to assume that an address for which this function returns
                         * false is an externally-owned account (EOA) and not a contract.
                         *
                         * Among others, `isContract` will return false for the following
                         * types of addresses:
                         *
                         *  - an externally-owned account
                         *  - a contract in construction
                         *  - an address where a contract will be created
                         *  - an address where a contract lived, but was destroyed
                         * ====
                         *
                         * [IMPORTANT]
                         * ====
                         * You shouldn't rely on `isContract` to protect against flash loan attacks!
                         *
                         * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
                         * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
                         * constructor.
                         * ====
                         */
                        function isContract(address account) internal view returns (bool) {
                            // This method relies on extcodesize/address.code.length, which returns 0
                            // for contracts in construction, since the code is only stored at the end
                            // of the constructor execution.
                            return account.code.length > 0;
                        }
                        /**
                         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
                         * `recipient`, forwarding all available gas and reverting on errors.
                         *
                         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
                         * of certain opcodes, possibly making contracts go over the 2300 gas limit
                         * imposed by `transfer`, making them unable to receive funds via
                         * `transfer`. {sendValue} removes this limitation.
                         *
                         * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
                         *
                         * IMPORTANT: because control is transferred to `recipient`, care must be
                         * taken to not create reentrancy vulnerabilities. Consider using
                         * {ReentrancyGuard} or the
                         * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
                         */
                        function sendValue(address payable recipient, uint256 amount) internal {
                            require(address(this).balance >= amount, "Address: insufficient balance");
                            (bool success, ) = recipient.call{value: amount}("");
                            require(success, "Address: unable to send value, recipient may have reverted");
                        }
                        /**
                         * @dev Performs a Solidity function call using a low level `call`. A
                         * plain `call` is an unsafe replacement for a function call: use this
                         * function instead.
                         *
                         * If `target` reverts with a revert reason, it is bubbled up by this
                         * function (like regular Solidity function calls).
                         *
                         * Returns the raw returned data. To convert to the expected return value,
                         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
                         *
                         * Requirements:
                         *
                         * - `target` must be a contract.
                         * - calling `target` with `data` must not revert.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                            return functionCall(target, data, "Address: low-level call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
                         * `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, 0, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but also transferring `value` wei to `target`.
                         *
                         * Requirements:
                         *
                         * - the calling contract must have an ETH balance of at least `value`.
                         * - the called Solidity function must be `payable`.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value
                        ) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
                         * with `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            require(address(this).balance >= value, "Address: insufficient balance for call");
                            require(isContract(target), "Address: call to non-contract");
                            (bool success, bytes memory returndata) = target.call{value: value}(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                            return functionStaticCall(target, data, "Address: low-level static call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal view returns (bytes memory) {
                            require(isContract(target), "Address: static call to non-contract");
                            (bool success, bytes memory returndata) = target.staticcall(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but performing a delegate call.
                         *
                         * _Available since v3.4._
                         */
                        function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                            return functionDelegateCall(target, data, "Address: low-level delegate call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
                         * but performing a delegate call.
                         *
                         * _Available since v3.4._
                         */
                        function functionDelegateCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            require(isContract(target), "Address: delegate call to non-contract");
                            (bool success, bytes memory returndata) = target.delegatecall(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
                         * revert reason using the provided one.
                         *
                         * _Available since v4.3._
                         */
                        function verifyCallResult(
                            bool success,
                            bytes memory returndata,
                            string memory errorMessage
                        ) internal pure returns (bytes memory) {
                            if (success) {
                                return returndata;
                            } else {
                                // Look for revert reason and bubble it up if present
                                if (returndata.length > 0) {
                                    // The easiest way to bubble the revert reason is using memory via assembly
                                    /// @solidity memory-safe-assembly
                                    assembly {
                                        let returndata_size := mload(returndata)
                                        revert(add(32, returndata), returndata_size)
                                    }
                                } else {
                                    revert(errorMessage);
                                }
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev Interface of the ERC165 standard, as defined in the
                     * https://eips.ethereum.org/EIPS/eip-165[EIP].
                     *
                     * Implementers can declare support of contract interfaces, which can then be
                     * queried by others ({ERC165Checker}).
                     *
                     * For an implementation, see {ERC165}.
                     */
                    interface IERC165 {
                        /**
                         * @dev Returns true if this contract implements the interface defined by
                         * `interfaceId`. See the corresponding
                         * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
                         * to learn more about how these ids are created.
                         *
                         * This function call must use less than 30 000 gas.
                         */
                        function supportsInterface(bytes4 interfaceId) external view returns (bool);
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev 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.
                     */
                    interface IERC20Permit {
                        /**
                         * @dev 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].
                         */
                        function permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external;
                        /**
                         * @dev 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.
                         */
                        function nonces(address owner) external view returns (uint256);
                        /**
                         * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
                         */
                        // solhint-disable-next-line func-name-mixedcase
                        function DOMAIN_SEPARATOR() external view returns (bytes32);
                    }
                    

                    File 7 of 11: FiatTokenV2_2
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { EIP712Domain } from "./EIP712Domain.sol"; // solhint-disable-line no-unused-import
                    import { Blacklistable } from "../v1/Blacklistable.sol"; // solhint-disable-line no-unused-import
                    import { FiatTokenV1 } from "../v1/FiatTokenV1.sol"; // solhint-disable-line no-unused-import
                    import { FiatTokenV2 } from "./FiatTokenV2.sol"; // solhint-disable-line no-unused-import
                    import { FiatTokenV2_1 } from "./FiatTokenV2_1.sol";
                    import { EIP712 } from "../util/EIP712.sol";
                    // solhint-disable func-name-mixedcase
                    /**
                     * @title FiatToken V2.2
                     * @notice ERC20 Token backed by fiat reserves, version 2.2
                     */
                    contract FiatTokenV2_2 is FiatTokenV2_1 {
                        /**
                         * @notice Initialize v2.2
                         * @param accountsToBlacklist   A list of accounts to migrate from the old blacklist
                         * @param newSymbol             New token symbol
                         * data structure to the new blacklist data structure.
                         */
                        function initializeV2_2(
                            address[] calldata accountsToBlacklist,
                            string calldata newSymbol
                        ) external {
                            // solhint-disable-next-line reason-string
                            require(_initializedVersion == 2);
                            // Update fiat token symbol
                            symbol = newSymbol;
                            // Add previously blacklisted accounts to the new blacklist data structure
                            // and remove them from the old blacklist data structure.
                            for (uint256 i = 0; i < accountsToBlacklist.length; i++) {
                                require(
                                    _deprecatedBlacklisted[accountsToBlacklist[i]],
                                    "FiatTokenV2_2: Blacklisting previously unblacklisted account!"
                                );
                                _blacklist(accountsToBlacklist[i]);
                                delete _deprecatedBlacklisted[accountsToBlacklist[i]];
                            }
                            _blacklist(address(this));
                            delete _deprecatedBlacklisted[address(this)];
                            _initializedVersion = 3;
                        }
                        /**
                         * @dev Internal function to get the current chain id.
                         * @return The current chain id.
                         */
                        function _chainId() internal virtual view returns (uint256) {
                            uint256 chainId;
                            assembly {
                                chainId := chainid()
                            }
                            return chainId;
                        }
                        /**
                         * @inheritdoc EIP712Domain
                         */
                        function _domainSeparator() internal override view returns (bytes32) {
                            return EIP712.makeDomainSeparator(name, "2", _chainId());
                        }
                        /**
                         * @notice Update allowance with a signed permit
                         * @dev EOA wallet signatures should be packed in the order of r, s, v.
                         * @param owner       Token owner's address (Authorizer)
                         * @param spender     Spender's address
                         * @param value       Amount of allowance
                         * @param deadline    The time at which the signature expires (unix time), or max uint256 value to signal no expiration
                         * @param signature   Signature bytes signed by an EOA wallet or a contract wallet
                         */
                        function permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            bytes memory signature
                        ) external whenNotPaused {
                            _permit(owner, spender, value, deadline, signature);
                        }
                        /**
                         * @notice Execute a transfer with a signed authorization
                         * @dev EOA wallet signatures should be packed in the order of r, s, v.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param signature     Signature bytes signed by an EOA wallet or a contract wallet
                         */
                        function transferWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            bytes memory signature
                        ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                            _transferWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                signature
                            );
                        }
                        /**
                         * @notice Receive a transfer with a signed authorization from the payer
                         * @dev This has an additional check to ensure that the payee's address
                         * matches the caller of this function to prevent front-running attacks.
                         * EOA wallet signatures should be packed in the order of r, s, v.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param signature     Signature bytes signed by an EOA wallet or a contract wallet
                         */
                        function receiveWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            bytes memory signature
                        ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                            _receiveWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                signature
                            );
                        }
                        /**
                         * @notice Attempt to cancel an authorization
                         * @dev Works only if the authorization is not yet used.
                         * EOA wallet signatures should be packed in the order of r, s, v.
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param signature     Signature bytes signed by an EOA wallet or a contract wallet
                         */
                        function cancelAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            bytes memory signature
                        ) external whenNotPaused {
                            _cancelAuthorization(authorizer, nonce, signature);
                        }
                        /**
                         * @dev Helper method that sets the blacklist state of an account on balanceAndBlacklistStates.
                         * If _shouldBlacklist is true, we apply a (1 << 255) bitmask with an OR operation on the
                         * account's balanceAndBlacklistState. This flips the high bit for the account to 1,
                         * indicating that the account is blacklisted.
                         *
                         * If _shouldBlacklist if false, we reset the account's balanceAndBlacklistStates to their
                         * balances. This clears the high bit for the account, indicating that the account is unblacklisted.
                         * @param _account         The address of the account.
                         * @param _shouldBlacklist True if the account should be blacklisted, false if the account should be unblacklisted.
                         */
                        function _setBlacklistState(address _account, bool _shouldBlacklist)
                            internal
                            override
                        {
                            balanceAndBlacklistStates[_account] = _shouldBlacklist
                                ? balanceAndBlacklistStates[_account] | (1 << 255)
                                : _balanceOf(_account);
                        }
                        /**
                         * @dev Helper method that sets the balance of an account on balanceAndBlacklistStates.
                         * Since balances are stored in the last 255 bits of the balanceAndBlacklistStates value,
                         * we need to ensure that the updated balance does not exceed (2^255 - 1).
                         * Since blacklisted accounts' balances cannot be updated, the method will also
                         * revert if the account is blacklisted
                         * @param _account The address of the account.
                         * @param _balance The new fiat token balance of the account (max: (2^255 - 1)).
                         */
                        function _setBalance(address _account, uint256 _balance) internal override {
                            require(
                                _balance <= ((1 << 255) - 1),
                                "FiatTokenV2_2: Balance exceeds (2^255 - 1)"
                            );
                            require(
                                !_isBlacklisted(_account),
                                "FiatTokenV2_2: Account is blacklisted"
                            );
                            balanceAndBlacklistStates[_account] = _balance;
                        }
                        /**
                         * @inheritdoc Blacklistable
                         */
                        function _isBlacklisted(address _account)
                            internal
                            override
                            view
                            returns (bool)
                        {
                            return balanceAndBlacklistStates[_account] >> 255 == 1;
                        }
                        /**
                         * @dev Helper method to obtain the balance of an account. Since balances
                         * are stored in the last 255 bits of the balanceAndBlacklistStates value,
                         * we apply a ((1 << 255) - 1) bit bitmask with an AND operation on the
                         * balanceAndBlacklistState to obtain the balance.
                         * @param _account  The address of the account.
                         * @return          The fiat token balance of the account.
                         */
                        function _balanceOf(address _account)
                            internal
                            override
                            view
                            returns (uint256)
                        {
                            return balanceAndBlacklistStates[_account] & ((1 << 255) - 1);
                        }
                        /**
                         * @inheritdoc FiatTokenV1
                         */
                        function approve(address spender, uint256 value)
                            external
                            override
                            whenNotPaused
                            returns (bool)
                        {
                            _approve(msg.sender, spender, value);
                            return true;
                        }
                        /**
                         * @inheritdoc FiatTokenV2
                         */
                        function permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external override whenNotPaused {
                            _permit(owner, spender, value, deadline, v, r, s);
                        }
                        /**
                         * @inheritdoc FiatTokenV2
                         */
                        function increaseAllowance(address spender, uint256 increment)
                            external
                            override
                            whenNotPaused
                            returns (bool)
                        {
                            _increaseAllowance(msg.sender, spender, increment);
                            return true;
                        }
                        /**
                         * @inheritdoc FiatTokenV2
                         */
                        function decreaseAllowance(address spender, uint256 decrement)
                            external
                            override
                            whenNotPaused
                            returns (bool)
                        {
                            _decreaseAllowance(msg.sender, spender, decrement);
                            return true;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.2 <0.8.0;
                    /**
                     * @dev Collection of functions related to the address type
                     */
                    library Address {
                        /**
                         * @dev Returns true if `account` is a contract.
                         *
                         * [IMPORTANT]
                         * ====
                         * It is unsafe to assume that an address for which this function returns
                         * false is an externally-owned account (EOA) and not a contract.
                         *
                         * Among others, `isContract` will return false for the following
                         * types of addresses:
                         *
                         *  - an externally-owned account
                         *  - a contract in construction
                         *  - an address where a contract will be created
                         *  - an address where a contract lived, but was destroyed
                         * ====
                         */
                        function isContract(address account) internal view returns (bool) {
                            // This method relies on extcodesize, which returns 0 for contracts in
                            // construction, since the code is only stored at the end of the
                            // constructor execution.
                            uint256 size;
                            // solhint-disable-next-line no-inline-assembly
                            assembly { size := extcodesize(account) }
                            return size > 0;
                        }
                        /**
                         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
                         * `recipient`, forwarding all available gas and reverting on errors.
                         *
                         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
                         * of certain opcodes, possibly making contracts go over the 2300 gas limit
                         * imposed by `transfer`, making them unable to receive funds via
                         * `transfer`. {sendValue} removes this limitation.
                         *
                         * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
                         *
                         * IMPORTANT: because control is transferred to `recipient`, care must be
                         * taken to not create reentrancy vulnerabilities. Consider using
                         * {ReentrancyGuard} or the
                         * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
                         */
                        function sendValue(address payable recipient, uint256 amount) internal {
                            require(address(this).balance >= amount, "Address: insufficient balance");
                            // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
                            (bool success, ) = recipient.call{ value: amount }("");
                            require(success, "Address: unable to send value, recipient may have reverted");
                        }
                        /**
                         * @dev Performs a Solidity function call using a low level `call`. A
                         * plain`call` is an unsafe replacement for a function call: use this
                         * function instead.
                         *
                         * If `target` reverts with a revert reason, it is bubbled up by this
                         * function (like regular Solidity function calls).
                         *
                         * Returns the raw returned data. To convert to the expected return value,
                         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
                         *
                         * Requirements:
                         *
                         * - `target` must be a contract.
                         * - calling `target` with `data` must not revert.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                          return functionCall(target, data, "Address: low-level call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
                         * `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, 0, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but also transferring `value` wei to `target`.
                         *
                         * Requirements:
                         *
                         * - the calling contract must have an ETH balance of at least `value`.
                         * - the called Solidity function must be `payable`.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
                         * with `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {
                            require(address(this).balance >= value, "Address: insufficient balance for call");
                            require(isContract(target), "Address: call to non-contract");
                            // solhint-disable-next-line avoid-low-level-calls
                            (bool success, bytes memory returndata) = target.call{ value: value }(data);
                            return _verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                            return functionStaticCall(target, data, "Address: low-level static call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
                            require(isContract(target), "Address: static call to non-contract");
                            // solhint-disable-next-line avoid-low-level-calls
                            (bool success, bytes memory returndata) = target.staticcall(data);
                            return _verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but performing a delegate call.
                         *
                         * _Available since v3.4._
                         */
                        function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                            return functionDelegateCall(target, data, "Address: low-level delegate call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
                         * but performing a delegate call.
                         *
                         * _Available since v3.4._
                         */
                        function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
                            require(isContract(target), "Address: delegate call to non-contract");
                            // solhint-disable-next-line avoid-low-level-calls
                            (bool success, bytes memory returndata) = target.delegatecall(data);
                            return _verifyCallResult(success, returndata, errorMessage);
                        }
                        function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
                            if (success) {
                                return returndata;
                            } else {
                                // Look for revert reason and bubble it up if present
                                if (returndata.length > 0) {
                                    // The easiest way to bubble the revert reason is using memory via assembly
                                    // solhint-disable-next-line no-inline-assembly
                                    assembly {
                                        let returndata_size := mload(returndata)
                                        revert(add(32, returndata), returndata_size)
                                    }
                                } else {
                                    revert(errorMessage);
                                }
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.0 <0.8.0;
                    import "./IERC20.sol";
                    import "../../math/SafeMath.sol";
                    import "../../utils/Address.sol";
                    /**
                     * @title SafeERC20
                     * @dev 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.
                     */
                    library SafeERC20 {
                        using SafeMath for uint256;
                        using Address for address;
                        function safeTransfer(IERC20 token, address to, uint256 value) internal {
                            _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
                        }
                        function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
                            _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
                        }
                        /**
                         * @dev Deprecated. This function has issues similar to the ones found in
                         * {IERC20-approve}, and its usage is discouraged.
                         *
                         * Whenever possible, use {safeIncreaseAllowance} and
                         * {safeDecreaseAllowance} instead.
                         */
                        function safeApprove(IERC20 token, address spender, uint256 value) internal {
                            // safeApprove should only be called when setting an initial allowance,
                            // or when resetting it to zero. To increase and decrease it, use
                            // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                            // solhint-disable-next-line max-line-length
                            require((value == 0) || (token.allowance(address(this), spender) == 0),
                                "SafeERC20: approve from non-zero to non-zero allowance"
                            );
                            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
                        }
                        function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
                            uint256 newAllowance = token.allowance(address(this), spender).add(value);
                            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                        }
                        function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
                            uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
                            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                        }
                        /**
                         * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
                         * on the return value: the return value is optional (but if data is returned, it must not be false).
                         * @param token The token targeted by the call.
                         * @param data The call data (encoded using abi.encode or one of its variants).
                         */
                        function _callOptionalReturn(IERC20 token, bytes memory data) private {
                            // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                            // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                            // the target address contains contract code and also asserts for success in the low-level call.
                            bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
                            if (returndata.length > 0) { // Return data is optional
                                // solhint-disable-next-line max-line-length
                                require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.0 <0.8.0;
                    /**
                     * @dev Interface of the ERC20 standard as defined in the EIP.
                     */
                    interface IERC20 {
                        /**
                         * @dev Returns the amount of tokens in existence.
                         */
                        function totalSupply() external view returns (uint256);
                        /**
                         * @dev Returns the amount of tokens owned by `account`.
                         */
                        function balanceOf(address account) external view returns (uint256);
                        /**
                         * @dev Moves `amount` tokens from the caller's account to `recipient`.
                         *
                         * Returns a boolean value indicating whether the operation succeeded.
                         *
                         * Emits a {Transfer} event.
                         */
                        function transfer(address recipient, uint256 amount) external returns (bool);
                        /**
                         * @dev 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.
                         */
                        function allowance(address owner, address spender) external view returns (uint256);
                        /**
                         * @dev 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.
                         */
                        function approve(address spender, uint256 amount) external returns (bool);
                        /**
                         * @dev Moves `amount` tokens from `sender` to `recipient` 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.
                         */
                        function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
                        /**
                         * @dev Emitted when `value` tokens are moved from one account (`from`) to
                         * another (`to`).
                         *
                         * Note that `value` may be zero.
                         */
                        event Transfer(address indexed from, address indexed to, uint256 value);
                        /**
                         * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                         * a call to {approve}. `value` is the new allowance.
                         */
                        event Approval(address indexed owner, address indexed spender, uint256 value);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.0 <0.8.0;
                    /**
                     * @dev Wrappers over Solidity's arithmetic operations with added overflow
                     * checks.
                     *
                     * Arithmetic operations in Solidity wrap on overflow. This can easily result
                     * in bugs, because programmers usually assume that an overflow raises an
                     * error, which is the standard behavior in high level programming languages.
                     * `SafeMath` restores this intuition by reverting the transaction when an
                     * operation overflows.
                     *
                     * Using this library instead of the unchecked operations eliminates an entire
                     * class of bugs, so it's recommended to use it always.
                     */
                    library SafeMath {
                        /**
                         * @dev Returns the addition of two unsigned integers, with an overflow flag.
                         *
                         * _Available since v3.4._
                         */
                        function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                            uint256 c = a + b;
                            if (c < a) return (false, 0);
                            return (true, c);
                        }
                        /**
                         * @dev Returns the substraction of two unsigned integers, with an overflow flag.
                         *
                         * _Available since v3.4._
                         */
                        function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                            if (b > a) return (false, 0);
                            return (true, a - b);
                        }
                        /**
                         * @dev Returns the multiplication of two unsigned integers, with an overflow flag.
                         *
                         * _Available since v3.4._
                         */
                        function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                            // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
                            // benefit is lost if 'b' is also tested.
                            // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
                            if (a == 0) return (true, 0);
                            uint256 c = a * b;
                            if (c / a != b) return (false, 0);
                            return (true, c);
                        }
                        /**
                         * @dev Returns the division of two unsigned integers, with a division by zero flag.
                         *
                         * _Available since v3.4._
                         */
                        function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                            if (b == 0) return (false, 0);
                            return (true, a / b);
                        }
                        /**
                         * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
                         *
                         * _Available since v3.4._
                         */
                        function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
                            if (b == 0) return (false, 0);
                            return (true, a % b);
                        }
                        /**
                         * @dev Returns the addition of two unsigned integers, reverting on
                         * overflow.
                         *
                         * Counterpart to Solidity's `+` operator.
                         *
                         * Requirements:
                         *
                         * - Addition cannot overflow.
                         */
                        function add(uint256 a, uint256 b) internal pure returns (uint256) {
                            uint256 c = a + b;
                            require(c >= a, "SafeMath: addition overflow");
                            return c;
                        }
                        /**
                         * @dev Returns the subtraction of two unsigned integers, reverting on
                         * overflow (when the result is negative).
                         *
                         * Counterpart to Solidity's `-` operator.
                         *
                         * Requirements:
                         *
                         * - Subtraction cannot overflow.
                         */
                        function sub(uint256 a, uint256 b) internal pure returns (uint256) {
                            require(b <= a, "SafeMath: subtraction overflow");
                            return a - b;
                        }
                        /**
                         * @dev Returns the multiplication of two unsigned integers, reverting on
                         * overflow.
                         *
                         * Counterpart to Solidity's `*` operator.
                         *
                         * Requirements:
                         *
                         * - Multiplication cannot overflow.
                         */
                        function mul(uint256 a, uint256 b) internal pure returns (uint256) {
                            if (a == 0) return 0;
                            uint256 c = a * b;
                            require(c / a == b, "SafeMath: multiplication overflow");
                            return c;
                        }
                        /**
                         * @dev Returns the integer division of two unsigned integers, reverting on
                         * division by zero. The result is rounded towards zero.
                         *
                         * Counterpart to Solidity's `/` operator. Note: this function uses a
                         * `revert` opcode (which leaves remaining gas untouched) while Solidity
                         * uses an invalid opcode to revert (consuming all remaining gas).
                         *
                         * Requirements:
                         *
                         * - The divisor cannot be zero.
                         */
                        function div(uint256 a, uint256 b) internal pure returns (uint256) {
                            require(b > 0, "SafeMath: division by zero");
                            return a / b;
                        }
                        /**
                         * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
                         * reverting when dividing by zero.
                         *
                         * Counterpart to Solidity's `%` operator. This function uses a `revert`
                         * opcode (which leaves remaining gas untouched) while Solidity uses an
                         * invalid opcode to revert (consuming all remaining gas).
                         *
                         * Requirements:
                         *
                         * - The divisor cannot be zero.
                         */
                        function mod(uint256 a, uint256 b) internal pure returns (uint256) {
                            require(b > 0, "SafeMath: modulo by zero");
                            return a % b;
                        }
                        /**
                         * @dev Returns the subtraction of two unsigned integers, reverting with custom message on
                         * overflow (when the result is negative).
                         *
                         * CAUTION: This function is deprecated because it requires allocating memory for the error
                         * message unnecessarily. For custom revert reasons use {trySub}.
                         *
                         * Counterpart to Solidity's `-` operator.
                         *
                         * Requirements:
                         *
                         * - Subtraction cannot overflow.
                         */
                        function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
                            require(b <= a, errorMessage);
                            return a - b;
                        }
                        /**
                         * @dev Returns the integer division of two unsigned integers, reverting with custom message on
                         * division by zero. The result is rounded towards zero.
                         *
                         * CAUTION: This function is deprecated because it requires allocating memory for the error
                         * message unnecessarily. For custom revert reasons use {tryDiv}.
                         *
                         * Counterpart to Solidity's `/` operator. Note: this function uses a
                         * `revert` opcode (which leaves remaining gas untouched) while Solidity
                         * uses an invalid opcode to revert (consuming all remaining gas).
                         *
                         * Requirements:
                         *
                         * - The divisor cannot be zero.
                         */
                        function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
                            require(b > 0, errorMessage);
                            return a / b;
                        }
                        /**
                         * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
                         * reverting with custom message when dividing by zero.
                         *
                         * CAUTION: This function is deprecated because it requires allocating memory for the error
                         * message unnecessarily. For custom revert reasons use {tryMod}.
                         *
                         * Counterpart to Solidity's `%` operator. This function uses a `revert`
                         * opcode (which leaves remaining gas untouched) while Solidity uses an
                         * invalid opcode to revert (consuming all remaining gas).
                         *
                         * Requirements:
                         *
                         * - The divisor cannot be zero.
                         */
                        function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
                            require(b > 0, errorMessage);
                            return a % b;
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { FiatTokenV2 } from "./FiatTokenV2.sol";
                    // solhint-disable func-name-mixedcase
                    /**
                     * @title FiatToken V2.1
                     * @notice ERC20 Token backed by fiat reserves, version 2.1
                     */
                    contract FiatTokenV2_1 is FiatTokenV2 {
                        /**
                         * @notice Initialize v2.1
                         * @param lostAndFound  The address to which the locked funds are sent
                         */
                        function initializeV2_1(address lostAndFound) external {
                            // solhint-disable-next-line reason-string
                            require(_initializedVersion == 1);
                            uint256 lockedAmount = _balanceOf(address(this));
                            if (lockedAmount > 0) {
                                _transfer(address(this), lostAndFound, lockedAmount);
                            }
                            _blacklist(address(this));
                            _initializedVersion = 2;
                        }
                        /**
                         * @notice Version string for the EIP712 domain separator
                         * @return Version string
                         */
                        function version() external pure returns (string memory) {
                            return "2";
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { FiatTokenV1_1 } from "../v1.1/FiatTokenV1_1.sol";
                    import { EIP712 } from "../util/EIP712.sol";
                    import { EIP3009 } from "./EIP3009.sol";
                    import { EIP2612 } from "./EIP2612.sol";
                    /**
                     * @title FiatToken V2
                     * @notice ERC20 Token backed by fiat reserves, version 2
                     */
                    contract FiatTokenV2 is FiatTokenV1_1, EIP3009, EIP2612 {
                        uint8 internal _initializedVersion;
                        /**
                         * @notice Initialize v2
                         * @param newName   New token name
                         */
                        function initializeV2(string calldata newName) external {
                            // solhint-disable-next-line reason-string
                            require(initialized && _initializedVersion == 0);
                            name = newName;
                            _DEPRECATED_CACHED_DOMAIN_SEPARATOR = EIP712.makeDomainSeparator(
                                newName,
                                "2"
                            );
                            _initializedVersion = 1;
                        }
                        /**
                         * @notice Increase the allowance by a given increment
                         * @param spender   Spender's address
                         * @param increment Amount of increase in allowance
                         * @return True if successful
                         */
                        function increaseAllowance(address spender, uint256 increment)
                            external
                            virtual
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(spender)
                            returns (bool)
                        {
                            _increaseAllowance(msg.sender, spender, increment);
                            return true;
                        }
                        /**
                         * @notice Decrease the allowance by a given decrement
                         * @param spender   Spender's address
                         * @param decrement Amount of decrease in allowance
                         * @return True if successful
                         */
                        function decreaseAllowance(address spender, uint256 decrement)
                            external
                            virtual
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(spender)
                            returns (bool)
                        {
                            _decreaseAllowance(msg.sender, spender, decrement);
                            return true;
                        }
                        /**
                         * @notice Execute a transfer with a signed authorization
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function transferWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                            _transferWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                v,
                                r,
                                s
                            );
                        }
                        /**
                         * @notice Receive a transfer with a signed authorization from the payer
                         * @dev This has an additional check to ensure that the payee's address
                         * matches the caller of this function to prevent front-running attacks.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function receiveWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external whenNotPaused notBlacklisted(from) notBlacklisted(to) {
                            _receiveWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                v,
                                r,
                                s
                            );
                        }
                        /**
                         * @notice Attempt to cancel an authorization
                         * @dev Works only if the authorization is not yet used.
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function cancelAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external whenNotPaused {
                            _cancelAuthorization(authorizer, nonce, v, r, s);
                        }
                        /**
                         * @notice Update allowance with a signed permit
                         * @param owner       Token owner's address (Authorizer)
                         * @param spender     Spender's address
                         * @param value       Amount of allowance
                         * @param deadline    The time at which the signature expires (unix time), or max uint256 value to signal no expiration
                         * @param v           v of the signature
                         * @param r           r of the signature
                         * @param s           s of the signature
                         */
                        function permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        )
                            external
                            virtual
                            whenNotPaused
                            notBlacklisted(owner)
                            notBlacklisted(spender)
                        {
                            _permit(owner, spender, value, deadline, v, r, s);
                        }
                        /**
                         * @dev Internal function to increase the allowance by a given increment
                         * @param owner     Token owner's address
                         * @param spender   Spender's address
                         * @param increment Amount of increase
                         */
                        function _increaseAllowance(
                            address owner,
                            address spender,
                            uint256 increment
                        ) internal override {
                            _approve(owner, spender, allowed[owner][spender].add(increment));
                        }
                        /**
                         * @dev Internal function to decrease the allowance by a given decrement
                         * @param owner     Token owner's address
                         * @param spender   Spender's address
                         * @param decrement Amount of decrease
                         */
                        function _decreaseAllowance(
                            address owner,
                            address spender,
                            uint256 decrement
                        ) internal override {
                            _approve(
                                owner,
                                spender,
                                allowed[owner][spender].sub(
                                    decrement,
                                    "ERC20: decreased allowance below zero"
                                )
                            );
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    // solhint-disable func-name-mixedcase
                    /**
                     * @title EIP712 Domain
                     */
                    contract EIP712Domain {
                        // was originally DOMAIN_SEPARATOR
                        // but that has been moved to a method so we can override it in V2_2+
                        bytes32 internal _DEPRECATED_CACHED_DOMAIN_SEPARATOR;
                        /**
                         * @notice Get the EIP712 Domain Separator.
                         * @return The bytes32 EIP712 domain separator.
                         */
                        function DOMAIN_SEPARATOR() external view returns (bytes32) {
                            return _domainSeparator();
                        }
                        /**
                         * @dev Internal method to get the EIP712 Domain Separator.
                         * @return The bytes32 EIP712 domain separator.
                         */
                        function _domainSeparator() internal virtual view returns (bytes32) {
                            return _DEPRECATED_CACHED_DOMAIN_SEPARATOR;
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { AbstractFiatTokenV2 } from "./AbstractFiatTokenV2.sol";
                    import { EIP712Domain } from "./EIP712Domain.sol";
                    import { SignatureChecker } from "../util/SignatureChecker.sol";
                    import { MessageHashUtils } from "../util/MessageHashUtils.sol";
                    /**
                     * @title EIP-3009
                     * @notice Provide internal implementation for gas-abstracted transfers
                     * @dev Contracts that inherit from this must wrap these with publicly
                     * accessible functions, optionally adding modifiers where necessary
                     */
                    abstract contract EIP3009 is AbstractFiatTokenV2, EIP712Domain {
                        // keccak256("TransferWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
                        bytes32
                            public constant TRANSFER_WITH_AUTHORIZATION_TYPEHASH = 0x7c7c6cdb67a18743f49ec6fa9b35f50d52ed05cbed4cc592e13b44501c1a2267;
                        // keccak256("ReceiveWithAuthorization(address from,address to,uint256 value,uint256 validAfter,uint256 validBefore,bytes32 nonce)")
                        bytes32
                            public constant RECEIVE_WITH_AUTHORIZATION_TYPEHASH = 0xd099cc98ef71107a616c4f0f941f04c322d8e254fe26b3c6668db87aae413de8;
                        // keccak256("CancelAuthorization(address authorizer,bytes32 nonce)")
                        bytes32
                            public constant CANCEL_AUTHORIZATION_TYPEHASH = 0x158b0a9edf7a828aad02f63cd515c68ef2f50ba807396f6d12842833a1597429;
                        /**
                         * @dev authorizer address => nonce => bool (true if nonce is used)
                         */
                        mapping(address => mapping(bytes32 => bool)) private _authorizationStates;
                        event AuthorizationUsed(address indexed authorizer, bytes32 indexed nonce);
                        event AuthorizationCanceled(
                            address indexed authorizer,
                            bytes32 indexed nonce
                        );
                        /**
                         * @notice Returns the state of an authorization
                         * @dev Nonces are randomly generated 32-byte data unique to the
                         * authorizer's address
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @return True if the nonce is used
                         */
                        function authorizationState(address authorizer, bytes32 nonce)
                            external
                            view
                            returns (bool)
                        {
                            return _authorizationStates[authorizer][nonce];
                        }
                        /**
                         * @notice Execute a transfer with a signed authorization
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function _transferWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            _transferWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                abi.encodePacked(r, s, v)
                            );
                        }
                        /**
                         * @notice Execute a transfer with a signed authorization
                         * @dev EOA wallet signatures should be packed in the order of r, s, v.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
                         */
                        function _transferWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            bytes memory signature
                        ) internal {
                            _requireValidAuthorization(from, nonce, validAfter, validBefore);
                            _requireValidSignature(
                                from,
                                keccak256(
                                    abi.encode(
                                        TRANSFER_WITH_AUTHORIZATION_TYPEHASH,
                                        from,
                                        to,
                                        value,
                                        validAfter,
                                        validBefore,
                                        nonce
                                    )
                                ),
                                signature
                            );
                            _markAuthorizationAsUsed(from, nonce);
                            _transfer(from, to, value);
                        }
                        /**
                         * @notice Receive a transfer with a signed authorization from the payer
                         * @dev This has an additional check to ensure that the payee's address
                         * matches the caller of this function to prevent front-running attacks.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function _receiveWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            _receiveWithAuthorization(
                                from,
                                to,
                                value,
                                validAfter,
                                validBefore,
                                nonce,
                                abi.encodePacked(r, s, v)
                            );
                        }
                        /**
                         * @notice Receive a transfer with a signed authorization from the payer
                         * @dev This has an additional check to ensure that the payee's address
                         * matches the caller of this function to prevent front-running attacks.
                         * EOA wallet signatures should be packed in the order of r, s, v.
                         * @param from          Payer's address (Authorizer)
                         * @param to            Payee's address
                         * @param value         Amount to be transferred
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         * @param nonce         Unique nonce
                         * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
                         */
                        function _receiveWithAuthorization(
                            address from,
                            address to,
                            uint256 value,
                            uint256 validAfter,
                            uint256 validBefore,
                            bytes32 nonce,
                            bytes memory signature
                        ) internal {
                            require(to == msg.sender, "FiatTokenV2: caller must be the payee");
                            _requireValidAuthorization(from, nonce, validAfter, validBefore);
                            _requireValidSignature(
                                from,
                                keccak256(
                                    abi.encode(
                                        RECEIVE_WITH_AUTHORIZATION_TYPEHASH,
                                        from,
                                        to,
                                        value,
                                        validAfter,
                                        validBefore,
                                        nonce
                                    )
                                ),
                                signature
                            );
                            _markAuthorizationAsUsed(from, nonce);
                            _transfer(from, to, value);
                        }
                        /**
                         * @notice Attempt to cancel an authorization
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param v             v of the signature
                         * @param r             r of the signature
                         * @param s             s of the signature
                         */
                        function _cancelAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            _cancelAuthorization(authorizer, nonce, abi.encodePacked(r, s, v));
                        }
                        /**
                         * @notice Attempt to cancel an authorization
                         * @dev EOA wallet signatures should be packed in the order of r, s, v.
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
                         */
                        function _cancelAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            bytes memory signature
                        ) internal {
                            _requireUnusedAuthorization(authorizer, nonce);
                            _requireValidSignature(
                                authorizer,
                                keccak256(
                                    abi.encode(CANCEL_AUTHORIZATION_TYPEHASH, authorizer, nonce)
                                ),
                                signature
                            );
                            _authorizationStates[authorizer][nonce] = true;
                            emit AuthorizationCanceled(authorizer, nonce);
                        }
                        /**
                         * @notice Validates that signature against input data struct
                         * @param signer        Signer's address
                         * @param dataHash      Hash of encoded data struct
                         * @param signature     Signature byte array produced by an EOA wallet or a contract wallet
                         */
                        function _requireValidSignature(
                            address signer,
                            bytes32 dataHash,
                            bytes memory signature
                        ) private view {
                            require(
                                SignatureChecker.isValidSignatureNow(
                                    signer,
                                    MessageHashUtils.toTypedDataHash(_domainSeparator(), dataHash),
                                    signature
                                ),
                                "FiatTokenV2: invalid signature"
                            );
                        }
                        /**
                         * @notice Check that an authorization is unused
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         */
                        function _requireUnusedAuthorization(address authorizer, bytes32 nonce)
                            private
                            view
                        {
                            require(
                                !_authorizationStates[authorizer][nonce],
                                "FiatTokenV2: authorization is used or canceled"
                            );
                        }
                        /**
                         * @notice Check that authorization is valid
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         * @param validAfter    The time after which this is valid (unix time)
                         * @param validBefore   The time before which this is valid (unix time)
                         */
                        function _requireValidAuthorization(
                            address authorizer,
                            bytes32 nonce,
                            uint256 validAfter,
                            uint256 validBefore
                        ) private view {
                            require(
                                now > validAfter,
                                "FiatTokenV2: authorization is not yet valid"
                            );
                            require(now < validBefore, "FiatTokenV2: authorization is expired");
                            _requireUnusedAuthorization(authorizer, nonce);
                        }
                        /**
                         * @notice Mark an authorization as used
                         * @param authorizer    Authorizer's address
                         * @param nonce         Nonce of the authorization
                         */
                        function _markAuthorizationAsUsed(address authorizer, bytes32 nonce)
                            private
                        {
                            _authorizationStates[authorizer][nonce] = true;
                            emit AuthorizationUsed(authorizer, nonce);
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { AbstractFiatTokenV2 } from "./AbstractFiatTokenV2.sol";
                    import { EIP712Domain } from "./EIP712Domain.sol";
                    import { MessageHashUtils } from "../util/MessageHashUtils.sol";
                    import { SignatureChecker } from "../util/SignatureChecker.sol";
                    /**
                     * @title EIP-2612
                     * @notice Provide internal implementation for gas-abstracted approvals
                     */
                    abstract contract EIP2612 is AbstractFiatTokenV2, EIP712Domain {
                        // keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)")
                        bytes32
                            public constant PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9;
                        mapping(address => uint256) private _permitNonces;
                        /**
                         * @notice Nonces for permit
                         * @param owner Token owner's address (Authorizer)
                         * @return Next nonce
                         */
                        function nonces(address owner) external view returns (uint256) {
                            return _permitNonces[owner];
                        }
                        /**
                         * @notice Verify a signed approval permit and execute if valid
                         * @param owner     Token owner's address (Authorizer)
                         * @param spender   Spender's address
                         * @param value     Amount of allowance
                         * @param deadline  The time at which the signature expires (unix time), or max uint256 value to signal no expiration
                         * @param v         v of the signature
                         * @param r         r of the signature
                         * @param s         s of the signature
                         */
                        function _permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            _permit(owner, spender, value, deadline, abi.encodePacked(r, s, v));
                        }
                        /**
                         * @notice Verify a signed approval permit and execute if valid
                         * @dev EOA wallet signatures should be packed in the order of r, s, v.
                         * @param owner      Token owner's address (Authorizer)
                         * @param spender    Spender's address
                         * @param value      Amount of allowance
                         * @param deadline   The time at which the signature expires (unix time), or max uint256 value to signal no expiration
                         * @param signature  Signature byte array signed by an EOA wallet or a contract wallet
                         */
                        function _permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            bytes memory signature
                        ) internal {
                            require(
                                deadline == type(uint256).max || deadline >= now,
                                "FiatTokenV2: permit is expired"
                            );
                            bytes32 typedDataHash = MessageHashUtils.toTypedDataHash(
                                _domainSeparator(),
                                keccak256(
                                    abi.encode(
                                        PERMIT_TYPEHASH,
                                        owner,
                                        spender,
                                        value,
                                        _permitNonces[owner]++,
                                        deadline
                                    )
                                )
                            );
                            require(
                                SignatureChecker.isValidSignatureNow(
                                    owner,
                                    typedDataHash,
                                    signature
                                ),
                                "EIP2612: invalid signature"
                            );
                            _approve(owner, spender, value);
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { AbstractFiatTokenV1 } from "../v1/AbstractFiatTokenV1.sol";
                    abstract contract AbstractFiatTokenV2 is AbstractFiatTokenV1 {
                        function _increaseAllowance(
                            address owner,
                            address spender,
                            uint256 increment
                        ) internal virtual;
                        function _decreaseAllowance(
                            address owner,
                            address spender,
                            uint256 decrement
                        ) internal virtual;
                    }
                    /**
                     * SPDX-License-Identifier: MIT
                     *
                     * Copyright (c) 2016 Smart Contract Solutions, Inc.
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * Permission is hereby granted, free of charge, to any person obtaining a copy
                     * of this software and associated documentation files (the "Software"), to deal
                     * in the Software without restriction, including without limitation the rights
                     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                     * copies of the Software, and to permit persons to whom the Software is
                     * furnished to do so, subject to the following conditions:
                     *
                     * The above copyright notice and this permission notice shall be included in
                     * copies or substantial portions of the Software.
                     *
                     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
                     * SOFTWARE.
                     */
                    pragma solidity 0.6.12;
                    import { Ownable } from "./Ownable.sol";
                    /**
                     * @notice Base contract which allows children to implement an emergency stop
                     * mechanism
                     * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/feb665136c0dae9912e08397c1a21c4af3651ef3/contracts/lifecycle/Pausable.sol
                     * Modifications:
                     * 1. Added pauser role, switched pause/unpause to be onlyPauser (6/14/2018)
                     * 2. Removed whenNotPause/whenPaused from pause/unpause (6/14/2018)
                     * 3. Removed whenPaused (6/14/2018)
                     * 4. Switches ownable library to use ZeppelinOS (7/12/18)
                     * 5. Remove constructor (7/13/18)
                     * 6. Reformat, conform to Solidity 0.6 syntax and add error messages (5/13/20)
                     * 7. Make public functions external (5/27/20)
                     */
                    contract Pausable is Ownable {
                        event Pause();
                        event Unpause();
                        event PauserChanged(address indexed newAddress);
                        address public pauser;
                        bool public paused = false;
                        /**
                         * @dev Modifier to make a function callable only when the contract is not paused.
                         */
                        modifier whenNotPaused() {
                            require(!paused, "Pausable: paused");
                            _;
                        }
                        /**
                         * @dev throws if called by any account other than the pauser
                         */
                        modifier onlyPauser() {
                            require(msg.sender == pauser, "Pausable: caller is not the pauser");
                            _;
                        }
                        /**
                         * @dev called by the owner to pause, triggers stopped state
                         */
                        function pause() external onlyPauser {
                            paused = true;
                            emit Pause();
                        }
                        /**
                         * @dev called by the owner to unpause, returns to normal state
                         */
                        function unpause() external onlyPauser {
                            paused = false;
                            emit Unpause();
                        }
                        /**
                         * @notice Updates the pauser address.
                         * @param _newPauser The address of the new pauser.
                         */
                        function updatePauser(address _newPauser) external onlyOwner {
                            require(
                                _newPauser != address(0),
                                "Pausable: new pauser is the zero address"
                            );
                            pauser = _newPauser;
                            emit PauserChanged(pauser);
                        }
                    }
                    /**
                     * SPDX-License-Identifier: MIT
                     *
                     * Copyright (c) 2018 zOS Global Limited.
                     * Copyright (c) 2018-2020 CENTRE SECZ
                     *
                     * Permission is hereby granted, free of charge, to any person obtaining a copy
                     * of this software and associated documentation files (the "Software"), to deal
                     * in the Software without restriction, including without limitation the rights
                     * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
                     * copies of the Software, and to permit persons to whom the Software is
                     * furnished to do so, subject to the following conditions:
                     *
                     * The above copyright notice and this permission notice shall be included in
                     * copies or substantial portions of the Software.
                     *
                     * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
                     * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
                     * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
                     * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
                     * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
                     * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
                     * SOFTWARE.
                     */
                    pragma solidity 0.6.12;
                    /**
                     * @notice The Ownable contract has an owner address, and provides basic
                     * authorization control functions
                     * @dev Forked from https://github.com/OpenZeppelin/openzeppelin-labs/blob/3887ab77b8adafba4a26ace002f3a684c1a3388b/upgradeability_ownership/contracts/ownership/Ownable.sol
                     * Modifications:
                     * 1. Consolidate OwnableStorage into this contract (7/13/18)
                     * 2. Reformat, conform to Solidity 0.6 syntax, and add error messages (5/13/20)
                     * 3. Make public functions external (5/27/20)
                     */
                    contract Ownable {
                        // Owner of the contract
                        address private _owner;
                        /**
                         * @dev Event to show ownership has been transferred
                         * @param previousOwner representing the address of the previous owner
                         * @param newOwner representing the address of the new owner
                         */
                        event OwnershipTransferred(address previousOwner, address newOwner);
                        /**
                         * @dev The constructor sets the original owner of the contract to the sender account.
                         */
                        constructor() public {
                            setOwner(msg.sender);
                        }
                        /**
                         * @dev Tells the address of the owner
                         * @return the address of the owner
                         */
                        function owner() external view returns (address) {
                            return _owner;
                        }
                        /**
                         * @dev Sets a new owner address
                         */
                        function setOwner(address newOwner) internal {
                            _owner = newOwner;
                        }
                        /**
                         * @dev Throws if called by any account other than the owner.
                         */
                        modifier onlyOwner() {
                            require(msg.sender == _owner, "Ownable: caller is not the owner");
                            _;
                        }
                        /**
                         * @dev Allows the current owner to transfer control of the contract to a newOwner.
                         * @param newOwner The address to transfer ownership to.
                         */
                        function transferOwnership(address newOwner) external onlyOwner {
                            require(
                                newOwner != address(0),
                                "Ownable: new owner is the zero address"
                            );
                            emit OwnershipTransferred(_owner, newOwner);
                            setOwner(newOwner);
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { SafeMath } from "@openzeppelin/contracts/math/SafeMath.sol";
                    import { AbstractFiatTokenV1 } from "./AbstractFiatTokenV1.sol";
                    import { Ownable } from "./Ownable.sol";
                    import { Pausable } from "./Pausable.sol";
                    import { Blacklistable } from "./Blacklistable.sol";
                    /**
                     * @title FiatToken
                     * @dev ERC20 Token backed by fiat reserves
                     */
                    contract FiatTokenV1 is AbstractFiatTokenV1, Ownable, Pausable, Blacklistable {
                        using SafeMath for uint256;
                        string public name;
                        string public symbol;
                        uint8 public decimals;
                        string public currency;
                        address public masterMinter;
                        bool internal initialized;
                        /// @dev A mapping that stores the balance and blacklist states for a given address.
                        /// The first bit defines whether the address is blacklisted (1 if blacklisted, 0 otherwise).
                        /// The last 255 bits define the balance for the address.
                        mapping(address => uint256) internal balanceAndBlacklistStates;
                        mapping(address => mapping(address => uint256)) internal allowed;
                        uint256 internal totalSupply_ = 0;
                        mapping(address => bool) internal minters;
                        mapping(address => uint256) internal minterAllowed;
                        event Mint(address indexed minter, address indexed to, uint256 amount);
                        event Burn(address indexed burner, uint256 amount);
                        event MinterConfigured(address indexed minter, uint256 minterAllowedAmount);
                        event MinterRemoved(address indexed oldMinter);
                        event MasterMinterChanged(address indexed newMasterMinter);
                        /**
                         * @notice Initializes the fiat token contract.
                         * @param tokenName       The name of the fiat token.
                         * @param tokenSymbol     The symbol of the fiat token.
                         * @param tokenCurrency   The fiat currency that the token represents.
                         * @param tokenDecimals   The number of decimals that the token uses.
                         * @param newMasterMinter The masterMinter address for the fiat token.
                         * @param newPauser       The pauser address for the fiat token.
                         * @param newBlacklister  The blacklister address for the fiat token.
                         * @param newOwner        The owner of the fiat token.
                         */
                        function initialize(
                            string memory tokenName,
                            string memory tokenSymbol,
                            string memory tokenCurrency,
                            uint8 tokenDecimals,
                            address newMasterMinter,
                            address newPauser,
                            address newBlacklister,
                            address newOwner
                        ) public {
                            require(!initialized, "FiatToken: contract is already initialized");
                            require(
                                newMasterMinter != address(0),
                                "FiatToken: new masterMinter is the zero address"
                            );
                            require(
                                newPauser != address(0),
                                "FiatToken: new pauser is the zero address"
                            );
                            require(
                                newBlacklister != address(0),
                                "FiatToken: new blacklister is the zero address"
                            );
                            require(
                                newOwner != address(0),
                                "FiatToken: new owner is the zero address"
                            );
                            name = tokenName;
                            symbol = tokenSymbol;
                            currency = tokenCurrency;
                            decimals = tokenDecimals;
                            masterMinter = newMasterMinter;
                            pauser = newPauser;
                            blacklister = newBlacklister;
                            setOwner(newOwner);
                            initialized = true;
                        }
                        /**
                         * @dev Throws if called by any account other than a minter.
                         */
                        modifier onlyMinters() {
                            require(minters[msg.sender], "FiatToken: caller is not a minter");
                            _;
                        }
                        /**
                         * @notice Mints fiat tokens to an address.
                         * @param _to The address that will receive the minted tokens.
                         * @param _amount The amount of tokens to mint. Must be less than or equal
                         * to the minterAllowance of the caller.
                         * @return True if the operation was successful.
                         */
                        function mint(address _to, uint256 _amount)
                            external
                            whenNotPaused
                            onlyMinters
                            notBlacklisted(msg.sender)
                            notBlacklisted(_to)
                            returns (bool)
                        {
                            require(_to != address(0), "FiatToken: mint to the zero address");
                            require(_amount > 0, "FiatToken: mint amount not greater than 0");
                            uint256 mintingAllowedAmount = minterAllowed[msg.sender];
                            require(
                                _amount <= mintingAllowedAmount,
                                "FiatToken: mint amount exceeds minterAllowance"
                            );
                            totalSupply_ = totalSupply_.add(_amount);
                            _setBalance(_to, _balanceOf(_to).add(_amount));
                            minterAllowed[msg.sender] = mintingAllowedAmount.sub(_amount);
                            emit Mint(msg.sender, _to, _amount);
                            emit Transfer(address(0), _to, _amount);
                            return true;
                        }
                        /**
                         * @dev Throws if called by any account other than the masterMinter
                         */
                        modifier onlyMasterMinter() {
                            require(
                                msg.sender == masterMinter,
                                "FiatToken: caller is not the masterMinter"
                            );
                            _;
                        }
                        /**
                         * @notice Gets the minter allowance for an account.
                         * @param minter The address to check.
                         * @return The remaining minter allowance for the account.
                         */
                        function minterAllowance(address minter) external view returns (uint256) {
                            return minterAllowed[minter];
                        }
                        /**
                         * @notice Checks if an account is a minter.
                         * @param account The address to check.
                         * @return True if the account is a minter, false if the account is not a minter.
                         */
                        function isMinter(address account) external view returns (bool) {
                            return minters[account];
                        }
                        /**
                         * @notice Gets the remaining amount of fiat tokens a spender is allowed to transfer on
                         * behalf of the token owner.
                         * @param owner   The token owner's address.
                         * @param spender The spender's address.
                         * @return The remaining allowance.
                         */
                        function allowance(address owner, address spender)
                            external
                            override
                            view
                            returns (uint256)
                        {
                            return allowed[owner][spender];
                        }
                        /**
                         * @notice Gets the totalSupply of the fiat token.
                         * @return The totalSupply of the fiat token.
                         */
                        function totalSupply() external override view returns (uint256) {
                            return totalSupply_;
                        }
                        /**
                         * @notice Gets the fiat token balance of an account.
                         * @param account  The address to check.
                         * @return balance The fiat token balance of the account.
                         */
                        function balanceOf(address account)
                            external
                            override
                            view
                            returns (uint256)
                        {
                            return _balanceOf(account);
                        }
                        /**
                         * @notice Sets a fiat token allowance for a spender to spend on behalf of the caller.
                         * @param spender The spender's address.
                         * @param value   The allowance amount.
                         * @return True if the operation was successful.
                         */
                        function approve(address spender, uint256 value)
                            external
                            virtual
                            override
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(spender)
                            returns (bool)
                        {
                            _approve(msg.sender, spender, value);
                            return true;
                        }
                        /**
                         * @dev Internal function to set allowance.
                         * @param owner     Token owner's address.
                         * @param spender   Spender's address.
                         * @param value     Allowance amount.
                         */
                        function _approve(
                            address owner,
                            address spender,
                            uint256 value
                        ) internal override {
                            require(owner != address(0), "ERC20: approve from the zero address");
                            require(spender != address(0), "ERC20: approve to the zero address");
                            allowed[owner][spender] = value;
                            emit Approval(owner, spender, value);
                        }
                        /**
                         * @notice Transfers tokens from an address to another by spending the caller's allowance.
                         * @dev The caller must have some fiat token allowance on the payer's tokens.
                         * @param from  Payer's address.
                         * @param to    Payee's address.
                         * @param value Transfer amount.
                         * @return True if the operation was successful.
                         */
                        function transferFrom(
                            address from,
                            address to,
                            uint256 value
                        )
                            external
                            override
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(from)
                            notBlacklisted(to)
                            returns (bool)
                        {
                            require(
                                value <= allowed[from][msg.sender],
                                "ERC20: transfer amount exceeds allowance"
                            );
                            _transfer(from, to, value);
                            allowed[from][msg.sender] = allowed[from][msg.sender].sub(value);
                            return true;
                        }
                        /**
                         * @notice Transfers tokens from the caller.
                         * @param to    Payee's address.
                         * @param value Transfer amount.
                         * @return True if the operation was successful.
                         */
                        function transfer(address to, uint256 value)
                            external
                            override
                            whenNotPaused
                            notBlacklisted(msg.sender)
                            notBlacklisted(to)
                            returns (bool)
                        {
                            _transfer(msg.sender, to, value);
                            return true;
                        }
                        /**
                         * @dev Internal function to process transfers.
                         * @param from  Payer's address.
                         * @param to    Payee's address.
                         * @param value Transfer amount.
                         */
                        function _transfer(
                            address from,
                            address to,
                            uint256 value
                        ) internal override {
                            require(from != address(0), "ERC20: transfer from the zero address");
                            require(to != address(0), "ERC20: transfer to the zero address");
                            require(
                                value <= _balanceOf(from),
                                "ERC20: transfer amount exceeds balance"
                            );
                            _setBalance(from, _balanceOf(from).sub(value));
                            _setBalance(to, _balanceOf(to).add(value));
                            emit Transfer(from, to, value);
                        }
                        /**
                         * @notice Adds or updates a new minter with a mint allowance.
                         * @param minter The address of the minter.
                         * @param minterAllowedAmount The minting amount allowed for the minter.
                         * @return True if the operation was successful.
                         */
                        function configureMinter(address minter, uint256 minterAllowedAmount)
                            external
                            whenNotPaused
                            onlyMasterMinter
                            returns (bool)
                        {
                            minters[minter] = true;
                            minterAllowed[minter] = minterAllowedAmount;
                            emit MinterConfigured(minter, minterAllowedAmount);
                            return true;
                        }
                        /**
                         * @notice Removes a minter.
                         * @param minter The address of the minter to remove.
                         * @return True if the operation was successful.
                         */
                        function removeMinter(address minter)
                            external
                            onlyMasterMinter
                            returns (bool)
                        {
                            minters[minter] = false;
                            minterAllowed[minter] = 0;
                            emit MinterRemoved(minter);
                            return true;
                        }
                        /**
                         * @notice Allows a minter to burn some of its own tokens.
                         * @dev The caller must be a minter, must not be blacklisted, and the amount to burn
                         * should be less than or equal to the account's balance.
                         * @param _amount the amount of tokens to be burned.
                         */
                        function burn(uint256 _amount)
                            external
                            whenNotPaused
                            onlyMinters
                            notBlacklisted(msg.sender)
                        {
                            uint256 balance = _balanceOf(msg.sender);
                            require(_amount > 0, "FiatToken: burn amount not greater than 0");
                            require(balance >= _amount, "FiatToken: burn amount exceeds balance");
                            totalSupply_ = totalSupply_.sub(_amount);
                            _setBalance(msg.sender, balance.sub(_amount));
                            emit Burn(msg.sender, _amount);
                            emit Transfer(msg.sender, address(0), _amount);
                        }
                        /**
                         * @notice Updates the master minter address.
                         * @param _newMasterMinter The address of the new master minter.
                         */
                        function updateMasterMinter(address _newMasterMinter) external onlyOwner {
                            require(
                                _newMasterMinter != address(0),
                                "FiatToken: new masterMinter is the zero address"
                            );
                            masterMinter = _newMasterMinter;
                            emit MasterMinterChanged(masterMinter);
                        }
                        /**
                         * @inheritdoc Blacklistable
                         */
                        function _blacklist(address _account) internal override {
                            _setBlacklistState(_account, true);
                        }
                        /**
                         * @inheritdoc Blacklistable
                         */
                        function _unBlacklist(address _account) internal override {
                            _setBlacklistState(_account, false);
                        }
                        /**
                         * @dev Helper method that sets the blacklist state of an account.
                         * @param _account         The address of the account.
                         * @param _shouldBlacklist True if the account should be blacklisted, false if the account should be unblacklisted.
                         */
                        function _setBlacklistState(address _account, bool _shouldBlacklist)
                            internal
                            virtual
                        {
                            _deprecatedBlacklisted[_account] = _shouldBlacklist;
                        }
                        /**
                         * @dev Helper method that sets the balance of an account.
                         * @param _account The address of the account.
                         * @param _balance The new fiat token balance of the account.
                         */
                        function _setBalance(address _account, uint256 _balance) internal virtual {
                            balanceAndBlacklistStates[_account] = _balance;
                        }
                        /**
                         * @inheritdoc Blacklistable
                         */
                        function _isBlacklisted(address _account)
                            internal
                            virtual
                            override
                            view
                            returns (bool)
                        {
                            return _deprecatedBlacklisted[_account];
                        }
                        /**
                         * @dev Helper method to obtain the balance of an account.
                         * @param _account  The address of the account.
                         * @return          The fiat token balance of the account.
                         */
                        function _balanceOf(address _account)
                            internal
                            virtual
                            view
                            returns (uint256)
                        {
                            return balanceAndBlacklistStates[_account];
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { Ownable } from "./Ownable.sol";
                    /**
                     * @title Blacklistable Token
                     * @dev Allows accounts to be blacklisted by a "blacklister" role
                     */
                    abstract contract Blacklistable is Ownable {
                        address public blacklister;
                        mapping(address => bool) internal _deprecatedBlacklisted;
                        event Blacklisted(address indexed _account);
                        event UnBlacklisted(address indexed _account);
                        event BlacklisterChanged(address indexed newBlacklister);
                        /**
                         * @dev Throws if called by any account other than the blacklister.
                         */
                        modifier onlyBlacklister() {
                            require(
                                msg.sender == blacklister,
                                "Blacklistable: caller is not the blacklister"
                            );
                            _;
                        }
                        /**
                         * @dev Throws if argument account is blacklisted.
                         * @param _account The address to check.
                         */
                        modifier notBlacklisted(address _account) {
                            require(
                                !_isBlacklisted(_account),
                                "Blacklistable: account is blacklisted"
                            );
                            _;
                        }
                        /**
                         * @notice Checks if account is blacklisted.
                         * @param _account The address to check.
                         * @return True if the account is blacklisted, false if the account is not blacklisted.
                         */
                        function isBlacklisted(address _account) external view returns (bool) {
                            return _isBlacklisted(_account);
                        }
                        /**
                         * @notice Adds account to blacklist.
                         * @param _account The address to blacklist.
                         */
                        function blacklist(address _account) external onlyBlacklister {
                            _blacklist(_account);
                            emit Blacklisted(_account);
                        }
                        /**
                         * @notice Removes account from blacklist.
                         * @param _account The address to remove from the blacklist.
                         */
                        function unBlacklist(address _account) external onlyBlacklister {
                            _unBlacklist(_account);
                            emit UnBlacklisted(_account);
                        }
                        /**
                         * @notice Updates the blacklister address.
                         * @param _newBlacklister The address of the new blacklister.
                         */
                        function updateBlacklister(address _newBlacklister) external onlyOwner {
                            require(
                                _newBlacklister != address(0),
                                "Blacklistable: new blacklister is the zero address"
                            );
                            blacklister = _newBlacklister;
                            emit BlacklisterChanged(blacklister);
                        }
                        /**
                         * @dev Checks if account is blacklisted.
                         * @param _account The address to check.
                         * @return true if the account is blacklisted, false otherwise.
                         */
                        function _isBlacklisted(address _account)
                            internal
                            virtual
                            view
                            returns (bool);
                        /**
                         * @dev Helper method that blacklists an account.
                         * @param _account The address to blacklist.
                         */
                        function _blacklist(address _account) internal virtual;
                        /**
                         * @dev Helper method that unblacklists an account.
                         * @param _account The address to unblacklist.
                         */
                        function _unBlacklist(address _account) internal virtual;
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
                    abstract contract AbstractFiatTokenV1 is IERC20 {
                        function _approve(
                            address owner,
                            address spender,
                            uint256 value
                        ) internal virtual;
                        function _transfer(
                            address from,
                            address to,
                            uint256 value
                        ) internal virtual;
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { Ownable } from "../v1/Ownable.sol";
                    import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
                    import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/SafeERC20.sol";
                    contract Rescuable is Ownable {
                        using SafeERC20 for IERC20;
                        address private _rescuer;
                        event RescuerChanged(address indexed newRescuer);
                        /**
                         * @notice Returns current rescuer
                         * @return Rescuer's address
                         */
                        function rescuer() external view returns (address) {
                            return _rescuer;
                        }
                        /**
                         * @notice Revert if called by any account other than the rescuer.
                         */
                        modifier onlyRescuer() {
                            require(msg.sender == _rescuer, "Rescuable: caller is not the rescuer");
                            _;
                        }
                        /**
                         * @notice Rescue ERC20 tokens locked up in this contract.
                         * @param tokenContract ERC20 token contract address
                         * @param to        Recipient address
                         * @param amount    Amount to withdraw
                         */
                        function rescueERC20(
                            IERC20 tokenContract,
                            address to,
                            uint256 amount
                        ) external onlyRescuer {
                            tokenContract.safeTransfer(to, amount);
                        }
                        /**
                         * @notice Updates the rescuer address.
                         * @param newRescuer The address of the new rescuer.
                         */
                        function updateRescuer(address newRescuer) external onlyOwner {
                            require(
                                newRescuer != address(0),
                                "Rescuable: new rescuer is the zero address"
                            );
                            _rescuer = newRescuer;
                            emit RescuerChanged(newRescuer);
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { FiatTokenV1 } from "../v1/FiatTokenV1.sol";
                    import { Rescuable } from "./Rescuable.sol";
                    /**
                     * @title FiatTokenV1_1
                     * @dev ERC20 Token backed by fiat reserves
                     */
                    contract FiatTokenV1_1 is FiatTokenV1, Rescuable {
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    import { ECRecover } from "./ECRecover.sol";
                    import { IERC1271 } from "../interface/IERC1271.sol";
                    /**
                     * @dev Signature verification helper that can be used instead of `ECRecover.recover` to seamlessly support both ECDSA
                     * signatures from externally owned accounts (EOAs) as well as ERC1271 signatures from smart contract wallets.
                     *
                     * Adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/21bb89ef5bfc789b9333eb05e3ba2b7b284ac77c/contracts/utils/cryptography/SignatureChecker.sol
                     */
                    library SignatureChecker {
                        /**
                         * @dev Checks if a signature is valid for a given signer and data hash. If the signer is a smart contract, the
                         * signature is validated against that smart contract using ERC1271, otherwise it's validated using `ECRecover.recover`.
                         * @param signer        Address of the claimed signer
                         * @param digest        Keccak-256 hash digest of the signed message
                         * @param signature     Signature byte array associated with hash
                         */
                        function isValidSignatureNow(
                            address signer,
                            bytes32 digest,
                            bytes memory signature
                        ) external view returns (bool) {
                            if (!isContract(signer)) {
                                return ECRecover.recover(digest, signature) == signer;
                            }
                            return isValidERC1271SignatureNow(signer, digest, signature);
                        }
                        /**
                         * @dev Checks if a signature is valid for a given signer and data hash. The signature is validated
                         * against the signer smart contract using ERC1271.
                         * @param signer        Address of the claimed signer
                         * @param digest        Keccak-256 hash digest of the signed message
                         * @param signature     Signature byte array associated with hash
                         *
                         * NOTE: Unlike ECDSA signatures, contract signatures are revocable, and the outcome of this function can thus
                         * change through time. It could return true at block N and false at block N+1 (or the opposite).
                         */
                        function isValidERC1271SignatureNow(
                            address signer,
                            bytes32 digest,
                            bytes memory signature
                        ) internal view returns (bool) {
                            (bool success, bytes memory result) = signer.staticcall(
                                abi.encodeWithSelector(
                                    IERC1271.isValidSignature.selector,
                                    digest,
                                    signature
                                )
                            );
                            return (success &&
                                result.length >= 32 &&
                                abi.decode(result, (bytes32)) ==
                                bytes32(IERC1271.isValidSignature.selector));
                        }
                        /**
                         * @dev Checks if the input address is a smart contract.
                         */
                        function isContract(address addr) internal view returns (bool) {
                            uint256 size;
                            assembly {
                                size := extcodesize(addr)
                            }
                            return size > 0;
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    /**
                     * @dev Signature message hash utilities for producing digests to be consumed by {ECDSA} recovery or signing.
                     *
                     * The library provides methods for generating a hash of a message that conforms to the
                     * https://eips.ethereum.org/EIPS/eip-191[EIP 191] and https://eips.ethereum.org/EIPS/eip-712[EIP 712]
                     * specifications.
                     */
                    library MessageHashUtils {
                        /**
                         * @dev Returns the keccak256 digest of an EIP-712 typed data (EIP-191 version `0x01`).
                         * Adapted from https://github.com/OpenZeppelin/openzeppelin-contracts/blob/21bb89ef5bfc789b9333eb05e3ba2b7b284ac77c/contracts/utils/cryptography/MessageHashUtils.sol
                         *
                         * The digest is calculated from a `domainSeparator` and a `structHash`, by prefixing them with
                         * `\\x19\\x01` and hashing the result. It corresponds to the hash signed by the
                         * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] JSON-RPC method as part of EIP-712.
                         *
                         * @param domainSeparator    Domain separator
                         * @param structHash         Hashed EIP-712 data struct
                         * @return digest            The keccak256 digest of an EIP-712 typed data
                         */
                        function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash)
                            internal
                            pure
                            returns (bytes32 digest)
                        {
                            assembly {
                                let ptr := mload(0x40)
                                mstore(ptr, "\\x19\\x01")
                                mstore(add(ptr, 0x02), domainSeparator)
                                mstore(add(ptr, 0x22), structHash)
                                digest := keccak256(ptr, 0x42)
                            }
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    /**
                     * @title EIP712
                     * @notice A library that provides EIP712 helper functions
                     */
                    library EIP712 {
                        /**
                         * @notice Make EIP712 domain separator
                         * @param name      Contract name
                         * @param version   Contract version
                         * @param chainId   Blockchain ID
                         * @return Domain separator
                         */
                        function makeDomainSeparator(
                            string memory name,
                            string memory version,
                            uint256 chainId
                        ) internal view returns (bytes32) {
                            return
                                keccak256(
                                    abi.encode(
                                        // keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)")
                                        0x8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f,
                                        keccak256(bytes(name)),
                                        keccak256(bytes(version)),
                                        chainId,
                                        address(this)
                                    )
                                );
                        }
                        /**
                         * @notice Make EIP712 domain separator
                         * @param name      Contract name
                         * @param version   Contract version
                         * @return Domain separator
                         */
                        function makeDomainSeparator(string memory name, string memory version)
                            internal
                            view
                            returns (bytes32)
                        {
                            uint256 chainId;
                            assembly {
                                chainId := chainid()
                            }
                            return makeDomainSeparator(name, version, chainId);
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    /**
                     * @title ECRecover
                     * @notice A library that provides a safe ECDSA recovery function
                     */
                    library ECRecover {
                        /**
                         * @notice Recover signer's address from a signed message
                         * @dev Adapted from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/65e4ffde586ec89af3b7e9140bdc9235d1254853/contracts/cryptography/ECDSA.sol
                         * Modifications: Accept v, r, and s as separate arguments
                         * @param digest    Keccak-256 hash digest of the signed message
                         * @param v         v of the signature
                         * @param r         r of the signature
                         * @param s         s of the signature
                         * @return Signer address
                         */
                        function recover(
                            bytes32 digest,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal pure returns (address) {
                            // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
                            // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
                            // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
                            // signatures from current libraries generate a unique signature with an s-value in the lower half order.
                            //
                            // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
                            // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
                            // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
                            // these malleable signatures as well.
                            if (
                                uint256(s) >
                                0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0
                            ) {
                                revert("ECRecover: invalid signature 's' value");
                            }
                            if (v != 27 && v != 28) {
                                revert("ECRecover: invalid signature 'v' value");
                            }
                            // If the signature is valid (and not malleable), return the signer address
                            address signer = ecrecover(digest, v, r, s);
                            require(signer != address(0), "ECRecover: invalid signature");
                            return signer;
                        }
                        /**
                         * @notice Recover signer's address from a signed message
                         * @dev Adapted from: https://github.com/OpenZeppelin/openzeppelin-contracts/blob/0053ee040a7ff1dbc39691c9e67a69f564930a88/contracts/utils/cryptography/ECDSA.sol
                         * @param digest    Keccak-256 hash digest of the signed message
                         * @param signature Signature byte array associated with hash
                         * @return Signer address
                         */
                        function recover(bytes32 digest, bytes memory signature)
                            internal
                            pure
                            returns (address)
                        {
                            require(signature.length == 65, "ECRecover: invalid signature length");
                            bytes32 r;
                            bytes32 s;
                            uint8 v;
                            // ecrecover takes the signature parameters, and the only way to get them
                            // currently is to use assembly.
                            /// @solidity memory-safe-assembly
                            assembly {
                                r := mload(add(signature, 0x20))
                                s := mload(add(signature, 0x40))
                                v := byte(0, mload(add(signature, 0x60)))
                            }
                            return recover(digest, v, r, s);
                        }
                    }
                    /**
                     * SPDX-License-Identifier: Apache-2.0
                     *
                     * Copyright (c) 2023, Circle Internet Financial, LLC.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     * http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity 0.6.12;
                    /**
                     * @dev Interface of the ERC1271 standard signature validation method for
                     * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].
                     */
                    interface IERC1271 {
                        /**
                         * @dev Should return whether the signature provided is valid for the provided data
                         * @param hash          Hash of the data to be signed
                         * @param signature     Signature byte array associated with the provided data hash
                         * @return magicValue   bytes4 magic value 0x1626ba7e when function passes
                         */
                        function isValidSignature(bytes32 hash, bytes memory signature)
                            external
                            view
                            returns (bytes4 magicValue);
                    }
                    

                    File 8 of 11: Lib_AddressManager
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.0 <0.8.0;
                    import "../utils/Context.sol";
                    /**
                     * @dev 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.
                     */
                    abstract contract Ownable is Context {
                        address private _owner;
                        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                        /**
                         * @dev Initializes the contract setting the deployer as the initial owner.
                         */
                        constructor () internal {
                            address msgSender = _msgSender();
                            _owner = msgSender;
                            emit OwnershipTransferred(address(0), msgSender);
                        }
                        /**
                         * @dev Returns the address of the current owner.
                         */
                        function owner() public view virtual returns (address) {
                            return _owner;
                        }
                        /**
                         * @dev Throws if called by any account other than the owner.
                         */
                        modifier onlyOwner() {
                            require(owner() == _msgSender(), "Ownable: caller is not the owner");
                            _;
                        }
                        /**
                         * @dev Leaves the contract without owner. It will not be possible to call
                         * `onlyOwner` functions anymore. Can only be called by the current owner.
                         *
                         * NOTE: Renouncing ownership will leave the contract without an owner,
                         * thereby removing any functionality that is only available to the owner.
                         */
                        function renounceOwnership() public virtual onlyOwner {
                            emit OwnershipTransferred(_owner, address(0));
                            _owner = address(0);
                        }
                        /**
                         * @dev Transfers ownership of the contract to a new account (`newOwner`).
                         * Can only be called by the current owner.
                         */
                        function transferOwnership(address newOwner) public virtual onlyOwner {
                            require(newOwner != address(0), "Ownable: new owner is the zero address");
                            emit OwnershipTransferred(_owner, newOwner);
                            _owner = newOwner;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.6.0 <0.8.0;
                    /*
                     * @dev 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 GSN 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.
                     */
                    abstract contract Context {
                        function _msgSender() internal view virtual returns (address payable) {
                            return msg.sender;
                        }
                        function _msgData() internal view virtual returns (bytes memory) {
                            this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
                            return msg.data;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >0.5.0 <0.8.0;
                    /* External Imports */
                    import { Ownable } from "@openzeppelin/contracts/access/Ownable.sol";
                    /**
                     * @title Lib_AddressManager
                     */
                    contract Lib_AddressManager is Ownable {
                        /**********
                         * Events *
                         **********/
                        event AddressSet(
                            string indexed _name,
                            address _newAddress,
                            address _oldAddress
                        );
                        /*************
                         * Variables *
                         *************/
                        mapping (bytes32 => address) private addresses;
                        /********************
                         * Public Functions *
                         ********************/
                        /**
                         * Changes the address associated with a particular name.
                         * @param _name String name to associate an address with.
                         * @param _address Address to associate with the name.
                         */
                        function setAddress(
                            string memory _name,
                            address _address
                        )
                            external
                            onlyOwner
                        {
                            bytes32 nameHash = _getNameHash(_name);
                            address oldAddress = addresses[nameHash];
                            addresses[nameHash] = _address;
                            emit AddressSet(
                                _name,
                                _address,
                                oldAddress
                            );
                        }
                        /**
                         * Retrieves the address associated with a given name.
                         * @param _name Name to retrieve an address for.
                         * @return Address associated with the given name.
                         */
                        function getAddress(
                            string memory _name
                        )
                            external
                            view
                            returns (
                                address
                            )
                        {
                            return addresses[_getNameHash(_name)];
                        }
                        /**********************
                         * Internal Functions *
                         **********************/
                        /**
                         * Computes the hash of a name.
                         * @param _name Name to compute a hash for.
                         * @return Hash of the given name.
                         */
                        function _getNameHash(
                            string memory _name
                        )
                            internal
                            pure
                            returns (
                                bytes32
                            )
                        {
                            return keccak256(abi.encodePacked(_name));
                        }
                    }
                    

                    File 9 of 11: L1CrossDomainMessenger
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    // Contracts
                    import { CrossDomainMessenger } from "src/universal/CrossDomainMessenger.sol";
                    // Libraries
                    import { Predeploys } from "src/libraries/Predeploys.sol";
                    // Interfaces
                    import { ISemver } from "interfaces/universal/ISemver.sol";
                    import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
                    import { IOptimismPortal2 as IOptimismPortal } from "interfaces/L1/IOptimismPortal2.sol";
                    /// @custom:proxied true
                    /// @title L1CrossDomainMessenger
                    /// @notice The L1CrossDomainMessenger is a message passing interface between L1 and L2 responsible
                    ///         for sending and receiving data on the L1 side. Users are encouraged to use this
                    ///         interface instead of interacting with lower-level contracts directly.
                    contract L1CrossDomainMessenger is CrossDomainMessenger, ISemver {
                        /// @notice Contract of the SuperchainConfig.
                        ISuperchainConfig public superchainConfig;
                        /// @notice Contract of the OptimismPortal.
                        /// @custom:network-specific
                        IOptimismPortal public portal;
                        /// @custom:legacy
                        /// @custom:spacer systemConfig
                        /// @notice Spacer taking up the legacy `systemConfig` slot.
                        address private spacer_253_0_20;
                        /// @notice Semantic version.
                        /// @custom:semver 2.6.0
                        string public constant version = "2.6.0";
                        /// @notice Constructs the L1CrossDomainMessenger contract.
                        constructor() {
                            _disableInitializers();
                        }
                        /// @notice Initializes the contract.
                        /// @param _superchainConfig Contract of the SuperchainConfig contract on this network.
                        /// @param _portal Contract of the OptimismPortal contract on this network.
                        function initialize(ISuperchainConfig _superchainConfig, IOptimismPortal _portal) external initializer {
                            superchainConfig = _superchainConfig;
                            portal = _portal;
                            __CrossDomainMessenger_init({ _otherMessenger: CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER) });
                        }
                        /// @notice Getter function for the OptimismPortal contract on this chain.
                        ///         Public getter is legacy and will be removed in the future. Use `portal()` instead.
                        /// @return Contract of the OptimismPortal on this chain.
                        /// @custom:legacy
                        function PORTAL() external view returns (IOptimismPortal) {
                            return portal;
                        }
                        /// @inheritdoc CrossDomainMessenger
                        function _sendMessage(address _to, uint64 _gasLimit, uint256 _value, bytes memory _data) internal override {
                            portal.depositTransaction{ value: _value }({
                                _to: _to,
                                _value: _value,
                                _gasLimit: _gasLimit,
                                _isCreation: false,
                                _data: _data
                            });
                        }
                        /// @inheritdoc CrossDomainMessenger
                        function _isOtherMessenger() internal view override returns (bool) {
                            return msg.sender == address(portal) && portal.l2Sender() == address(otherMessenger);
                        }
                        /// @inheritdoc CrossDomainMessenger
                        function _isUnsafeTarget(address _target) internal view override returns (bool) {
                            return _target == address(this) || _target == address(portal);
                        }
                        /// @inheritdoc CrossDomainMessenger
                        function paused() public view override returns (bool) {
                            return superchainConfig.paused();
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    // Libraries
                    import { Initializable } from "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
                    import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
                    import { SafeCall } from "src/libraries/SafeCall.sol";
                    import { Hashing } from "src/libraries/Hashing.sol";
                    import { Encoding } from "src/libraries/Encoding.sol";
                    import { Constants } from "src/libraries/Constants.sol";
                    /// @custom:legacy
                    /// @title CrossDomainMessengerLegacySpacer0
                    /// @notice Contract only exists to add a spacer to the CrossDomainMessenger where the
                    ///         libAddressManager variable used to exist. Must be the first contract in the inheritance
                    ///         tree of the CrossDomainMessenger.
                    contract CrossDomainMessengerLegacySpacer0 {
                        /// @custom:legacy
                        /// @custom:spacer libAddressManager
                        /// @notice Spacer for backwards compatibility.
                        address private spacer_0_0_20;
                    }
                    /// @custom:legacy
                    /// @title CrossDomainMessengerLegacySpacer1
                    /// @notice Contract only exists to add a spacer to the CrossDomainMessenger where the
                    ///         PausableUpgradable and OwnableUpgradeable variables used to exist. Must be
                    ///         the third contract in the inheritance tree of the CrossDomainMessenger.
                    contract CrossDomainMessengerLegacySpacer1 {
                        /// @custom:legacy
                        /// @custom:spacer ContextUpgradable's __gap
                        /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin
                        ///         ContextUpgradable.
                        uint256[50] private spacer_1_0_1600;
                        /// @custom:legacy
                        /// @custom:spacer OwnableUpgradeable's _owner
                        /// @notice Spacer for backwards compatibility.
                        ///         Come from OpenZeppelin OwnableUpgradeable.
                        address private spacer_51_0_20;
                        /// @custom:legacy
                        /// @custom:spacer OwnableUpgradeable's __gap
                        /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin
                        ///         OwnableUpgradeable.
                        uint256[49] private spacer_52_0_1568;
                        /// @custom:legacy
                        /// @custom:spacer PausableUpgradable's _paused
                        /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin
                        ///         PausableUpgradable.
                        bool private spacer_101_0_1;
                        /// @custom:legacy
                        /// @custom:spacer PausableUpgradable's __gap
                        /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin
                        ///         PausableUpgradable.
                        uint256[49] private spacer_102_0_1568;
                        /// @custom:legacy
                        /// @custom:spacer ReentrancyGuardUpgradeable's `_status` field.
                        /// @notice Spacer for backwards compatibility.
                        uint256 private spacer_151_0_32;
                        /// @custom:legacy
                        /// @custom:spacer ReentrancyGuardUpgradeable's __gap
                        /// @notice Spacer for backwards compatibility.
                        uint256[49] private spacer_152_0_1568;
                        /// @custom:legacy
                        /// @custom:spacer blockedMessages
                        /// @notice Spacer for backwards compatibility.
                        mapping(bytes32 => bool) private spacer_201_0_32;
                        /// @custom:legacy
                        /// @custom:spacer relayedMessages
                        /// @notice Spacer for backwards compatibility.
                        mapping(bytes32 => bool) private spacer_202_0_32;
                    }
                    /// @custom:upgradeable
                    /// @title CrossDomainMessenger
                    /// @notice CrossDomainMessenger is a base contract that provides the core logic for the L1 and L2
                    ///         cross-chain messenger contracts. It's designed to be a universal interface that only
                    ///         needs to be extended slightly to provide low-level message passing functionality on each
                    ///         chain it's deployed on. Currently only designed for message passing between two paired
                    ///         chains and does not support one-to-many interactions.
                    ///         Any changes to this contract MUST result in a semver bump for contracts that inherit it.
                    abstract contract CrossDomainMessenger is
                        CrossDomainMessengerLegacySpacer0,
                        Initializable,
                        CrossDomainMessengerLegacySpacer1
                    {
                        /// @notice Current message version identifier.
                        uint16 public constant MESSAGE_VERSION = 1;
                        /// @notice Constant overhead added to the base gas for a message.
                        uint64 public constant RELAY_CONSTANT_OVERHEAD = 200_000;
                        /// @notice Numerator for dynamic overhead added to the base gas for a message.
                        uint64 public constant MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR = 64;
                        /// @notice Denominator for dynamic overhead added to the base gas for a message.
                        uint64 public constant MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR = 63;
                        /// @notice Extra gas added to base gas for each byte of calldata in a message.
                        uint64 public constant MIN_GAS_CALLDATA_OVERHEAD = 16;
                        /// @notice Gas reserved for performing the external call in `relayMessage`.
                        uint64 public constant RELAY_CALL_OVERHEAD = 40_000;
                        /// @notice Gas reserved for finalizing the execution of `relayMessage` after the safe call.
                        uint64 public constant RELAY_RESERVED_GAS = 40_000;
                        /// @notice Gas reserved for the execution between the `hasMinGas` check and the external
                        ///         call in `relayMessage`.
                        uint64 public constant RELAY_GAS_CHECK_BUFFER = 5_000;
                        /// @notice Base gas required for any transaction in the EVM.
                        uint64 public constant TX_BASE_GAS = 21_000;
                        /// @notice Floor overhead per byte of non-zero calldata in a message. Calldata floor was
                        ///         introduced in EIP-7623.
                        uint64 public constant FLOOR_CALLDATA_OVERHEAD = 40;
                        /// @notice Overhead added to the internal message data when the full call to relayMessage is
                        ///         ABI encoded. This is a constant value that is specific to the V1 message encoding
                        ///         scheme. 260 is an upper bound, actual overhead can be as low as 228 bytes for an
                        ///         empty message.
                        uint64 public constant ENCODING_OVERHEAD = 260;
                        /// @notice Mapping of message hashes to boolean receipt values. Note that a message will only
                        ///         be present in this mapping if it has successfully been relayed on this chain, and
                        ///         can therefore not be relayed again.
                        mapping(bytes32 => bool) public successfulMessages;
                        /// @notice Address of the sender of the currently executing message on the other chain. If the
                        ///         value of this variable is the default value (0x00000000...dead) then no message is
                        ///         currently being executed. Use the xDomainMessageSender getter which will throw an
                        ///         error if this is the case.
                        address internal xDomainMsgSender;
                        /// @notice Nonce for the next message to be sent, without the message version applied. Use the
                        ///         messageNonce getter which will insert the message version into the nonce to give you
                        ///         the actual nonce to be used for the message.
                        uint240 internal msgNonce;
                        /// @notice Mapping of message hashes to a boolean if and only if the message has failed to be
                        ///         executed at least once. A message will not be present in this mapping if it
                        ///         successfully executed on the first attempt.
                        mapping(bytes32 => bool) public failedMessages;
                        /// @notice CrossDomainMessenger contract on the other chain.
                        /// @custom:network-specific
                        CrossDomainMessenger public otherMessenger;
                        /// @notice Reserve extra slots in the storage layout for future upgrades.
                        ///         A gap size of 43 was chosen here, so that the first slot used in a child contract
                        ///         would be 1 plus a multiple of 50.
                        uint256[43] private __gap;
                        /// @notice Emitted whenever a message is sent to the other chain.
                        /// @param target       Address of the recipient of the message.
                        /// @param sender       Address of the sender of the message.
                        /// @param message      Message to trigger the recipient address with.
                        /// @param messageNonce Unique nonce attached to the message.
                        /// @param gasLimit     Minimum gas limit that the message can be executed with.
                        event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit);
                        /// @notice Additional event data to emit, required as of Bedrock. Cannot be merged with the
                        ///         SentMessage event without breaking the ABI of this contract, this is good enough.
                        /// @param sender Address of the sender of the message.
                        /// @param value  ETH value sent along with the message to the recipient.
                        event SentMessageExtension1(address indexed sender, uint256 value);
                        /// @notice Emitted whenever a message is successfully relayed on this chain.
                        /// @param msgHash Hash of the message that was relayed.
                        event RelayedMessage(bytes32 indexed msgHash);
                        /// @notice Emitted whenever a message fails to be relayed on this chain.
                        /// @param msgHash Hash of the message that failed to be relayed.
                        event FailedRelayedMessage(bytes32 indexed msgHash);
                        /// @notice Sends a message to some target address on the other chain. Note that if the call
                        ///         always reverts, then the message will be unrelayable, and any ETH sent will be
                        ///         permanently locked. The same will occur if the target on the other chain is
                        ///         considered unsafe (see the _isUnsafeTarget() function).
                        /// @param _target      Target contract or wallet address.
                        /// @param _message     Message to trigger the target address with.
                        /// @param _minGasLimit Minimum gas limit that the message can be executed with.
                        function sendMessage(address _target, bytes calldata _message, uint32 _minGasLimit) external payable {
                            // Triggers a message to the other messenger. Note that the amount of gas provided to the
                            // message is the amount of gas requested by the user PLUS the base gas value. We want to
                            // guarantee the property that the call to the target contract will always have at least
                            // the minimum gas limit specified by the user.
                            _sendMessage({
                                _to: address(otherMessenger),
                                _gasLimit: baseGas(_message, _minGasLimit),
                                _value: msg.value,
                                _data: abi.encodeWithSelector(
                                    this.relayMessage.selector, messageNonce(), msg.sender, _target, msg.value, _minGasLimit, _message
                                )
                            });
                            emit SentMessage(_target, msg.sender, _message, messageNonce(), _minGasLimit);
                            emit SentMessageExtension1(msg.sender, msg.value);
                            unchecked {
                                ++msgNonce;
                            }
                        }
                        /// @notice Relays a message that was sent by the other CrossDomainMessenger contract. Can only
                        ///         be executed via cross-chain call from the other messenger OR if the message was
                        ///         already received once and is currently being replayed.
                        /// @param _nonce       Nonce of the message being relayed.
                        /// @param _sender      Address of the user who sent the message.
                        /// @param _target      Address that the message is targeted at.
                        /// @param _value       ETH value to send with the message.
                        /// @param _minGasLimit Minimum amount of gas that the message can be executed with.
                        /// @param _message     Message to send to the target.
                        function relayMessage(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _minGasLimit,
                            bytes calldata _message
                        )
                            external
                            payable
                        {
                            // On L1 this function will check the Portal for its paused status.
                            // On L2 this function should be a no-op, because paused will always return false.
                            require(paused() == false, "CrossDomainMessenger: paused");
                            (, uint16 version) = Encoding.decodeVersionedNonce(_nonce);
                            require(version < 2, "CrossDomainMessenger: only version 0 or 1 messages are supported at this time");
                            // If the message is version 0, then it's a migrated legacy withdrawal. We therefore need
                            // to check that the legacy version of the message has not already been relayed.
                            if (version == 0) {
                                bytes32 oldHash = Hashing.hashCrossDomainMessageV0(_target, _sender, _message, _nonce);
                                require(successfulMessages[oldHash] == false, "CrossDomainMessenger: legacy withdrawal already relayed");
                            }
                            // We use the v1 message hash as the unique identifier for the message because it commits
                            // to the value and minimum gas limit of the message.
                            bytes32 versionedHash =
                                Hashing.hashCrossDomainMessageV1(_nonce, _sender, _target, _value, _minGasLimit, _message);
                            if (_isOtherMessenger()) {
                                // These properties should always hold when the message is first submitted (as
                                // opposed to being replayed).
                                assert(msg.value == _value);
                                assert(!failedMessages[versionedHash]);
                            } else {
                                require(msg.value == 0, "CrossDomainMessenger: value must be zero unless message is from a system address");
                                require(failedMessages[versionedHash], "CrossDomainMessenger: message cannot be replayed");
                            }
                            require(
                                _isUnsafeTarget(_target) == false, "CrossDomainMessenger: cannot send message to blocked system address"
                            );
                            require(successfulMessages[versionedHash] == false, "CrossDomainMessenger: message has already been relayed");
                            // If there is not enough gas left to perform the external call and finish the execution,
                            // return early and assign the message to the failedMessages mapping.
                            // We are asserting that we have enough gas to:
                            // 1. Call the target contract (_minGasLimit + RELAY_CALL_OVERHEAD + RELAY_GAS_CHECK_BUFFER)
                            //   1.a. The RELAY_CALL_OVERHEAD is included in `hasMinGas`.
                            // 2. Finish the execution after the external call (RELAY_RESERVED_GAS).
                            //
                            // If `xDomainMsgSender` is not the default L2 sender, this function
                            // is being re-entered. This marks the message as failed to allow it to be replayed.
                            if (
                                !SafeCall.hasMinGas(_minGasLimit, RELAY_RESERVED_GAS + RELAY_GAS_CHECK_BUFFER)
                                    || xDomainMsgSender != Constants.DEFAULT_L2_SENDER
                            ) {
                                failedMessages[versionedHash] = true;
                                emit FailedRelayedMessage(versionedHash);
                                // Revert in this case if the transaction was triggered by the estimation address. This
                                // should only be possible during gas estimation or we have bigger problems. Reverting
                                // here will make the behavior of gas estimation change such that the gas limit
                                // computed will be the amount required to relay the message, even if that amount is
                                // greater than the minimum gas limit specified by the user.
                                if (tx.origin == Constants.ESTIMATION_ADDRESS) {
                                    revert("CrossDomainMessenger: failed to relay message");
                                }
                                return;
                            }
                            xDomainMsgSender = _sender;
                            bool success = SafeCall.call(_target, gasleft() - RELAY_RESERVED_GAS, _value, _message);
                            xDomainMsgSender = Constants.DEFAULT_L2_SENDER;
                            if (success) {
                                // This check is identical to one above, but it ensures that the same message cannot be relayed
                                // twice, and adds a layer of protection against rentrancy.
                                assert(successfulMessages[versionedHash] == false);
                                successfulMessages[versionedHash] = true;
                                emit RelayedMessage(versionedHash);
                            } else {
                                failedMessages[versionedHash] = true;
                                emit FailedRelayedMessage(versionedHash);
                                // Revert in this case if the transaction was triggered by the estimation address. This
                                // should only be possible during gas estimation or we have bigger problems. Reverting
                                // here will make the behavior of gas estimation change such that the gas limit
                                // computed will be the amount required to relay the message, even if that amount is
                                // greater than the minimum gas limit specified by the user.
                                if (tx.origin == Constants.ESTIMATION_ADDRESS) {
                                    revert("CrossDomainMessenger: failed to relay message");
                                }
                            }
                        }
                        /// @notice Retrieves the address of the contract or wallet that initiated the currently
                        ///         executing message on the other chain. Will throw an error if there is no message
                        ///         currently being executed. Allows the recipient of a call to see who triggered it.
                        /// @return Address of the sender of the currently executing message on the other chain.
                        function xDomainMessageSender() external view returns (address) {
                            require(
                                xDomainMsgSender != Constants.DEFAULT_L2_SENDER, "CrossDomainMessenger: xDomainMessageSender is not set"
                            );
                            return xDomainMsgSender;
                        }
                        /// @notice Retrieves the address of the paired CrossDomainMessenger contract on the other chain
                        ///         Public getter is legacy and will be removed in the future. Use `otherMessenger()` instead.
                        /// @return CrossDomainMessenger contract on the other chain.
                        /// @custom:legacy
                        function OTHER_MESSENGER() public view returns (CrossDomainMessenger) {
                            return otherMessenger;
                        }
                        /// @notice Retrieves the next message nonce. Message version will be added to the upper two
                        ///         bytes of the message nonce. Message version allows us to treat messages as having
                        ///         different structures.
                        /// @return Nonce of the next message to be sent, with added message version.
                        function messageNonce() public view returns (uint256) {
                            return Encoding.encodeVersionedNonce(msgNonce, MESSAGE_VERSION);
                        }
                        /// @notice Computes the amount of gas required to guarantee that a given message will be
                        ///         received on the other chain without running out of gas. Guaranteeing that a message
                        ///         will not run out of gas is important because this ensures that a message can always
                        ///         be replayed on the other chain if it fails to execute completely.
                        /// @param _message     Message to compute the amount of required gas for.
                        /// @param _minGasLimit Minimum desired gas limit when message goes to target.
                        /// @return Amount of gas required to guarantee message receipt.
                        function baseGas(bytes memory _message, uint32 _minGasLimit) public pure returns (uint64) {
                            // Base gas should really be computed on the fully encoded message but that would break the
                            // expected API, so we instead just add the encoding overhead to the message length inside
                            // of this function.
                            // We need a minimum amount of execution gas to ensure that the message will be received on
                            // the other side without running out of gas (stored within the failedMessages mapping).
                            // If we get beyond the hasMinGas check, then we *must* supply more than minGasLimit to
                            // the external call.
                            uint64 executionGas = uint64(
                                // Constant costs for relayMessage
                                RELAY_CONSTANT_OVERHEAD
                                // Covers dynamic parts of the CALL opcode
                                + RELAY_CALL_OVERHEAD
                                // Ensures execution of relayMessage completes after call
                                + RELAY_RESERVED_GAS
                                // Buffer between hasMinGas check and the CALL
                                + RELAY_GAS_CHECK_BUFFER
                                // Minimum gas limit, multiplied by 64/63 to account for EIP-150.
                                + ((_minGasLimit * MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR) / MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR)
                            );
                            // Total message size is the result of properly ABI encoding the call to relayMessage.
                            // Since we only get the message data and not the rest of the calldata, we use the
                            // ENCODING_OVERHEAD constant to conservatively account for the remaining bytes.
                            uint64 totalMessageSize = uint64(_message.length + ENCODING_OVERHEAD);
                            // Finally, replicate the transaction cost formula as defined after EIP-7623. This is
                            // mostly relevant in the L1 -> L2 case because we need to be able to cover the intrinsic
                            // cost of the message but it doesn't hurt in the L2 -> L1 case. After EIP-7623, the cost
                            // of a transaction is floored by its calldata size. We don't need to account for the
                            // contract creation case because this is always a call to relayMessage.
                            return TX_BASE_GAS
                                + uint64(
                                    Math.max(
                                        executionGas + (totalMessageSize * MIN_GAS_CALLDATA_OVERHEAD),
                                        (totalMessageSize * FLOOR_CALLDATA_OVERHEAD)
                                    )
                                );
                        }
                        /// @notice Initializer.
                        /// @param _otherMessenger CrossDomainMessenger contract on the other chain.
                        function __CrossDomainMessenger_init(CrossDomainMessenger _otherMessenger) internal onlyInitializing {
                            // We only want to set the xDomainMsgSender to the default value if it hasn't been initialized yet,
                            // meaning that this is a fresh contract deployment.
                            // This prevents resetting the xDomainMsgSender to the default value during an upgrade, which would enable
                            // a reentrant withdrawal to sandwhich the upgrade replay a withdrawal twice.
                            if (xDomainMsgSender == address(0)) {
                                xDomainMsgSender = Constants.DEFAULT_L2_SENDER;
                            }
                            otherMessenger = _otherMessenger;
                        }
                        /// @notice Sends a low-level message to the other messenger. Needs to be implemented by child
                        ///         contracts because the logic for this depends on the network where the messenger is
                        ///         being deployed.
                        /// @param _to       Recipient of the message on the other chain.
                        /// @param _gasLimit Minimum gas limit the message can be executed with.
                        /// @param _value    Amount of ETH to send with the message.
                        /// @param _data     Message data.
                        function _sendMessage(address _to, uint64 _gasLimit, uint256 _value, bytes memory _data) internal virtual;
                        /// @notice Checks whether the message is coming from the other messenger. Implemented by child
                        ///         contracts because the logic for this depends on the network where the messenger is
                        ///         being deployed.
                        /// @return Whether the message is coming from the other messenger.
                        function _isOtherMessenger() internal view virtual returns (bool);
                        /// @notice Checks whether a given call target is a system address that could cause the
                        ///         messenger to peform an unsafe action. This is NOT a mechanism for blocking user
                        ///         addresses. This is ONLY used to prevent the execution of messages to specific
                        ///         system addresses that could cause security issues, e.g., having the
                        ///         CrossDomainMessenger send messages to itself.
                        /// @param _target Address of the contract to check.
                        /// @return Whether or not the address is an unsafe system address.
                        function _isUnsafeTarget(address _target) internal view virtual returns (bool);
                        /// @notice This function should return true if the contract is paused.
                        ///         On L1 this function will check the SuperchainConfig for its paused status.
                        ///         On L2 this function should be a no-op.
                        /// @return Whether or not the contract is paused.
                        function paused() public view virtual returns (bool) {
                            return false;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title Predeploys
                    /// @notice Contains constant addresses for protocol contracts that are pre-deployed to the L2 system.
                    //          This excludes the preinstalls (non-protocol contracts).
                    library Predeploys {
                        /// @notice Number of predeploy-namespace addresses reserved for protocol usage.
                        uint256 internal constant PREDEPLOY_COUNT = 2048;
                        /// @custom:legacy
                        /// @notice Address of the LegacyMessagePasser predeploy. Deprecate. Use the updated
                        ///         L2ToL1MessagePasser contract instead.
                        address internal constant LEGACY_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;
                        /// @custom:legacy
                        /// @notice Address of the L1MessageSender predeploy. Deprecated. Use L2CrossDomainMessenger
                        ///         or access tx.origin (or msg.sender) in a L1 to L2 transaction instead.
                        ///         Not embedded into new OP-Stack chains.
                        address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;
                        /// @custom:legacy
                        /// @notice Address of the DeployerWhitelist predeploy. No longer active.
                        address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;
                        /// @notice Address of the canonical WETH contract.
                        address internal constant WETH = 0x4200000000000000000000000000000000000006;
                        /// @notice Address of the L2CrossDomainMessenger predeploy.
                        address internal constant L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007;
                        /// @notice Address of the GasPriceOracle predeploy. Includes fee information
                        ///         and helpers for computing the L1 portion of the transaction fee.
                        address internal constant GAS_PRICE_ORACLE = 0x420000000000000000000000000000000000000F;
                        /// @notice Address of the L2StandardBridge predeploy.
                        address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;
                        //// @notice Address of the SequencerFeeWallet predeploy.
                        address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;
                        /// @notice Address of the OptimismMintableERC20Factory predeploy.
                        address internal constant OPTIMISM_MINTABLE_ERC20_FACTORY = 0x4200000000000000000000000000000000000012;
                        /// @custom:legacy
                        /// @notice Address of the L1BlockNumber predeploy. Deprecated. Use the L1Block predeploy
                        ///         instead, which exposes more information about the L1 state.
                        address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;
                        /// @notice Address of the L2ERC721Bridge predeploy.
                        address internal constant L2_ERC721_BRIDGE = 0x4200000000000000000000000000000000000014;
                        /// @notice Address of the L1Block predeploy.
                        address internal constant L1_BLOCK_ATTRIBUTES = 0x4200000000000000000000000000000000000015;
                        /// @notice Address of the L2ToL1MessagePasser predeploy.
                        address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000016;
                        /// @notice Address of the OptimismMintableERC721Factory predeploy.
                        address internal constant OPTIMISM_MINTABLE_ERC721_FACTORY = 0x4200000000000000000000000000000000000017;
                        /// @notice Address of the ProxyAdmin predeploy.
                        address internal constant PROXY_ADMIN = 0x4200000000000000000000000000000000000018;
                        /// @notice Address of the BaseFeeVault predeploy.
                        address internal constant BASE_FEE_VAULT = 0x4200000000000000000000000000000000000019;
                        /// @notice Address of the L1FeeVault predeploy.
                        address internal constant L1_FEE_VAULT = 0x420000000000000000000000000000000000001A;
                        /// @notice Address of the OperatorFeeVault predeploy.
                        address internal constant OPERATOR_FEE_VAULT = 0x420000000000000000000000000000000000001b;
                        /// @notice Address of the SchemaRegistry predeploy.
                        address internal constant SCHEMA_REGISTRY = 0x4200000000000000000000000000000000000020;
                        /// @notice Address of the EAS predeploy.
                        address internal constant EAS = 0x4200000000000000000000000000000000000021;
                        /// @notice Address of the GovernanceToken predeploy.
                        address internal constant GOVERNANCE_TOKEN = 0x4200000000000000000000000000000000000042;
                        /// @custom:legacy
                        /// @notice Address of the LegacyERC20ETH predeploy. Deprecated. Balances are migrated to the
                        ///         state trie as of the Bedrock upgrade. Contract has been locked and write functions
                        ///         can no longer be accessed.
                        address internal constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;
                        /// @notice Address of the CrossL2Inbox predeploy.
                        address internal constant CROSS_L2_INBOX = 0x4200000000000000000000000000000000000022;
                        /// @notice Address of the L2ToL2CrossDomainMessenger predeploy.
                        address internal constant L2_TO_L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000023;
                        /// @notice Address of the SuperchainWETH predeploy.
                        address internal constant SUPERCHAIN_WETH = 0x4200000000000000000000000000000000000024;
                        /// @notice Address of the ETHLiquidity predeploy.
                        address internal constant ETH_LIQUIDITY = 0x4200000000000000000000000000000000000025;
                        /// @notice Address of the OptimismSuperchainERC20Factory predeploy.
                        address internal constant OPTIMISM_SUPERCHAIN_ERC20_FACTORY = 0x4200000000000000000000000000000000000026;
                        /// @notice Address of the OptimismSuperchainERC20Beacon predeploy.
                        address internal constant OPTIMISM_SUPERCHAIN_ERC20_BEACON = 0x4200000000000000000000000000000000000027;
                        // TODO: Precalculate the address of the implementation contract
                        /// @notice Arbitrary address of the OptimismSuperchainERC20 implementation contract.
                        address internal constant OPTIMISM_SUPERCHAIN_ERC20 = 0xB9415c6cA93bdC545D4c5177512FCC22EFa38F28;
                        /// @notice Address of the SuperchainTokenBridge predeploy.
                        address internal constant SUPERCHAIN_TOKEN_BRIDGE = 0x4200000000000000000000000000000000000028;
                        /// @notice Returns the name of the predeploy at the given address.
                        function getName(address _addr) internal pure returns (string memory out_) {
                            require(isPredeployNamespace(_addr), "Predeploys: address must be a predeploy");
                            if (_addr == LEGACY_MESSAGE_PASSER) return "LegacyMessagePasser";
                            if (_addr == L1_MESSAGE_SENDER) return "L1MessageSender";
                            if (_addr == DEPLOYER_WHITELIST) return "DeployerWhitelist";
                            if (_addr == WETH) return "WETH";
                            if (_addr == L2_CROSS_DOMAIN_MESSENGER) return "L2CrossDomainMessenger";
                            if (_addr == GAS_PRICE_ORACLE) return "GasPriceOracle";
                            if (_addr == L2_STANDARD_BRIDGE) return "L2StandardBridge";
                            if (_addr == SEQUENCER_FEE_WALLET) return "SequencerFeeVault";
                            if (_addr == OPTIMISM_MINTABLE_ERC20_FACTORY) return "OptimismMintableERC20Factory";
                            if (_addr == L1_BLOCK_NUMBER) return "L1BlockNumber";
                            if (_addr == L2_ERC721_BRIDGE) return "L2ERC721Bridge";
                            if (_addr == L1_BLOCK_ATTRIBUTES) return "L1Block";
                            if (_addr == L2_TO_L1_MESSAGE_PASSER) return "L2ToL1MessagePasser";
                            if (_addr == OPTIMISM_MINTABLE_ERC721_FACTORY) return "OptimismMintableERC721Factory";
                            if (_addr == PROXY_ADMIN) return "ProxyAdmin";
                            if (_addr == BASE_FEE_VAULT) return "BaseFeeVault";
                            if (_addr == L1_FEE_VAULT) return "L1FeeVault";
                            if (_addr == OPERATOR_FEE_VAULT) return "OperatorFeeVault";
                            if (_addr == SCHEMA_REGISTRY) return "SchemaRegistry";
                            if (_addr == EAS) return "EAS";
                            if (_addr == GOVERNANCE_TOKEN) return "GovernanceToken";
                            if (_addr == LEGACY_ERC20_ETH) return "LegacyERC20ETH";
                            if (_addr == CROSS_L2_INBOX) return "CrossL2Inbox";
                            if (_addr == L2_TO_L2_CROSS_DOMAIN_MESSENGER) return "L2ToL2CrossDomainMessenger";
                            if (_addr == SUPERCHAIN_WETH) return "SuperchainWETH";
                            if (_addr == ETH_LIQUIDITY) return "ETHLiquidity";
                            if (_addr == OPTIMISM_SUPERCHAIN_ERC20_FACTORY) return "OptimismSuperchainERC20Factory";
                            if (_addr == OPTIMISM_SUPERCHAIN_ERC20_BEACON) return "OptimismSuperchainERC20Beacon";
                            if (_addr == SUPERCHAIN_TOKEN_BRIDGE) return "SuperchainTokenBridge";
                            revert("Predeploys: unnamed predeploy");
                        }
                        /// @notice Returns true if the predeploy is not proxied.
                        function notProxied(address _addr) internal pure returns (bool) {
                            return _addr == GOVERNANCE_TOKEN || _addr == WETH;
                        }
                        /// @notice Returns true if the address is a defined predeploy that is embedded into new OP-Stack chains.
                        function isSupportedPredeploy(address _addr, bool _useInterop) internal pure returns (bool) {
                            return _addr == LEGACY_MESSAGE_PASSER || _addr == DEPLOYER_WHITELIST || _addr == WETH
                                || _addr == L2_CROSS_DOMAIN_MESSENGER || _addr == GAS_PRICE_ORACLE || _addr == L2_STANDARD_BRIDGE
                                || _addr == SEQUENCER_FEE_WALLET || _addr == OPTIMISM_MINTABLE_ERC20_FACTORY || _addr == L1_BLOCK_NUMBER
                                || _addr == L2_ERC721_BRIDGE || _addr == L1_BLOCK_ATTRIBUTES || _addr == L2_TO_L1_MESSAGE_PASSER
                                || _addr == OPTIMISM_MINTABLE_ERC721_FACTORY || _addr == PROXY_ADMIN || _addr == BASE_FEE_VAULT
                                || _addr == L1_FEE_VAULT || _addr == OPERATOR_FEE_VAULT || _addr == SCHEMA_REGISTRY || _addr == EAS
                                || _addr == GOVERNANCE_TOKEN || (_useInterop && _addr == CROSS_L2_INBOX)
                                || (_useInterop && _addr == L2_TO_L2_CROSS_DOMAIN_MESSENGER) || (_useInterop && _addr == SUPERCHAIN_WETH)
                                || (_useInterop && _addr == ETH_LIQUIDITY) || (_useInterop && _addr == SUPERCHAIN_TOKEN_BRIDGE);
                        }
                        function isPredeployNamespace(address _addr) internal pure returns (bool) {
                            return uint160(_addr) >> 11 == uint160(0x4200000000000000000000000000000000000000) >> 11;
                        }
                        /// @notice Function to compute the expected address of the predeploy implementation
                        ///         in the genesis state.
                        function predeployToCodeNamespace(address _addr) internal pure returns (address) {
                            require(
                                isPredeployNamespace(_addr), "Predeploys: can only derive code-namespace address for predeploy addresses"
                            );
                            return address(
                                uint160(uint256(uint160(_addr)) & 0xffff | uint256(uint160(0xc0D3C0d3C0d3C0D3c0d3C0d3c0D3C0d3c0d30000)))
                            );
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title ISemver
                    /// @notice ISemver is a simple contract for ensuring that contracts are
                    ///         versioned using semantic versioning.
                    interface ISemver {
                        /// @notice Getter for the semantic version of the contract. This is not
                        ///         meant to be used onchain but instead meant to be used by offchain
                        ///         tooling.
                        /// @return Semver contract version as a string.
                        function version() external view returns (string memory);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface ISuperchainConfig {
                        enum UpdateType {
                            GUARDIAN
                        }
                        event ConfigUpdate(UpdateType indexed updateType, bytes data);
                        event Initialized(uint8 version);
                        event Paused(string identifier);
                        event Unpaused();
                        function GUARDIAN_SLOT() external view returns (bytes32);
                        function PAUSED_SLOT() external view returns (bytes32);
                        function guardian() external view returns (address guardian_);
                        function initialize(address _guardian, bool _paused) external;
                        function pause(string memory _identifier) external;
                        function paused() external view returns (bool paused_);
                        function unpause() external;
                        function version() external view returns (string memory);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { Types } from "src/libraries/Types.sol";
                    import { GameType, Timestamp } from "src/dispute/lib/LibUDT.sol";
                    import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
                    import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
                    import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
                    import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
                    interface IOptimismPortal2 {
                        error AlreadyFinalized();
                        error BadTarget();
                        error Blacklisted();
                        error CallPaused();
                        error ContentLengthMismatch();
                        error EmptyItem();
                        error GasEstimation();
                        error InvalidDataRemainder();
                        error InvalidDisputeGame();
                        error InvalidGameType();
                        error InvalidHeader();
                        error InvalidMerkleProof();
                        error InvalidProof();
                        error LargeCalldata();
                        error NonReentrant();
                        error OutOfGas();
                        error ProposalNotValidated();
                        error SmallGasLimit();
                        error Unauthorized();
                        error UnexpectedList();
                        error UnexpectedString();
                        error Unproven();
                        error LegacyGame();
                        event DisputeGameBlacklisted(IDisputeGame indexed disputeGame);
                        event Initialized(uint8 version);
                        event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt);
                        event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);
                        event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
                        event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
                        event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter);
                        receive() external payable;
                        function blacklistDisputeGame(IDisputeGame _disputeGame) external;
                        function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) external view;
                        function depositTransaction(
                            address _to,
                            uint256 _value,
                            uint64 _gasLimit,
                            bool _isCreation,
                            bytes memory _data
                        )
                            external
                            payable;
                        function disputeGameBlacklist(IDisputeGame) external view returns (bool);
                        function disputeGameFactory() external view returns (IDisputeGameFactory);
                        function disputeGameFinalityDelaySeconds() external view returns (uint256);
                        function donateETH() external payable;
                        function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external;
                        function finalizeWithdrawalTransactionExternalProof(
                            Types.WithdrawalTransaction memory _tx,
                            address _proofSubmitter
                        )
                            external;
                        function finalizedWithdrawals(bytes32) external view returns (bool);
                        function guardian() external view returns (address);
                        function initialize(
                            IDisputeGameFactory _disputeGameFactory,
                            ISystemConfig _systemConfig,
                            ISuperchainConfig _superchainConfig,
                            GameType _initialRespectedGameType
                        )
                            external;
                        function l2Sender() external view returns (address);
                        function minimumGasLimit(uint64 _byteCount) external pure returns (uint64);
                        function numProofSubmitters(bytes32 _withdrawalHash) external view returns (uint256);
                        function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
                        function paused() external view returns (bool);
                        function proofMaturityDelaySeconds() external view returns (uint256);
                        function proofSubmitters(bytes32, uint256) external view returns (address);
                        function proveWithdrawalTransaction(
                            Types.WithdrawalTransaction memory _tx,
                            uint256 _disputeGameIndex,
                            Types.OutputRootProof memory _outputRootProof,
                            bytes[] memory _withdrawalProof
                        )
                            external;
                        function provenWithdrawals(
                            bytes32,
                            address
                        )
                            external
                            view
                            returns (IDisputeGame disputeGameProxy, uint64 timestamp); // nosemgrep
                        function respectedGameType() external view returns (GameType);
                        function respectedGameTypeUpdatedAt() external view returns (uint64);
                        function setRespectedGameType(GameType _gameType) external;
                        function superchainConfig() external view returns (ISuperchainConfig);
                        function systemConfig() external view returns (ISystemConfig);
                        function version() external pure returns (string memory);
                        function __constructor__(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) external;
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
                    pragma solidity ^0.8.2;
                    import "../../utils/AddressUpgradeable.sol";
                    /**
                     * @dev 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]
                     * ```
                     * 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]
                     * ```
                     * /// @custom:oz-upgrades-unsafe-allow constructor
                     * constructor() {
                     *     _disableInitializers();
                     * }
                     * ```
                     * ====
                     */
                    abstract contract Initializable {
                        /**
                         * @dev Indicates that the contract has been initialized.
                         * @custom:oz-retyped-from bool
                         */
                        uint8 private _initialized;
                        /**
                         * @dev Indicates that the contract is in the process of being initialized.
                         */
                        bool private _initializing;
                        /**
                         * @dev Triggered when the contract has been initialized or reinitialized.
                         */
                        event Initialized(uint8 version);
                        /**
                         * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
                         * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
                         */
                        modifier initializer() {
                            bool isTopLevelCall = !_initializing;
                            require(
                                (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
                                "Initializable: contract is already initialized"
                            );
                            _initialized = 1;
                            if (isTopLevelCall) {
                                _initializing = true;
                            }
                            _;
                            if (isTopLevelCall) {
                                _initializing = false;
                                emit Initialized(1);
                            }
                        }
                        /**
                         * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
                         * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
                         * used to initialize parent contracts.
                         *
                         * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
                         * initialization step. This is essential to configure modules that are added through upgrades and that require
                         * initialization.
                         *
                         * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
                         * a contract, executing them in the right order is up to the developer or operator.
                         */
                        modifier reinitializer(uint8 version) {
                            require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                            _initialized = version;
                            _initializing = true;
                            _;
                            _initializing = false;
                            emit Initialized(version);
                        }
                        /**
                         * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
                         * {initializer} and {reinitializer} modifiers, directly or indirectly.
                         */
                        modifier onlyInitializing() {
                            require(_initializing, "Initializable: contract is not initializing");
                            _;
                        }
                        /**
                         * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
                         * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
                         * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
                         * through proxies.
                         */
                        function _disableInitializers() internal virtual {
                            require(!_initializing, "Initializable: contract is initializing");
                            if (_initialized < type(uint8).max) {
                                _initialized = type(uint8).max;
                                emit Initialized(type(uint8).max);
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev Standard math utilities missing in the Solidity language.
                     */
                    library Math {
                        enum Rounding {
                            Down, // Toward negative infinity
                            Up, // Toward infinity
                            Zero // Toward zero
                        }
                        /**
                         * @dev Returns the largest of two numbers.
                         */
                        function max(uint256 a, uint256 b) internal pure returns (uint256) {
                            return a >= b ? a : b;
                        }
                        /**
                         * @dev Returns the smallest of two numbers.
                         */
                        function min(uint256 a, uint256 b) internal pure returns (uint256) {
                            return a < b ? a : b;
                        }
                        /**
                         * @dev Returns the average of two numbers. The result is rounded towards
                         * zero.
                         */
                        function average(uint256 a, uint256 b) internal pure returns (uint256) {
                            // (a + b) / 2 can overflow.
                            return (a & b) + (a ^ b) / 2;
                        }
                        /**
                         * @dev Returns the ceiling of the division of two numbers.
                         *
                         * This differs from standard division with `/` in that it rounds up instead
                         * of rounding down.
                         */
                        function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
                            // (a + b - 1) / b can overflow on addition, so we distribute.
                            return a == 0 ? 0 : (a - 1) / b + 1;
                        }
                        /**
                         * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
                         * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
                         * with further edits by Uniswap Labs also under MIT license.
                         */
                        function mulDiv(
                            uint256 x,
                            uint256 y,
                            uint256 denominator
                        ) internal pure returns (uint256 result) {
                            unchecked {
                                // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
                                // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
                                // variables such that product = prod1 * 2^256 + prod0.
                                uint256 prod0; // Least significant 256 bits of the product
                                uint256 prod1; // Most significant 256 bits of the product
                                assembly {
                                    let mm := mulmod(x, y, not(0))
                                    prod0 := mul(x, y)
                                    prod1 := sub(sub(mm, prod0), lt(mm, prod0))
                                }
                                // Handle non-overflow cases, 256 by 256 division.
                                if (prod1 == 0) {
                                    return prod0 / denominator;
                                }
                                // Make sure the result is less than 2^256. Also prevents denominator == 0.
                                require(denominator > prod1);
                                ///////////////////////////////////////////////
                                // 512 by 256 division.
                                ///////////////////////////////////////////////
                                // Make division exact by subtracting the remainder from [prod1 prod0].
                                uint256 remainder;
                                assembly {
                                    // Compute remainder using mulmod.
                                    remainder := mulmod(x, y, denominator)
                                    // Subtract 256 bit number from 512 bit number.
                                    prod1 := sub(prod1, gt(remainder, prod0))
                                    prod0 := sub(prod0, remainder)
                                }
                                // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
                                // See https://cs.stackexchange.com/q/138556/92363.
                                // Does not overflow because the denominator cannot be zero at this stage in the function.
                                uint256 twos = denominator & (~denominator + 1);
                                assembly {
                                    // Divide denominator by twos.
                                    denominator := div(denominator, twos)
                                    // Divide [prod1 prod0] by twos.
                                    prod0 := div(prod0, twos)
                                    // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                                    twos := add(div(sub(0, twos), twos), 1)
                                }
                                // Shift in bits from prod1 into prod0.
                                prod0 |= prod1 * twos;
                                // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
                                // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
                                // four bits. That is, denominator * inv = 1 mod 2^4.
                                uint256 inverse = (3 * denominator) ^ 2;
                                // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
                                // in modular arithmetic, doubling the correct bits in each step.
                                inverse *= 2 - denominator * inverse; // inverse mod 2^8
                                inverse *= 2 - denominator * inverse; // inverse mod 2^16
                                inverse *= 2 - denominator * inverse; // inverse mod 2^32
                                inverse *= 2 - denominator * inverse; // inverse mod 2^64
                                inverse *= 2 - denominator * inverse; // inverse mod 2^128
                                inverse *= 2 - denominator * inverse; // inverse mod 2^256
                                // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
                                // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
                                // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
                                // is no longer required.
                                result = prod0 * inverse;
                                return result;
                            }
                        }
                        /**
                         * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
                         */
                        function mulDiv(
                            uint256 x,
                            uint256 y,
                            uint256 denominator,
                            Rounding rounding
                        ) internal pure returns (uint256) {
                            uint256 result = mulDiv(x, y, denominator);
                            if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
                                result += 1;
                            }
                            return result;
                        }
                        /**
                         * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
                         *
                         * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
                         */
                        function sqrt(uint256 a) internal pure returns (uint256) {
                            if (a == 0) {
                                return 0;
                            }
                            // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
                            // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
                            // `msb(a) <= a < 2*msb(a)`.
                            // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
                            // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
                            // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
                            // good first aproximation of `sqrt(a)` with at least 1 correct bit.
                            uint256 result = 1;
                            uint256 x = a;
                            if (x >> 128 > 0) {
                                x >>= 128;
                                result <<= 64;
                            }
                            if (x >> 64 > 0) {
                                x >>= 64;
                                result <<= 32;
                            }
                            if (x >> 32 > 0) {
                                x >>= 32;
                                result <<= 16;
                            }
                            if (x >> 16 > 0) {
                                x >>= 16;
                                result <<= 8;
                            }
                            if (x >> 8 > 0) {
                                x >>= 8;
                                result <<= 4;
                            }
                            if (x >> 4 > 0) {
                                x >>= 4;
                                result <<= 2;
                            }
                            if (x >> 2 > 0) {
                                result <<= 1;
                            }
                            // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
                            // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
                            // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
                            // into the expected uint128 result.
                            unchecked {
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                return min(result, a / result);
                            }
                        }
                        /**
                         * @notice Calculates sqrt(a), following the selected rounding direction.
                         */
                        function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
                            uint256 result = sqrt(a);
                            if (rounding == Rounding.Up && result * result < a) {
                                result += 1;
                            }
                            return result;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title SafeCall
                    /// @notice Perform low level safe calls
                    library SafeCall {
                        /// @notice Performs a low level call without copying any returndata.
                        /// @dev Passes no calldata to the call context.
                        /// @param _target   Address to call
                        /// @param _gas      Amount of gas to pass to the call
                        /// @param _value    Amount of value to pass to the call
                        function send(address _target, uint256 _gas, uint256 _value) internal returns (bool success_) {
                            assembly {
                                success_ :=
                                    call(
                                        _gas, // gas
                                        _target, // recipient
                                        _value, // ether value
                                        0, // inloc
                                        0, // inlen
                                        0, // outloc
                                        0 // outlen
                                    )
                            }
                        }
                        /// @notice Perform a low level call with all gas without copying any returndata
                        /// @param _target   Address to call
                        /// @param _value    Amount of value to pass to the call
                        function send(address _target, uint256 _value) internal returns (bool success_) {
                            success_ = send(_target, gasleft(), _value);
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _gas      Amount of gas to pass to the call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function call(
                            address _target,
                            uint256 _gas,
                            uint256 _value,
                            bytes memory _calldata
                        )
                            internal
                            returns (bool success_)
                        {
                            assembly {
                                success_ :=
                                    call(
                                        _gas, // gas
                                        _target, // recipient
                                        _value, // ether value
                                        add(_calldata, 32), // inloc
                                        mload(_calldata), // inlen
                                        0, // outloc
                                        0 // outlen
                                    )
                            }
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function call(address _target, uint256 _value, bytes memory _calldata) internal returns (bool success_) {
                            success_ = call({ _target: _target, _gas: gasleft(), _value: _value, _calldata: _calldata });
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _calldata Calldata to pass to the call
                        function call(address _target, bytes memory _calldata) internal returns (bool success_) {
                            success_ = call({ _target: _target, _gas: gasleft(), _value: 0, _calldata: _calldata });
                        }
                        /// @notice Helper function to determine if there is sufficient gas remaining within the context
                        ///         to guarantee that the minimum gas requirement for a call will be met as well as
                        ///         optionally reserving a specified amount of gas for after the call has concluded.
                        /// @param _minGas      The minimum amount of gas that may be passed to the target context.
                        /// @param _reservedGas Optional amount of gas to reserve for the caller after the execution
                        ///                     of the target context.
                        /// @return `true` if there is enough gas remaining to safely supply `_minGas` to the target
                        ///         context as well as reserve `_reservedGas` for the caller after the execution of
                        ///         the target context.
                        /// @dev !!!!! FOOTGUN ALERT !!!!!
                        ///      1.) The 40_000 base buffer is to account for the worst case of the dynamic cost of the
                        ///          `CALL` opcode's `address_access_cost`, `positive_value_cost`, and
                        ///          `value_to_empty_account_cost` factors with an added buffer of 5,700 gas. It is
                        ///          still possible to self-rekt by initiating a withdrawal with a minimum gas limit
                        ///          that does not account for the `memory_expansion_cost` & `code_execution_cost`
                        ///          factors of the dynamic cost of the `CALL` opcode.
                        ///      2.) This function should *directly* precede the external call if possible. There is an
                        ///          added buffer to account for gas consumed between this check and the call, but it
                        ///          is only 5,700 gas.
                        ///      3.) Because EIP-150 ensures that a maximum of 63/64ths of the remaining gas in the call
                        ///          frame may be passed to a subcontext, we need to ensure that the gas will not be
                        ///          truncated.
                        ///      4.) Use wisely. This function is not a silver bullet.
                        function hasMinGas(uint256 _minGas, uint256 _reservedGas) internal view returns (bool) {
                            bool _hasMinGas;
                            assembly {
                                // Equation: gas × 63 ≥ minGas × 64 + 63(40_000 + reservedGas)
                                _hasMinGas := iszero(lt(mul(gas(), 63), add(mul(_minGas, 64), mul(add(40000, _reservedGas), 63))))
                            }
                            return _hasMinGas;
                        }
                        /// @notice Perform a low level call without copying any returndata. This function
                        ///         will revert if the call cannot be performed with the specified minimum
                        ///         gas.
                        /// @param _target   Address to call
                        /// @param _minGas   The minimum amount of gas that may be passed to the call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function callWithMinGas(
                            address _target,
                            uint256 _minGas,
                            uint256 _value,
                            bytes memory _calldata
                        )
                            internal
                            returns (bool)
                        {
                            bool _success;
                            bool _hasMinGas = hasMinGas(_minGas, 0);
                            assembly {
                                // Assertion: gasleft() >= (_minGas * 64) / 63 + 40_000
                                if iszero(_hasMinGas) {
                                    // Store the "Error(string)" selector in scratch space.
                                    mstore(0, 0x08c379a0)
                                    // Store the pointer to the string length in scratch space.
                                    mstore(32, 32)
                                    // Store the string.
                                    //
                                    // SAFETY:
                                    // - We pad the beginning of the string with two zero bytes as well as the
                                    // length (24) to ensure that we override the free memory pointer at offset
                                    // 0x40. This is necessary because the free memory pointer is likely to
                                    // be greater than 1 byte when this function is called, but it is incredibly
                                    // unlikely that it will be greater than 3 bytes. As for the data within
                                    // 0x60, it is ensured that it is 0 due to 0x60 being the zero offset.
                                    // - It's fine to clobber the free memory pointer, we're reverting.
                                    mstore(88, 0x0000185361666543616c6c3a204e6f7420656e6f75676820676173)
                                    // Revert with 'Error("SafeCall: Not enough gas")'
                                    revert(28, 100)
                                }
                                // The call will be supplied at least ((_minGas * 64) / 63) gas due to the
                                // above assertion. This ensures that, in all circumstances (except for when the
                                // `_minGas` does not account for the `memory_expansion_cost` and `code_execution_cost`
                                // factors of the dynamic cost of the `CALL` opcode), the call will receive at least
                                // the minimum amount of gas specified.
                                _success :=
                                    call(
                                        gas(), // gas
                                        _target, // recipient
                                        _value, // ether value
                                        add(_calldata, 32), // inloc
                                        mload(_calldata), // inlen
                                        0x00, // outloc
                                        0x00 // outlen
                                    )
                            }
                            return _success;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Libraries
                    import { Types } from "src/libraries/Types.sol";
                    import { Encoding } from "src/libraries/Encoding.sol";
                    /// @title Hashing
                    /// @notice Hashing handles Optimism's various different hashing schemes.
                    library Hashing {
                        /// @notice Computes the hash of the RLP encoded L2 transaction that would be generated when a
                        ///         given deposit is sent to the L2 system. Useful for searching for a deposit in the L2
                        ///         system.
                        /// @param _tx User deposit transaction to hash.
                        /// @return Hash of the RLP encoded L2 deposit transaction.
                        function hashDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes32) {
                            return keccak256(Encoding.encodeDepositTransaction(_tx));
                        }
                        /// @notice Computes the deposit transaction's "source hash", a value that guarantees the hash
                        ///         of the L2 transaction that corresponds to a deposit is unique and is
                        ///         deterministically generated from L1 transaction data.
                        /// @param _l1BlockHash Hash of the L1 block where the deposit was included.
                        /// @param _logIndex    The index of the log that created the deposit transaction.
                        /// @return Hash of the deposit transaction's "source hash".
                        function hashDepositSource(bytes32 _l1BlockHash, uint256 _logIndex) internal pure returns (bytes32) {
                            bytes32 depositId = keccak256(abi.encode(_l1BlockHash, _logIndex));
                            return keccak256(abi.encode(bytes32(0), depositId));
                        }
                        /// @notice Hashes the cross domain message based on the version that is encoded into the
                        ///         message nonce.
                        /// @param _nonce    Message nonce with version encoded into the first two bytes.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Hashed cross domain message.
                        function hashCrossDomainMessage(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            (, uint16 version) = Encoding.decodeVersionedNonce(_nonce);
                            if (version == 0) {
                                return hashCrossDomainMessageV0(_target, _sender, _data, _nonce);
                            } else if (version == 1) {
                                return hashCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data);
                            } else {
                                revert("Hashing: unknown cross domain message version");
                            }
                        }
                        /// @notice Hashes a cross domain message based on the V0 (legacy) encoding.
                        /// @param _target Address of the target of the message.
                        /// @param _sender Address of the sender of the message.
                        /// @param _data   Data to send with the message.
                        /// @param _nonce  Message nonce.
                        /// @return Hashed cross domain message.
                        function hashCrossDomainMessageV0(
                            address _target,
                            address _sender,
                            bytes memory _data,
                            uint256 _nonce
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            return keccak256(Encoding.encodeCrossDomainMessageV0(_target, _sender, _data, _nonce));
                        }
                        /// @notice Hashes a cross domain message based on the V1 (current) encoding.
                        /// @param _nonce    Message nonce.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Hashed cross domain message.
                        function hashCrossDomainMessageV1(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            return keccak256(Encoding.encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data));
                        }
                        /// @notice Derives the withdrawal hash according to the encoding in the L2 Withdrawer contract
                        /// @param _tx Withdrawal transaction to hash.
                        /// @return Hashed withdrawal transaction.
                        function hashWithdrawal(Types.WithdrawalTransaction memory _tx) internal pure returns (bytes32) {
                            return keccak256(abi.encode(_tx.nonce, _tx.sender, _tx.target, _tx.value, _tx.gasLimit, _tx.data));
                        }
                        /// @notice Hashes the various elements of an output root proof into an output root hash which
                        ///         can be used to check if the proof is valid.
                        /// @param _outputRootProof Output root proof which should hash to an output root.
                        /// @return Hashed output root proof.
                        function hashOutputRootProof(Types.OutputRootProof memory _outputRootProof) internal pure returns (bytes32) {
                            return keccak256(
                                abi.encode(
                                    _outputRootProof.version,
                                    _outputRootProof.stateRoot,
                                    _outputRootProof.messagePasserStorageRoot,
                                    _outputRootProof.latestBlockhash
                                )
                            );
                        }
                        /// @notice Generates a unique hash for cross l2 messages. This hash is used to identify
                        ///         the message and ensure it is not relayed more than once.
                        /// @param _destination Chain ID of the destination chain.
                        /// @param _source Chain ID of the source chain.
                        /// @param _nonce Unique nonce associated with the message to prevent replay attacks.
                        /// @param _sender Address of the user who originally sent the message.
                        /// @param _target Address of the contract or wallet that the message is targeting on the destination chain.
                        /// @param _message The message payload to be relayed to the target on the destination chain.
                        /// @return Hash of the encoded message parameters, used to uniquely identify the message.
                        function hashL2toL2CrossDomainMessage(
                            uint256 _destination,
                            uint256 _source,
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            bytes memory _message
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            return keccak256(abi.encode(_destination, _source, _nonce, _sender, _target, _message));
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Libraries
                    import { Types } from "src/libraries/Types.sol";
                    import { Hashing } from "src/libraries/Hashing.sol";
                    import { RLPWriter } from "src/libraries/rlp/RLPWriter.sol";
                    /// @title Encoding
                    /// @notice Encoding handles Optimism's various different encoding schemes.
                    library Encoding {
                        /// @notice RLP encodes the L2 transaction that would be generated when a given deposit is sent
                        ///         to the L2 system. Useful for searching for a deposit in the L2 system. The
                        ///         transaction is prefixed with 0x7e to identify its EIP-2718 type.
                        /// @param _tx User deposit transaction to encode.
                        /// @return RLP encoded L2 deposit transaction.
                        function encodeDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes memory) {
                            bytes32 source = Hashing.hashDepositSource(_tx.l1BlockHash, _tx.logIndex);
                            bytes[] memory raw = new bytes[](8);
                            raw[0] = RLPWriter.writeBytes(abi.encodePacked(source));
                            raw[1] = RLPWriter.writeAddress(_tx.from);
                            raw[2] = _tx.isCreation ? RLPWriter.writeBytes("") : RLPWriter.writeAddress(_tx.to);
                            raw[3] = RLPWriter.writeUint(_tx.mint);
                            raw[4] = RLPWriter.writeUint(_tx.value);
                            raw[5] = RLPWriter.writeUint(uint256(_tx.gasLimit));
                            raw[6] = RLPWriter.writeBool(false);
                            raw[7] = RLPWriter.writeBytes(_tx.data);
                            return abi.encodePacked(uint8(0x7e), RLPWriter.writeList(raw));
                        }
                        /// @notice Encodes the cross domain message based on the version that is encoded into the
                        ///         message nonce.
                        /// @param _nonce    Message nonce with version encoded into the first two bytes.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Encoded cross domain message.
                        function encodeCrossDomainMessage(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            (, uint16 version) = decodeVersionedNonce(_nonce);
                            if (version == 0) {
                                return encodeCrossDomainMessageV0(_target, _sender, _data, _nonce);
                            } else if (version == 1) {
                                return encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data);
                            } else {
                                revert("Encoding: unknown cross domain message version");
                            }
                        }
                        /// @notice Encodes a cross domain message based on the V0 (legacy) encoding.
                        /// @param _target Address of the target of the message.
                        /// @param _sender Address of the sender of the message.
                        /// @param _data   Data to send with the message.
                        /// @param _nonce  Message nonce.
                        /// @return Encoded cross domain message.
                        function encodeCrossDomainMessageV0(
                            address _target,
                            address _sender,
                            bytes memory _data,
                            uint256 _nonce
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            // nosemgrep: sol-style-use-abi-encodecall
                            return abi.encodeWithSignature("relayMessage(address,address,bytes,uint256)", _target, _sender, _data, _nonce);
                        }
                        /// @notice Encodes a cross domain message based on the V1 (current) encoding.
                        /// @param _nonce    Message nonce.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Encoded cross domain message.
                        function encodeCrossDomainMessageV1(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            // nosemgrep: sol-style-use-abi-encodecall
                            return abi.encodeWithSignature(
                                "relayMessage(uint256,address,address,uint256,uint256,bytes)",
                                _nonce,
                                _sender,
                                _target,
                                _value,
                                _gasLimit,
                                _data
                            );
                        }
                        /// @notice Adds a version number into the first two bytes of a message nonce.
                        /// @param _nonce   Message nonce to encode into.
                        /// @param _version Version number to encode into the message nonce.
                        /// @return Message nonce with version encoded into the first two bytes.
                        function encodeVersionedNonce(uint240 _nonce, uint16 _version) internal pure returns (uint256) {
                            uint256 nonce;
                            assembly {
                                nonce := or(shl(240, _version), _nonce)
                            }
                            return nonce;
                        }
                        /// @notice Pulls the version out of a version-encoded nonce.
                        /// @param _nonce Message nonce with version encoded into the first two bytes.
                        /// @return Nonce without encoded version.
                        /// @return Version of the message.
                        function decodeVersionedNonce(uint256 _nonce) internal pure returns (uint240, uint16) {
                            uint240 nonce;
                            uint16 version;
                            assembly {
                                nonce := and(_nonce, 0x0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
                                version := shr(240, _nonce)
                            }
                            return (nonce, version);
                        }
                        /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesEcotone
                        /// @param _baseFeeScalar       L1 base fee Scalar
                        /// @param _blobBaseFeeScalar   L1 blob base fee Scalar
                        /// @param _sequenceNumber      Number of L2 blocks since epoch start.
                        /// @param _timestamp           L1 timestamp.
                        /// @param _number              L1 blocknumber.
                        /// @param _baseFee             L1 base fee.
                        /// @param _blobBaseFee         L1 blob base fee.
                        /// @param _hash                L1 blockhash.
                        /// @param _batcherHash         Versioned hash to authenticate batcher by.
                        function encodeSetL1BlockValuesEcotone(
                            uint32 _baseFeeScalar,
                            uint32 _blobBaseFeeScalar,
                            uint64 _sequenceNumber,
                            uint64 _timestamp,
                            uint64 _number,
                            uint256 _baseFee,
                            uint256 _blobBaseFee,
                            bytes32 _hash,
                            bytes32 _batcherHash
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesEcotone()"));
                            return abi.encodePacked(
                                functionSignature,
                                _baseFeeScalar,
                                _blobBaseFeeScalar,
                                _sequenceNumber,
                                _timestamp,
                                _number,
                                _baseFee,
                                _blobBaseFee,
                                _hash,
                                _batcherHash
                            );
                        }
                        /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesIsthmus
                        /// @param _baseFeeScalar       L1 base fee Scalar
                        /// @param _blobBaseFeeScalar   L1 blob base fee Scalar
                        /// @param _sequenceNumber      Number of L2 blocks since epoch start.
                        /// @param _timestamp           L1 timestamp.
                        /// @param _number              L1 blocknumber.
                        /// @param _baseFee             L1 base fee.
                        /// @param _blobBaseFee         L1 blob base fee.
                        /// @param _hash                L1 blockhash.
                        /// @param _batcherHash         Versioned hash to authenticate batcher by.
                        /// @param _operatorFeeScalar   Operator fee scalar.
                        /// @param _operatorFeeConstant Operator fee constant.
                        function encodeSetL1BlockValuesIsthmus(
                            uint32 _baseFeeScalar,
                            uint32 _blobBaseFeeScalar,
                            uint64 _sequenceNumber,
                            uint64 _timestamp,
                            uint64 _number,
                            uint256 _baseFee,
                            uint256 _blobBaseFee,
                            bytes32 _hash,
                            bytes32 _batcherHash,
                            uint32 _operatorFeeScalar,
                            uint64 _operatorFeeConstant
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesIsthmus()"));
                            return abi.encodePacked(
                                functionSignature,
                                _baseFeeScalar,
                                _blobBaseFeeScalar,
                                _sequenceNumber,
                                _timestamp,
                                _number,
                                _baseFee,
                                _blobBaseFee,
                                _hash,
                                _batcherHash,
                                _operatorFeeScalar,
                                _operatorFeeConstant
                            );
                        }
                        /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesInterop
                        /// @param _baseFeeScalar       L1 base fee Scalar
                        /// @param _blobBaseFeeScalar   L1 blob base fee Scalar
                        /// @param _sequenceNumber      Number of L2 blocks since epoch start.
                        /// @param _timestamp           L1 timestamp.
                        /// @param _number              L1 blocknumber.
                        /// @param _baseFee             L1 base fee.
                        /// @param _blobBaseFee         L1 blob base fee.
                        /// @param _hash                L1 blockhash.
                        /// @param _batcherHash         Versioned hash to authenticate batcher by.
                        function encodeSetL1BlockValuesInterop(
                            uint32 _baseFeeScalar,
                            uint32 _blobBaseFeeScalar,
                            uint64 _sequenceNumber,
                            uint64 _timestamp,
                            uint64 _number,
                            uint256 _baseFee,
                            uint256 _blobBaseFee,
                            bytes32 _hash,
                            bytes32 _batcherHash
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesInterop()"));
                            return abi.encodePacked(
                                functionSignature,
                                _baseFeeScalar,
                                _blobBaseFeeScalar,
                                _sequenceNumber,
                                _timestamp,
                                _number,
                                _baseFee,
                                _blobBaseFee,
                                _hash,
                                _batcherHash
                            );
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Interfaces
                    import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
                    /// @title Constants
                    /// @notice Constants is a library for storing constants. Simple! Don't put everything in here, just
                    ///         the stuff used in multiple contracts. Constants that only apply to a single contract
                    ///         should be defined in that contract instead.
                    library Constants {
                        /// @notice Special address to be used as the tx origin for gas estimation calls in the
                        ///         OptimismPortal and CrossDomainMessenger calls. You only need to use this address if
                        ///         the minimum gas limit specified by the user is not actually enough to execute the
                        ///         given message and you're attempting to estimate the actual necessary gas limit. We
                        ///         use address(1) because it's the ecrecover precompile and therefore guaranteed to
                        ///         never have any code on any EVM chain.
                        address internal constant ESTIMATION_ADDRESS = address(1);
                        /// @notice Value used for the L2 sender storage slot in both the OptimismPortal and the
                        ///         CrossDomainMessenger contracts before an actual sender is set. This value is
                        ///         non-zero to reduce the gas cost of message passing transactions.
                        address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD;
                        /// @notice The storage slot that holds the address of a proxy implementation.
                        /// @dev `bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)`
                        bytes32 internal constant PROXY_IMPLEMENTATION_ADDRESS =
                            0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                        /// @notice The storage slot that holds the address of the owner.
                        /// @dev `bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)`
                        bytes32 internal constant PROXY_OWNER_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                        /// @notice The address that represents ether when dealing with ERC20 token addresses.
                        address internal constant ETHER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                        /// @notice The address that represents the system caller responsible for L1 attributes
                        ///         transactions.
                        address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;
                        /// @notice Returns the default values for the ResourceConfig. These are the recommended values
                        ///         for a production network.
                        function DEFAULT_RESOURCE_CONFIG() internal pure returns (IResourceMetering.ResourceConfig memory) {
                            IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({
                                maxResourceLimit: 20_000_000,
                                elasticityMultiplier: 10,
                                baseFeeMaxChangeDenominator: 8,
                                minimumBaseFee: 1 gwei,
                                systemTxMaxGas: 1_000_000,
                                maximumBaseFee: type(uint128).max
                            });
                            return config;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title Types
                    /// @notice Contains various types used throughout the Optimism contract system.
                    library Types {
                        /// @notice OutputProposal represents a commitment to the L2 state. The timestamp is the L1
                        ///         timestamp that the output root is posted. This timestamp is used to verify that the
                        ///         finalization period has passed since the output root was submitted.
                        /// @custom:field outputRoot    Hash of the L2 output.
                        /// @custom:field timestamp     Timestamp of the L1 block that the output root was submitted in.
                        /// @custom:field l2BlockNumber L2 block number that the output corresponds to.
                        struct OutputProposal {
                            bytes32 outputRoot;
                            uint128 timestamp;
                            uint128 l2BlockNumber;
                        }
                        /// @notice Struct representing the elements that are hashed together to generate an output root
                        ///         which itself represents a snapshot of the L2 state.
                        /// @custom:field version                  Version of the output root.
                        /// @custom:field stateRoot                Root of the state trie at the block of this output.
                        /// @custom:field messagePasserStorageRoot Root of the message passer storage trie.
                        /// @custom:field latestBlockhash          Hash of the block this output was generated from.
                        struct OutputRootProof {
                            bytes32 version;
                            bytes32 stateRoot;
                            bytes32 messagePasserStorageRoot;
                            bytes32 latestBlockhash;
                        }
                        /// @notice Struct representing a deposit transaction (L1 => L2 transaction) created by an end
                        ///         user (as opposed to a system deposit transaction generated by the system).
                        /// @custom:field from        Address of the sender of the transaction.
                        /// @custom:field to          Address of the recipient of the transaction.
                        /// @custom:field isCreation  True if the transaction is a contract creation.
                        /// @custom:field value       Value to send to the recipient.
                        /// @custom:field mint        Amount of ETH to mint.
                        /// @custom:field gasLimit    Gas limit of the transaction.
                        /// @custom:field data        Data of the transaction.
                        /// @custom:field l1BlockHash Hash of the block the transaction was submitted in.
                        /// @custom:field logIndex    Index of the log in the block the transaction was submitted in.
                        struct UserDepositTransaction {
                            address from;
                            address to;
                            bool isCreation;
                            uint256 value;
                            uint256 mint;
                            uint64 gasLimit;
                            bytes data;
                            bytes32 l1BlockHash;
                            uint256 logIndex;
                        }
                        /// @notice Struct representing a withdrawal transaction.
                        /// @custom:field nonce    Nonce of the withdrawal transaction
                        /// @custom:field sender   Address of the sender of the transaction.
                        /// @custom:field target   Address of the recipient of the transaction.
                        /// @custom:field value    Value to send to the recipient.
                        /// @custom:field gasLimit Gas limit of the transaction.
                        /// @custom:field data     Data of the transaction.
                        struct WithdrawalTransaction {
                            uint256 nonce;
                            address sender;
                            address target;
                            uint256 value;
                            uint256 gasLimit;
                            bytes data;
                        }
                        /// @notice Enum representing where the FeeVault withdraws funds to.
                        /// @custom:value L1 FeeVault withdraws funds to L1.
                        /// @custom:value L2 FeeVault withdraws funds to L2.
                        enum WithdrawalNetwork {
                            L1,
                            L2
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.15;
                    // Libraries
                    import { Position } from "src/dispute/lib/LibPosition.sol";
                    using LibClaim for Claim global;
                    using LibHash for Hash global;
                    using LibDuration for Duration global;
                    using LibClock for Clock global;
                    using LibGameId for GameId global;
                    using LibTimestamp for Timestamp global;
                    using LibVMStatus for VMStatus global;
                    using LibGameType for GameType global;
                    /// @notice A `Clock` represents a packed `Duration` and `Timestamp`
                    /// @dev The packed layout of this type is as follows:
                    /// ┌────────────┬────────────────┐
                    /// │    Bits    │     Value      │
                    /// ├────────────┼────────────────┤
                    /// │ [0, 64)    │ Duration       │
                    /// │ [64, 128)  │ Timestamp      │
                    /// └────────────┴────────────────┘
                    type Clock is uint128;
                    /// @title LibClock
                    /// @notice This library contains helper functions for working with the `Clock` type.
                    library LibClock {
                        /// @notice Packs a `Duration` and `Timestamp` into a `Clock` type.
                        /// @param _duration The `Duration` to pack into the `Clock` type.
                        /// @param _timestamp The `Timestamp` to pack into the `Clock` type.
                        /// @return clock_ The `Clock` containing the `_duration` and `_timestamp`.
                        function wrap(Duration _duration, Timestamp _timestamp) internal pure returns (Clock clock_) {
                            assembly {
                                clock_ := or(shl(0x40, _duration), _timestamp)
                            }
                        }
                        /// @notice Pull the `Duration` out of a `Clock` type.
                        /// @param _clock The `Clock` type to pull the `Duration` out of.
                        /// @return duration_ The `Duration` pulled out of `_clock`.
                        function duration(Clock _clock) internal pure returns (Duration duration_) {
                            // Shift the high-order 64 bits into the low-order 64 bits, leaving only the `duration`.
                            assembly {
                                duration_ := shr(0x40, _clock)
                            }
                        }
                        /// @notice Pull the `Timestamp` out of a `Clock` type.
                        /// @param _clock The `Clock` type to pull the `Timestamp` out of.
                        /// @return timestamp_ The `Timestamp` pulled out of `_clock`.
                        function timestamp(Clock _clock) internal pure returns (Timestamp timestamp_) {
                            // Clean the high-order 192 bits by shifting the clock left and then right again, leaving
                            // only the `timestamp`.
                            assembly {
                                timestamp_ := shr(0xC0, shl(0xC0, _clock))
                            }
                        }
                        /// @notice Get the value of a `Clock` type in the form of the underlying uint128.
                        /// @param _clock The `Clock` type to get the value of.
                        /// @return clock_ The value of the `Clock` type as a uint128 type.
                        function raw(Clock _clock) internal pure returns (uint128 clock_) {
                            assembly {
                                clock_ := _clock
                            }
                        }
                    }
                    /// @notice A `GameId` represents a packed 4 byte game ID, a 8 byte timestamp, and a 20 byte address.
                    /// @dev The packed layout of this type is as follows:
                    /// ┌───────────┬───────────┐
                    /// │   Bits    │   Value   │
                    /// ├───────────┼───────────┤
                    /// │ [0, 32)   │ Game Type │
                    /// │ [32, 96)  │ Timestamp │
                    /// │ [96, 256) │ Address   │
                    /// └───────────┴───────────┘
                    type GameId is bytes32;
                    /// @title LibGameId
                    /// @notice Utility functions for packing and unpacking GameIds.
                    library LibGameId {
                        /// @notice Packs values into a 32 byte GameId type.
                        /// @param _gameType The game type.
                        /// @param _timestamp The timestamp of the game's creation.
                        /// @param _gameProxy The game proxy address.
                        /// @return gameId_ The packed GameId.
                        function pack(
                            GameType _gameType,
                            Timestamp _timestamp,
                            address _gameProxy
                        )
                            internal
                            pure
                            returns (GameId gameId_)
                        {
                            assembly {
                                gameId_ := or(or(shl(224, _gameType), shl(160, _timestamp)), _gameProxy)
                            }
                        }
                        /// @notice Unpacks values from a 32 byte GameId type.
                        /// @param _gameId The packed GameId.
                        /// @return gameType_ The game type.
                        /// @return timestamp_ The timestamp of the game's creation.
                        /// @return gameProxy_ The game proxy address.
                        function unpack(GameId _gameId)
                            internal
                            pure
                            returns (GameType gameType_, Timestamp timestamp_, address gameProxy_)
                        {
                            assembly {
                                gameType_ := shr(224, _gameId)
                                timestamp_ := and(shr(160, _gameId), 0xFFFFFFFFFFFFFFFF)
                                gameProxy_ := and(_gameId, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
                            }
                        }
                    }
                    /// @notice A claim represents an MPT root representing the state of the fault proof program.
                    type Claim is bytes32;
                    /// @title LibClaim
                    /// @notice This library contains helper functions for working with the `Claim` type.
                    library LibClaim {
                        /// @notice Get the value of a `Claim` type in the form of the underlying bytes32.
                        /// @param _claim The `Claim` type to get the value of.
                        /// @return claim_ The value of the `Claim` type as a bytes32 type.
                        function raw(Claim _claim) internal pure returns (bytes32 claim_) {
                            assembly {
                                claim_ := _claim
                            }
                        }
                        /// @notice Hashes a claim and a position together.
                        /// @param _claim A Claim type.
                        /// @param _position The position of `claim`.
                        /// @param _challengeIndex The index of the claim being moved against.
                        /// @return claimHash_ A hash of abi.encodePacked(claim, position|challengeIndex);
                        function hashClaimPos(
                            Claim _claim,
                            Position _position,
                            uint256 _challengeIndex
                        )
                            internal
                            pure
                            returns (Hash claimHash_)
                        {
                            assembly {
                                mstore(0x00, _claim)
                                mstore(0x20, or(shl(128, _position), and(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, _challengeIndex)))
                                claimHash_ := keccak256(0x00, 0x40)
                            }
                        }
                    }
                    /// @notice A dedicated duration type.
                    /// @dev Unit: seconds
                    type Duration is uint64;
                    /// @title LibDuration
                    /// @notice This library contains helper functions for working with the `Duration` type.
                    library LibDuration {
                        /// @notice Get the value of a `Duration` type in the form of the underlying uint64.
                        /// @param _duration The `Duration` type to get the value of.
                        /// @return duration_ The value of the `Duration` type as a uint64 type.
                        function raw(Duration _duration) internal pure returns (uint64 duration_) {
                            assembly {
                                duration_ := _duration
                            }
                        }
                    }
                    /// @notice A custom type for a generic hash.
                    type Hash is bytes32;
                    /// @title LibHash
                    /// @notice This library contains helper functions for working with the `Hash` type.
                    library LibHash {
                        /// @notice Get the value of a `Hash` type in the form of the underlying bytes32.
                        /// @param _hash The `Hash` type to get the value of.
                        /// @return hash_ The value of the `Hash` type as a bytes32 type.
                        function raw(Hash _hash) internal pure returns (bytes32 hash_) {
                            assembly {
                                hash_ := _hash
                            }
                        }
                    }
                    /// @notice A dedicated timestamp type.
                    type Timestamp is uint64;
                    /// @title LibTimestamp
                    /// @notice This library contains helper functions for working with the `Timestamp` type.
                    library LibTimestamp {
                        /// @notice Get the value of a `Timestamp` type in the form of the underlying uint64.
                        /// @param _timestamp The `Timestamp` type to get the value of.
                        /// @return timestamp_ The value of the `Timestamp` type as a uint64 type.
                        function raw(Timestamp _timestamp) internal pure returns (uint64 timestamp_) {
                            assembly {
                                timestamp_ := _timestamp
                            }
                        }
                    }
                    /// @notice A `VMStatus` represents the status of a VM execution.
                    type VMStatus is uint8;
                    /// @title LibVMStatus
                    /// @notice This library contains helper functions for working with the `VMStatus` type.
                    library LibVMStatus {
                        /// @notice Get the value of a `VMStatus` type in the form of the underlying uint8.
                        /// @param _vmstatus The `VMStatus` type to get the value of.
                        /// @return vmstatus_ The value of the `VMStatus` type as a uint8 type.
                        function raw(VMStatus _vmstatus) internal pure returns (uint8 vmstatus_) {
                            assembly {
                                vmstatus_ := _vmstatus
                            }
                        }
                    }
                    /// @notice A `GameType` represents the type of game being played.
                    type GameType is uint32;
                    /// @title LibGameType
                    /// @notice This library contains helper functions for working with the `GameType` type.
                    library LibGameType {
                        /// @notice Get the value of a `GameType` type in the form of the underlying uint32.
                        /// @param _gametype The `GameType` type to get the value of.
                        /// @return gametype_ The value of the `GameType` type as a uint32 type.
                        function raw(GameType _gametype) internal pure returns (uint32 gametype_) {
                            assembly {
                                gametype_ := _gametype
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IInitializable } from "interfaces/dispute/IInitializable.sol";
                    import { Timestamp, GameStatus, GameType, Claim, Hash } from "src/dispute/lib/Types.sol";
                    interface IDisputeGame is IInitializable {
                        event Resolved(GameStatus indexed status);
                        function createdAt() external view returns (Timestamp);
                        function resolvedAt() external view returns (Timestamp);
                        function status() external view returns (GameStatus);
                        function gameType() external view returns (GameType gameType_);
                        function gameCreator() external pure returns (address creator_);
                        function rootClaim() external pure returns (Claim rootClaim_);
                        function l1Head() external pure returns (Hash l1Head_);
                        function l2BlockNumber() external pure returns (uint256 l2BlockNumber_);
                        function extraData() external pure returns (bytes memory extraData_);
                        function resolve() external returns (GameStatus status_);
                        function gameData() external view returns (GameType gameType_, Claim rootClaim_, bytes memory extraData_);
                        function wasRespectedGameTypeWhenCreated() external view returns (bool);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
                    import { GameId, Timestamp, Claim, Hash, GameType } from "src/dispute/lib/Types.sol";
                    interface IDisputeGameFactory {
                        struct GameSearchResult {
                            uint256 index;
                            GameId metadata;
                            Timestamp timestamp;
                            Claim rootClaim;
                            bytes extraData;
                        }
                        error GameAlreadyExists(Hash uuid);
                        error IncorrectBondAmount();
                        error NoImplementation(GameType gameType);
                        event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim);
                        event ImplementationSet(address indexed impl, GameType indexed gameType);
                        event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond);
                        event Initialized(uint8 version);
                        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                        function create(
                            GameType _gameType,
                            Claim _rootClaim,
                            bytes memory _extraData
                        )
                            external
                            payable
                            returns (IDisputeGame proxy_);
                        function findLatestGames(
                            GameType _gameType,
                            uint256 _start,
                            uint256 _n
                        )
                            external
                            view
                            returns (GameSearchResult[] memory games_);
                        function gameAtIndex(uint256 _index)
                            external
                            view
                            returns (GameType gameType_, Timestamp timestamp_, IDisputeGame proxy_);
                        function gameCount() external view returns (uint256 gameCount_);
                        function gameImpls(GameType) external view returns (IDisputeGame);
                        function games(
                            GameType _gameType,
                            Claim _rootClaim,
                            bytes memory _extraData
                        )
                            external
                            view
                            returns (IDisputeGame proxy_, Timestamp timestamp_);
                        function getGameUUID(
                            GameType _gameType,
                            Claim _rootClaim,
                            bytes memory _extraData
                        )
                            external
                            pure
                            returns (Hash uuid_);
                        function initBonds(GameType) external view returns (uint256);
                        function initialize(address _owner) external;
                        function owner() external view returns (address);
                        function renounceOwnership() external;
                        function setImplementation(GameType _gameType, IDisputeGame _impl) external;
                        function setInitBond(GameType _gameType, uint256 _initBond) external;
                        function transferOwnership(address newOwner) external; // nosemgrep
                        function version() external view returns (string memory);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
                    interface ISystemConfig {
                        enum UpdateType {
                            BATCHER,
                            FEE_SCALARS,
                            GAS_LIMIT,
                            UNSAFE_BLOCK_SIGNER,
                            EIP_1559_PARAMS,
                            OPERATOR_FEE_PARAMS
                        }
                        struct Addresses {
                            address l1CrossDomainMessenger;
                            address l1ERC721Bridge;
                            address l1StandardBridge;
                            address disputeGameFactory;
                            address optimismPortal;
                            address optimismMintableERC20Factory;
                        }
                        event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
                        event Initialized(uint8 version);
                        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                        function BATCH_INBOX_SLOT() external view returns (bytes32);
                        function DISPUTE_GAME_FACTORY_SLOT() external view returns (bytes32);
                        function L1_CROSS_DOMAIN_MESSENGER_SLOT() external view returns (bytes32);
                        function L1_ERC_721_BRIDGE_SLOT() external view returns (bytes32);
                        function L1_STANDARD_BRIDGE_SLOT() external view returns (bytes32);
                        function OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT() external view returns (bytes32);
                        function OPTIMISM_PORTAL_SLOT() external view returns (bytes32);
                        function START_BLOCK_SLOT() external view returns (bytes32);
                        function UNSAFE_BLOCK_SIGNER_SLOT() external view returns (bytes32);
                        function VERSION() external view returns (uint256);
                        function basefeeScalar() external view returns (uint32);
                        function batchInbox() external view returns (address addr_);
                        function batcherHash() external view returns (bytes32);
                        function blobbasefeeScalar() external view returns (uint32);
                        function disputeGameFactory() external view returns (address addr_);
                        function gasLimit() external view returns (uint64);
                        function eip1559Denominator() external view returns (uint32);
                        function eip1559Elasticity() external view returns (uint32);
                        function getAddresses() external view returns (Addresses memory);
                        function initialize(
                            address _owner,
                            uint32 _basefeeScalar,
                            uint32 _blobbasefeeScalar,
                            bytes32 _batcherHash,
                            uint64 _gasLimit,
                            address _unsafeBlockSigner,
                            IResourceMetering.ResourceConfig memory _config,
                            address _batchInbox,
                            Addresses memory _addresses
                        )
                            external;
                        function l1CrossDomainMessenger() external view returns (address addr_);
                        function l1ERC721Bridge() external view returns (address addr_);
                        function l1StandardBridge() external view returns (address addr_);
                        function maximumGasLimit() external pure returns (uint64);
                        function minimumGasLimit() external view returns (uint64);
                        function operatorFeeConstant() external view returns (uint64);
                        function operatorFeeScalar() external view returns (uint32);
                        function optimismMintableERC20Factory() external view returns (address addr_);
                        function optimismPortal() external view returns (address addr_);
                        function overhead() external view returns (uint256);
                        function owner() external view returns (address);
                        function renounceOwnership() external;
                        function resourceConfig() external view returns (IResourceMetering.ResourceConfig memory);
                        function scalar() external view returns (uint256);
                        function setBatcherHash(bytes32 _batcherHash) external;
                        function setGasConfig(uint256 _overhead, uint256 _scalar) external;
                        function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external;
                        function setGasLimit(uint64 _gasLimit) external;
                        function setOperatorFeeScalars(uint32 _operatorFeeScalar, uint64 _operatorFeeConstant) external;
                        function setUnsafeBlockSigner(address _unsafeBlockSigner) external;
                        function setEIP1559Params(uint32 _denominator, uint32 _elasticity) external;
                        function startBlock() external view returns (uint256 startBlock_);
                        function transferOwnership(address newOwner) external; // nosemgrep
                        function unsafeBlockSigner() external view returns (address addr_);
                        function version() external pure returns (string memory);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
                    pragma solidity ^0.8.1;
                    /**
                     * @dev Collection of functions related to the address type
                     */
                    library AddressUpgradeable {
                        /**
                         * @dev Returns true if `account` is a contract.
                         *
                         * [IMPORTANT]
                         * ====
                         * It is unsafe to assume that an address for which this function returns
                         * false is an externally-owned account (EOA) and not a contract.
                         *
                         * Among others, `isContract` will return false for the following
                         * types of addresses:
                         *
                         *  - an externally-owned account
                         *  - a contract in construction
                         *  - an address where a contract will be created
                         *  - an address where a contract lived, but was destroyed
                         * ====
                         *
                         * [IMPORTANT]
                         * ====
                         * You shouldn't rely on `isContract` to protect against flash loan attacks!
                         *
                         * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
                         * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
                         * constructor.
                         * ====
                         */
                        function isContract(address account) internal view returns (bool) {
                            // This method relies on extcodesize/address.code.length, which returns 0
                            // for contracts in construction, since the code is only stored at the end
                            // of the constructor execution.
                            return account.code.length > 0;
                        }
                        /**
                         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
                         * `recipient`, forwarding all available gas and reverting on errors.
                         *
                         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
                         * of certain opcodes, possibly making contracts go over the 2300 gas limit
                         * imposed by `transfer`, making them unable to receive funds via
                         * `transfer`. {sendValue} removes this limitation.
                         *
                         * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
                         *
                         * IMPORTANT: because control is transferred to `recipient`, care must be
                         * taken to not create reentrancy vulnerabilities. Consider using
                         * {ReentrancyGuard} or the
                         * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
                         */
                        function sendValue(address payable recipient, uint256 amount) internal {
                            require(address(this).balance >= amount, "Address: insufficient balance");
                            (bool success, ) = recipient.call{value: amount}("");
                            require(success, "Address: unable to send value, recipient may have reverted");
                        }
                        /**
                         * @dev Performs a Solidity function call using a low level `call`. A
                         * plain `call` is an unsafe replacement for a function call: use this
                         * function instead.
                         *
                         * If `target` reverts with a revert reason, it is bubbled up by this
                         * function (like regular Solidity function calls).
                         *
                         * Returns the raw returned data. To convert to the expected return value,
                         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
                         *
                         * Requirements:
                         *
                         * - `target` must be a contract.
                         * - calling `target` with `data` must not revert.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                            return functionCall(target, data, "Address: low-level call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
                         * `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, 0, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but also transferring `value` wei to `target`.
                         *
                         * Requirements:
                         *
                         * - the calling contract must have an ETH balance of at least `value`.
                         * - the called Solidity function must be `payable`.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value
                        ) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
                         * with `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            require(address(this).balance >= value, "Address: insufficient balance for call");
                            require(isContract(target), "Address: call to non-contract");
                            (bool success, bytes memory returndata) = target.call{value: value}(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                            return functionStaticCall(target, data, "Address: low-level static call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal view returns (bytes memory) {
                            require(isContract(target), "Address: static call to non-contract");
                            (bool success, bytes memory returndata) = target.staticcall(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
                         * revert reason using the provided one.
                         *
                         * _Available since v4.3._
                         */
                        function verifyCallResult(
                            bool success,
                            bytes memory returndata,
                            string memory errorMessage
                        ) internal pure returns (bytes memory) {
                            if (success) {
                                return returndata;
                            } else {
                                // Look for revert reason and bubble it up if present
                                if (returndata.length > 0) {
                                    // The easiest way to bubble the revert reason is using memory via assembly
                                    /// @solidity memory-safe-assembly
                                    assembly {
                                        let returndata_size := mload(returndata)
                                        revert(add(32, returndata), returndata_size)
                                    }
                                } else {
                                    revert(errorMessage);
                                }
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @custom:attribution https://github.com/bakaoh/solidity-rlp-encode
                    /// @title RLPWriter
                    /// @author RLPWriter is a library for encoding Solidity types to RLP bytes. Adapted from Bakaoh's
                    ///         RLPEncode library (https://github.com/bakaoh/solidity-rlp-encode) with minor
                    ///         modifications to improve legibility.
                    library RLPWriter {
                        /// @notice RLP encodes a byte string.
                        /// @param _in The byte string to encode.
                        /// @return out_ The RLP encoded string in bytes.
                        function writeBytes(bytes memory _in) internal pure returns (bytes memory out_) {
                            if (_in.length == 1 && uint8(_in[0]) < 128) {
                                out_ = _in;
                            } else {
                                out_ = abi.encodePacked(_writeLength(_in.length, 128), _in);
                            }
                        }
                        /// @notice RLP encodes a list of RLP encoded byte byte strings.
                        /// @param _in The list of RLP encoded byte strings.
                        /// @return list_ The RLP encoded list of items in bytes.
                        function writeList(bytes[] memory _in) internal pure returns (bytes memory list_) {
                            list_ = _flatten(_in);
                            list_ = abi.encodePacked(_writeLength(list_.length, 192), list_);
                        }
                        /// @notice RLP encodes a string.
                        /// @param _in The string to encode.
                        /// @return out_ The RLP encoded string in bytes.
                        function writeString(string memory _in) internal pure returns (bytes memory out_) {
                            out_ = writeBytes(bytes(_in));
                        }
                        /// @notice RLP encodes an address.
                        /// @param _in The address to encode.
                        /// @return out_ The RLP encoded address in bytes.
                        function writeAddress(address _in) internal pure returns (bytes memory out_) {
                            out_ = writeBytes(abi.encodePacked(_in));
                        }
                        /// @notice RLP encodes a uint.
                        /// @param _in The uint256 to encode.
                        /// @return out_ The RLP encoded uint256 in bytes.
                        function writeUint(uint256 _in) internal pure returns (bytes memory out_) {
                            out_ = writeBytes(_toBinary(_in));
                        }
                        /// @notice RLP encodes a bool.
                        /// @param _in The bool to encode.
                        /// @return out_ The RLP encoded bool in bytes.
                        function writeBool(bool _in) internal pure returns (bytes memory out_) {
                            out_ = new bytes(1);
                            out_[0] = (_in ? bytes1(0x01) : bytes1(0x80));
                        }
                        /// @notice Encode the first byte and then the `len` in binary form if `length` is more than 55.
                        /// @param _len    The length of the string or the payload.
                        /// @param _offset 128 if item is string, 192 if item is list.
                        /// @return out_ RLP encoded bytes.
                        function _writeLength(uint256 _len, uint256 _offset) private pure returns (bytes memory out_) {
                            if (_len < 56) {
                                out_ = new bytes(1);
                                out_[0] = bytes1(uint8(_len) + uint8(_offset));
                            } else {
                                uint256 lenLen;
                                uint256 i = 1;
                                while (_len / i != 0) {
                                    lenLen++;
                                    i *= 256;
                                }
                                out_ = new bytes(lenLen + 1);
                                out_[0] = bytes1(uint8(lenLen) + uint8(_offset) + 55);
                                for (i = 1; i <= lenLen; i++) {
                                    out_[i] = bytes1(uint8((_len / (256 ** (lenLen - i))) % 256));
                                }
                            }
                        }
                        /// @notice Encode integer in big endian binary form with no leading zeroes.
                        /// @param _x The integer to encode.
                        /// @return out_ RLP encoded bytes.
                        function _toBinary(uint256 _x) private pure returns (bytes memory out_) {
                            bytes memory b = abi.encodePacked(_x);
                            uint256 i = 0;
                            for (; i < 32; i++) {
                                if (b[i] != 0) {
                                    break;
                                }
                            }
                            out_ = new bytes(32 - i);
                            for (uint256 j = 0; j < out_.length; j++) {
                                out_[j] = b[i++];
                            }
                        }
                        /// @custom:attribution https://github.com/Arachnid/solidity-stringutils
                        /// @notice Copies a piece of memory to another location.
                        /// @param _dest Destination location.
                        /// @param _src  Source location.
                        /// @param _len  Length of memory to copy.
                        function _memcpy(uint256 _dest, uint256 _src, uint256 _len) private pure {
                            uint256 dest = _dest;
                            uint256 src = _src;
                            uint256 len = _len;
                            for (; len >= 32; len -= 32) {
                                assembly {
                                    mstore(dest, mload(src))
                                }
                                dest += 32;
                                src += 32;
                            }
                            uint256 mask;
                            unchecked {
                                mask = 256 ** (32 - len) - 1;
                            }
                            assembly {
                                let srcpart := and(mload(src), not(mask))
                                let destpart := and(mload(dest), mask)
                                mstore(dest, or(destpart, srcpart))
                            }
                        }
                        /// @custom:attribution https://github.com/sammayo/solidity-rlp-encoder
                        /// @notice Flattens a list of byte strings into one byte string.
                        /// @param _list List of byte strings to flatten.
                        /// @return out_ The flattened byte string.
                        function _flatten(bytes[] memory _list) private pure returns (bytes memory out_) {
                            if (_list.length == 0) {
                                return new bytes(0);
                            }
                            uint256 len;
                            uint256 i = 0;
                            for (; i < _list.length; i++) {
                                len += _list[i].length;
                            }
                            out_ = new bytes(len);
                            uint256 flattenedPtr;
                            assembly {
                                flattenedPtr := add(out_, 0x20)
                            }
                            for (i = 0; i < _list.length; i++) {
                                bytes memory item = _list[i];
                                uint256 listPtr;
                                assembly {
                                    listPtr := add(item, 0x20)
                                }
                                _memcpy(flattenedPtr, listPtr, item.length);
                                flattenedPtr += _list[i].length;
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface IResourceMetering {
                        struct ResourceParams {
                            uint128 prevBaseFee;
                            uint64 prevBoughtGas;
                            uint64 prevBlockNum;
                        }
                        struct ResourceConfig {
                            uint32 maxResourceLimit;
                            uint8 elasticityMultiplier;
                            uint8 baseFeeMaxChangeDenominator;
                            uint32 minimumBaseFee;
                            uint32 systemTxMaxGas;
                            uint128 maximumBaseFee;
                        }
                        error OutOfGas();
                        event Initialized(uint8 version);
                        function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.15;
                    using LibPosition for Position global;
                    /// @notice A `Position` represents a position of a claim within the game tree.
                    /// @dev This is represented as a "generalized index" where the high-order bit
                    /// is the level in the tree and the remaining bits is a unique bit pattern, allowing
                    /// a unique identifier for each node in the tree. Mathematically, it is calculated
                    /// as 2^{depth} + indexAtDepth.
                    type Position is uint128;
                    /// @title LibPosition
                    /// @notice This library contains helper functions for working with the `Position` type.
                    library LibPosition {
                        /// @notice the `MAX_POSITION_BITLEN` is the number of bits that the `Position` type, and the implementation of
                        ///         its behavior within this library, can safely support.
                        uint8 internal constant MAX_POSITION_BITLEN = 126;
                        /// @notice Computes a generalized index (2^{depth} + indexAtDepth).
                        /// @param _depth The depth of the position.
                        /// @param _indexAtDepth The index at the depth of the position.
                        /// @return position_ The computed generalized index.
                        function wrap(uint8 _depth, uint128 _indexAtDepth) internal pure returns (Position position_) {
                            assembly {
                                // gindex = 2^{_depth} + _indexAtDepth
                                position_ := add(shl(_depth, 1), _indexAtDepth)
                            }
                        }
                        /// @notice Pulls the `depth` out of a `Position` type.
                        /// @param _position The generalized index to get the `depth` of.
                        /// @return depth_ The `depth` of the `position` gindex.
                        /// @custom:attribution Solady <https://github.com/Vectorized/Solady>
                        function depth(Position _position) internal pure returns (uint8 depth_) {
                            // Return the most significant bit offset, which signifies the depth of the gindex.
                            assembly {
                                depth_ := or(depth_, shl(6, lt(0xffffffffffffffff, shr(depth_, _position))))
                                depth_ := or(depth_, shl(5, lt(0xffffffff, shr(depth_, _position))))
                                // For the remaining 32 bits, use a De Bruijn lookup.
                                _position := shr(depth_, _position)
                                _position := or(_position, shr(1, _position))
                                _position := or(_position, shr(2, _position))
                                _position := or(_position, shr(4, _position))
                                _position := or(_position, shr(8, _position))
                                _position := or(_position, shr(16, _position))
                                depth_ :=
                                    or(
                                        depth_,
                                        byte(
                                            shr(251, mul(_position, shl(224, 0x07c4acdd))),
                                            0x0009010a0d15021d0b0e10121619031e080c141c0f111807131b17061a05041f
                                        )
                                    )
                            }
                        }
                        /// @notice Pulls the `indexAtDepth` out of a `Position` type.
                        ///         The `indexAtDepth` is the left/right index of a position at a specific depth within
                        ///         the binary tree, starting from index 0. For example, at gindex 2, the `depth` = 1
                        ///         and the `indexAtDepth` = 0.
                        /// @param _position The generalized index to get the `indexAtDepth` of.
                        /// @return indexAtDepth_ The `indexAtDepth` of the `position` gindex.
                        function indexAtDepth(Position _position) internal pure returns (uint128 indexAtDepth_) {
                            // Return bits p_{msb-1}...p_{0}. This effectively pulls the 2^{depth} out of the gindex,
                            // leaving only the `indexAtDepth`.
                            uint256 msb = depth(_position);
                            assembly {
                                indexAtDepth_ := sub(_position, shl(msb, 1))
                            }
                        }
                        /// @notice Get the left child of `_position`.
                        /// @param _position The position to get the left position of.
                        /// @return left_ The position to the left of `position`.
                        function left(Position _position) internal pure returns (Position left_) {
                            assembly {
                                left_ := shl(1, _position)
                            }
                        }
                        /// @notice Get the right child of `_position`
                        /// @param _position The position to get the right position of.
                        /// @return right_ The position to the right of `position`.
                        function right(Position _position) internal pure returns (Position right_) {
                            assembly {
                                right_ := or(1, shl(1, _position))
                            }
                        }
                        /// @notice Get the parent position of `_position`.
                        /// @param _position The position to get the parent position of.
                        /// @return parent_ The parent position of `position`.
                        function parent(Position _position) internal pure returns (Position parent_) {
                            assembly {
                                parent_ := shr(1, _position)
                            }
                        }
                        /// @notice Get the deepest, right most gindex relative to the `position`. This is equivalent to
                        ///         calling `right` on a position until the maximum depth is reached.
                        /// @param _position The position to get the relative deepest, right most gindex of.
                        /// @param _maxDepth The maximum depth of the game.
                        /// @return rightIndex_ The deepest, right most gindex relative to the `position`.
                        function rightIndex(Position _position, uint256 _maxDepth) internal pure returns (Position rightIndex_) {
                            uint256 msb = depth(_position);
                            assembly {
                                let remaining := sub(_maxDepth, msb)
                                rightIndex_ := or(shl(remaining, _position), sub(shl(remaining, 1), 1))
                            }
                        }
                        /// @notice Get the deepest, right most trace index relative to the `position`. This is
                        ///         equivalent to calling `right` on a position until the maximum depth is reached and
                        ///         then finding its index at depth.
                        /// @param _position The position to get the relative trace index of.
                        /// @param _maxDepth The maximum depth of the game.
                        /// @return traceIndex_ The trace index relative to the `position`.
                        function traceIndex(Position _position, uint256 _maxDepth) internal pure returns (uint256 traceIndex_) {
                            uint256 msb = depth(_position);
                            assembly {
                                let remaining := sub(_maxDepth, msb)
                                traceIndex_ := sub(or(shl(remaining, _position), sub(shl(remaining, 1), 1)), shl(_maxDepth, 1))
                            }
                        }
                        /// @notice Gets the position of the highest ancestor of `_position` that commits to the same
                        ///         trace index.
                        /// @param _position The position to get the highest ancestor of.
                        /// @return ancestor_ The highest ancestor of `position` that commits to the same trace index.
                        function traceAncestor(Position _position) internal pure returns (Position ancestor_) {
                            // Create a field with only the lowest unset bit of `_position` set.
                            Position lsb;
                            assembly {
                                lsb := and(not(_position), add(_position, 1))
                            }
                            // Find the index of the lowest unset bit within the field.
                            uint256 msb = depth(lsb);
                            // The highest ancestor that commits to the same trace index is the original position
                            // shifted right by the index of the lowest unset bit.
                            assembly {
                                let a := shr(msb, _position)
                                // Bound the ancestor to the minimum gindex, 1.
                                ancestor_ := or(a, iszero(a))
                            }
                        }
                        /// @notice Gets the position of the highest ancestor of `_position` that commits to the same
                        ///         trace index, while still being below `_upperBoundExclusive`.
                        /// @param _position The position to get the highest ancestor of.
                        /// @param _upperBoundExclusive The exclusive upper depth bound, used to inform where to stop in order
                        ///                             to not escape a sub-tree.
                        /// @return ancestor_ The highest ancestor of `position` that commits to the same trace index.
                        function traceAncestorBounded(
                            Position _position,
                            uint256 _upperBoundExclusive
                        )
                            internal
                            pure
                            returns (Position ancestor_)
                        {
                            // This function only works for positions that are below the upper bound.
                            if (_position.depth() <= _upperBoundExclusive) {
                                assembly {
                                    // Revert with `ClaimAboveSplit()`
                                    mstore(0x00, 0xb34b5c22)
                                    revert(0x1C, 0x04)
                                }
                            }
                            // Grab the global trace ancestor.
                            ancestor_ = traceAncestor(_position);
                            // If the ancestor is above or at the upper bound, shift it to be below the upper bound.
                            // This should be a special case that only covers positions that commit to the final leaf
                            // in a sub-tree.
                            if (ancestor_.depth() <= _upperBoundExclusive) {
                                ancestor_ = ancestor_.rightIndex(_upperBoundExclusive + 1);
                            }
                        }
                        /// @notice Get the move position of `_position`, which is the left child of:
                        ///         1. `_position` if `_isAttack` is true.
                        ///         2. `_position | 1` if `_isAttack` is false.
                        /// @param _position The position to get the relative attack/defense position of.
                        /// @param _isAttack Whether or not the move is an attack move.
                        /// @return move_ The move position relative to `position`.
                        function move(Position _position, bool _isAttack) internal pure returns (Position move_) {
                            assembly {
                                move_ := shl(1, or(iszero(_isAttack), _position))
                            }
                        }
                        /// @notice Get the value of a `Position` type in the form of the underlying uint128.
                        /// @param _position The position to get the value of.
                        /// @return raw_ The value of the `position` as a uint128 type.
                        function raw(Position _position) internal pure returns (uint128 raw_) {
                            assembly {
                                raw_ := _position
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface IInitializable {
                        function initialize() external payable;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.15;
                    // Libraries
                    import {
                        Position,
                        Hash,
                        GameType,
                        VMStatus,
                        Timestamp,
                        Duration,
                        Clock,
                        GameId,
                        Claim,
                        LibGameId,
                        LibClock
                    } from "src/dispute/lib/LibUDT.sol";
                    /// @notice The current status of the dispute game.
                    enum GameStatus {
                        // The game is currently in progress, and has not been resolved.
                        IN_PROGRESS,
                        // The game has concluded, and the `rootClaim` was challenged successfully.
                        CHALLENGER_WINS,
                        // The game has concluded, and the `rootClaim` could not be contested.
                        DEFENDER_WINS
                    }
                    /// @notice The game's bond distribution type. Games are expected to start in the `UNDECIDED`
                    ///         state, and then choose either `NORMAL` or `REFUND`.
                    enum BondDistributionMode {
                        // Bond distribution strategy has not been chosen.
                        UNDECIDED,
                        // Bonds should be distributed as normal.
                        NORMAL,
                        // Bonds should be refunded to claimants.
                        REFUND
                    }
                    /// @notice Represents an L2 output root and the L2 block number at which it was generated.
                    /// @custom:field root The output root.
                    /// @custom:field l2BlockNumber The L2 block number at which the output root was generated.
                    struct OutputRoot {
                        Hash root;
                        uint256 l2BlockNumber;
                    }
                    /// @title GameTypes
                    /// @notice A library that defines the IDs of games that can be played.
                    library GameTypes {
                        /// @dev A dispute game type the uses the cannon vm.
                        GameType internal constant CANNON = GameType.wrap(0);
                        /// @dev A permissioned dispute game type that uses the cannon vm.
                        GameType internal constant PERMISSIONED_CANNON = GameType.wrap(1);
                        /// @notice A dispute game type that uses the asterisc vm.
                        GameType internal constant ASTERISC = GameType.wrap(2);
                        /// @notice A dispute game type that uses the asterisc vm with Kona.
                        GameType internal constant ASTERISC_KONA = GameType.wrap(3);
                        /// @notice A dispute game type that uses OP Succinct
                        GameType internal constant OP_SUCCINCT = GameType.wrap(6);
                        /// @notice A dispute game type with short game duration for testing withdrawals.
                        ///         Not intended for production use.
                        GameType internal constant FAST = GameType.wrap(254);
                        /// @notice A dispute game type that uses an alphabet vm.
                        ///         Not intended for production use.
                        GameType internal constant ALPHABET = GameType.wrap(255);
                        /// @notice A dispute game type that uses RISC Zero's Kailua
                        GameType internal constant KAILUA = GameType.wrap(1337);
                    }
                    /// @title VMStatuses
                    /// @notice Named type aliases for the various valid VM status bytes.
                    library VMStatuses {
                        /// @notice The VM has executed successfully and the outcome is valid.
                        VMStatus internal constant VALID = VMStatus.wrap(0);
                        /// @notice The VM has executed successfully and the outcome is invalid.
                        VMStatus internal constant INVALID = VMStatus.wrap(1);
                        /// @notice The VM has paniced.
                        VMStatus internal constant PANIC = VMStatus.wrap(2);
                        /// @notice The VM execution is still in progress.
                        VMStatus internal constant UNFINISHED = VMStatus.wrap(3);
                    }
                    /// @title LocalPreimageKey
                    /// @notice Named type aliases for local `PreimageOracle` key identifiers.
                    library LocalPreimageKey {
                        /// @notice The identifier for the L1 head hash.
                        uint256 internal constant L1_HEAD_HASH = 0x01;
                        /// @notice The identifier for the starting output root.
                        uint256 internal constant STARTING_OUTPUT_ROOT = 0x02;
                        /// @notice The identifier for the disputed output root.
                        uint256 internal constant DISPUTED_OUTPUT_ROOT = 0x03;
                        /// @notice The identifier for the disputed L2 block number.
                        uint256 internal constant DISPUTED_L2_BLOCK_NUMBER = 0x04;
                        /// @notice The identifier for the chain ID.
                        uint256 internal constant CHAIN_ID = 0x05;
                    }
                    

                    File 10 of 11: OptimismPortal2
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    // Contracts
                    import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
                    import { ResourceMetering } from "src/L1/ResourceMetering.sol";
                    // Libraries
                    import { SafeERC20 } from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
                    import { EOA } from "src/libraries/EOA.sol";
                    import { SafeCall } from "src/libraries/SafeCall.sol";
                    import { Constants } from "src/libraries/Constants.sol";
                    import { Types } from "src/libraries/Types.sol";
                    import { Hashing } from "src/libraries/Hashing.sol";
                    import { SecureMerkleTrie } from "src/libraries/trie/SecureMerkleTrie.sol";
                    import { AddressAliasHelper } from "src/vendor/AddressAliasHelper.sol";
                    import {
                        BadTarget,
                        LargeCalldata,
                        SmallGasLimit,
                        Unauthorized,
                        CallPaused,
                        GasEstimation,
                        NonReentrant,
                        InvalidProof,
                        InvalidGameType,
                        InvalidDisputeGame,
                        InvalidMerkleProof,
                        Blacklisted,
                        Unproven,
                        ProposalNotValidated,
                        AlreadyFinalized,
                        LegacyGame
                    } from "src/libraries/PortalErrors.sol";
                    import { GameStatus, GameType, Claim, Timestamp } from "src/dispute/lib/Types.sol";
                    // Interfaces
                    import { IERC20 } from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
                    import { ISemver } from "interfaces/universal/ISemver.sol";
                    import { ISystemConfig } from "interfaces/L1/ISystemConfig.sol";
                    import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
                    import { ISuperchainConfig } from "interfaces/L1/ISuperchainConfig.sol";
                    import { IDisputeGameFactory } from "interfaces/dispute/IDisputeGameFactory.sol";
                    import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
                    /// @custom:proxied true
                    /// @title OptimismPortal2
                    /// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1
                    ///         and L2. Messages sent directly to the OptimismPortal have no form of replayability.
                    ///         Users are encouraged to use the L1CrossDomainMessenger for a higher-level interface.
                    contract OptimismPortal2 is Initializable, ResourceMetering, ISemver {
                        /// @notice Allows for interactions with non standard ERC20 tokens.
                        using SafeERC20 for IERC20;
                        /// @notice Represents a proven withdrawal.
                        /// @custom:field disputeGameProxy The address of the dispute game proxy that the withdrawal was proven against.
                        /// @custom:field timestamp        Timestamp at which the withdrawal was proven.
                        struct ProvenWithdrawal {
                            IDisputeGame disputeGameProxy;
                            uint64 timestamp;
                        }
                        /// @notice The delay between when a withdrawal transaction is proven and when it may be finalized.
                        uint256 internal immutable PROOF_MATURITY_DELAY_SECONDS;
                        /// @notice The delay between when a dispute game is resolved and when a withdrawal proven against it may be
                        ///         finalized.
                        uint256 internal immutable DISPUTE_GAME_FINALITY_DELAY_SECONDS;
                        /// @notice Version of the deposit event.
                        uint256 internal constant DEPOSIT_VERSION = 0;
                        /// @notice The L2 gas limit set when eth is deposited using the receive() function.
                        uint64 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;
                        /// @notice The L2 gas limit for system deposit transactions that are initiated from L1.
                        uint32 internal constant SYSTEM_DEPOSIT_GAS_LIMIT = 200_000;
                        /// @notice Address of the L2 account which initiated a withdrawal in this transaction.
                        ///         If the of this variable is the default L2 sender address, then we are NOT inside of
                        ///         a call to finalizeWithdrawalTransaction.
                        address public l2Sender;
                        /// @notice A list of withdrawal hashes which have been successfully finalized.
                        mapping(bytes32 => bool) public finalizedWithdrawals;
                        /// @custom:legacy
                        /// @custom:spacer provenWithdrawals
                        /// @notice Spacer taking up the legacy `provenWithdrawals` mapping slot.
                        bytes32 private spacer_52_0_32;
                        /// @custom:legacy
                        /// @custom:spacer paused
                        /// @notice Spacer for backwards compatibility.
                        bool private spacer_53_0_1;
                        /// @notice Contract of the Superchain Config.
                        ISuperchainConfig public superchainConfig;
                        /// @custom:legacy
                        /// @custom:spacer l2Oracle
                        /// @notice Spacer taking up the legacy `l2Oracle` address slot.
                        address private spacer_54_0_20;
                        /// @notice Contract of the SystemConfig.
                        /// @custom:network-specific
                        ISystemConfig public systemConfig;
                        /// @notice Address of the DisputeGameFactory.
                        /// @custom:network-specific
                        IDisputeGameFactory public disputeGameFactory;
                        /// @notice A mapping of withdrawal hashes to proof submitters to `ProvenWithdrawal` data.
                        mapping(bytes32 => mapping(address => ProvenWithdrawal)) public provenWithdrawals;
                        /// @notice A mapping of dispute game addresses to whether or not they are blacklisted.
                        mapping(IDisputeGame => bool) public disputeGameBlacklist;
                        /// @notice The game type that the OptimismPortal consults for output proposals.
                        GameType public respectedGameType;
                        /// @notice The timestamp at which the respected game type was last updated.
                        uint64 public respectedGameTypeUpdatedAt;
                        /// @notice Mapping of withdrawal hashes to addresses that have submitted a proof for the
                        ///         withdrawal. Original OptimismPortal contract only allowed one proof to be submitted
                        ///         for any given withdrawal hash. Fault Proofs version of this contract must allow
                        ///         multiple proofs for the same withdrawal hash to prevent a malicious user from
                        ///         blocking other withdrawals by proving them against invalid proposals. Submitters
                        ///         are tracked in an array to simplify the off-chain process of determining which
                        ///         proof submission should be used when finalizing a withdrawal.
                        mapping(bytes32 => address[]) public proofSubmitters;
                        /// @custom:legacy
                        /// @custom:spacer _balance
                        /// @notice Spacer taking up the legacy `_balance` slot.
                        uint256 private spacer_61_0_32;
                        /// @notice Emitted when a transaction is deposited from L1 to L2.
                        ///         The parameters of this event are read by the rollup node and used to derive deposit
                        ///         transactions on L2.
                        /// @param from       Address that triggered the deposit transaction.
                        /// @param to         Address that the deposit transaction is directed to.
                        /// @param version    Version of this deposit transaction event.
                        /// @param opaqueData ABI encoded deposit data to be parsed off-chain.
                        event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);
                        /// @notice Emitted when a withdrawal transaction is proven.
                        /// @param withdrawalHash Hash of the withdrawal transaction.
                        /// @param from           Address that triggered the withdrawal transaction.
                        /// @param to             Address that the withdrawal transaction is directed to.
                        event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);
                        /// @notice Emitted when a withdrawal transaction is proven. Exists as a separate event to allow for backwards
                        ///         compatibility for tooling that observes the `WithdrawalProven` event.
                        /// @param withdrawalHash Hash of the withdrawal transaction.
                        /// @param proofSubmitter Address of the proof submitter.
                        event WithdrawalProvenExtension1(bytes32 indexed withdrawalHash, address indexed proofSubmitter);
                        /// @notice Emitted when a withdrawal transaction is finalized.
                        /// @param withdrawalHash Hash of the withdrawal transaction.
                        /// @param success        Whether the withdrawal transaction was successful.
                        event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);
                        /// @notice Emitted when a dispute game is blacklisted by the Guardian.
                        /// @param disputeGame Address of the dispute game that was blacklisted.
                        event DisputeGameBlacklisted(IDisputeGame indexed disputeGame);
                        /// @notice Emitted when the Guardian changes the respected game type in the portal.
                        /// @param newGameType The new respected game type.
                        /// @param updatedAt   The timestamp at which the respected game type was updated.
                        event RespectedGameTypeSet(GameType indexed newGameType, Timestamp indexed updatedAt);
                        /// @notice Reverts when paused.
                        modifier whenNotPaused() {
                            if (paused()) revert CallPaused();
                            _;
                        }
                        /// @notice Semantic version.
                        /// @custom:semver 3.14.0
                        function version() public pure virtual returns (string memory) {
                            return "3.14.0";
                        }
                        /// @notice Constructs the OptimismPortal contract.
                        constructor(uint256 _proofMaturityDelaySeconds, uint256 _disputeGameFinalityDelaySeconds) {
                            PROOF_MATURITY_DELAY_SECONDS = _proofMaturityDelaySeconds;
                            DISPUTE_GAME_FINALITY_DELAY_SECONDS = _disputeGameFinalityDelaySeconds;
                            _disableInitializers();
                        }
                        /// @notice Initializer.
                        /// @param _disputeGameFactory Contract of the DisputeGameFactory.
                        /// @param _systemConfig Contract of the SystemConfig.
                        /// @param _superchainConfig Contract of the SuperchainConfig.
                        function initialize(
                            IDisputeGameFactory _disputeGameFactory,
                            ISystemConfig _systemConfig,
                            ISuperchainConfig _superchainConfig,
                            GameType _initialRespectedGameType
                        )
                            external
                            initializer
                        {
                            disputeGameFactory = _disputeGameFactory;
                            systemConfig = _systemConfig;
                            superchainConfig = _superchainConfig;
                            // Set the `l2Sender` slot, only if it is currently empty. This signals the first initialization of the
                            // contract.
                            if (l2Sender == address(0)) {
                                l2Sender = Constants.DEFAULT_L2_SENDER;
                                // Set the `respectedGameTypeUpdatedAt` timestamp, to ignore all games of the respected type prior
                                // to this operation.
                                respectedGameTypeUpdatedAt = uint64(block.timestamp);
                                // Set the initial respected game type
                                respectedGameType = _initialRespectedGameType;
                            }
                            __ResourceMetering_init();
                        }
                        /// @notice Getter function for the address of the guardian.
                        ///         Public getter is legacy and will be removed in the future. Use `SuperchainConfig.guardian()` instead.
                        /// @return Address of the guardian.
                        /// @custom:legacy
                        function guardian() public view returns (address) {
                            return superchainConfig.guardian();
                        }
                        /// @notice Getter for the current paused status.
                        function paused() public view returns (bool) {
                            return superchainConfig.paused();
                        }
                        /// @notice Getter for the proof maturity delay.
                        function proofMaturityDelaySeconds() public view returns (uint256) {
                            return PROOF_MATURITY_DELAY_SECONDS;
                        }
                        /// @notice Getter for the dispute game finality delay.
                        function disputeGameFinalityDelaySeconds() public view returns (uint256) {
                            return DISPUTE_GAME_FINALITY_DELAY_SECONDS;
                        }
                        /// @notice Computes the minimum gas limit for a deposit.
                        ///         The minimum gas limit linearly increases based on the size of the calldata.
                        ///         This is to prevent users from creating L2 resource usage without paying for it.
                        ///         This function can be used when interacting with the portal to ensure forwards
                        ///         compatibility.
                        /// @param _byteCount Number of bytes in the calldata.
                        /// @return The minimum gas limit for a deposit.
                        function minimumGasLimit(uint64 _byteCount) public pure returns (uint64) {
                            return _byteCount * 40 + 21000;
                        }
                        /// @notice Accepts value so that users can send ETH directly to this contract and have the
                        ///         funds be deposited to their address on L2. This is intended as a convenience
                        ///         function for EOAs. Contracts should call the depositTransaction() function directly
                        ///         otherwise any deposited funds will be lost due to address aliasing.
                        receive() external payable {
                            depositTransaction(msg.sender, msg.value, RECEIVE_DEFAULT_GAS_LIMIT, false, bytes(""));
                        }
                        /// @notice Accepts ETH value without triggering a deposit to L2.
                        ///         This function mainly exists for the sake of the migration between the legacy
                        ///         Optimism system and Bedrock.
                        function donateETH() external payable {
                            // Intentionally empty.
                        }
                        /// @notice Getter for the resource config.
                        ///         Used internally by the ResourceMetering contract.
                        ///         The SystemConfig is the source of truth for the resource config.
                        /// @return config_ ResourceMetering ResourceConfig
                        function _resourceConfig() internal view override returns (ResourceMetering.ResourceConfig memory config_) {
                            IResourceMetering.ResourceConfig memory config = systemConfig.resourceConfig();
                            assembly ("memory-safe") {
                                config_ := config
                            }
                        }
                        /// @notice Proves a withdrawal transaction.
                        /// @param _tx               Withdrawal transaction to finalize.
                        /// @param _disputeGameIndex Index of the dispute game to prove the withdrawal against.
                        /// @param _outputRootProof  Inclusion proof of the L2ToL1MessagePasser contract's storage root.
                        /// @param _withdrawalProof  Inclusion proof of the withdrawal in L2ToL1MessagePasser contract.
                        function proveWithdrawalTransaction(
                            Types.WithdrawalTransaction memory _tx,
                            uint256 _disputeGameIndex,
                            Types.OutputRootProof calldata _outputRootProof,
                            bytes[] calldata _withdrawalProof
                        )
                            external
                            whenNotPaused
                        {
                            // Prevent users from creating a deposit transaction where this address is the message
                            // sender on L2. Because this is checked here, we do not need to check again in
                            // `finalizeWithdrawalTransaction`.
                            if (_tx.target == address(this)) revert BadTarget();
                            // Fetch the dispute game proxy from the `DisputeGameFactory` contract.
                            (GameType gameType,, IDisputeGame gameProxy) = disputeGameFactory.gameAtIndex(_disputeGameIndex);
                            Claim outputRoot = gameProxy.rootClaim();
                            // The game type of the dispute game must be the respected game type.
                            if (gameType.raw() != respectedGameType.raw()) revert InvalidGameType();
                            // The game type of the DisputeGame must have been the respected game type at creation.
                            // eip150-safe
                            try gameProxy.wasRespectedGameTypeWhenCreated() returns (bool wasRespected_) {
                                if (!wasRespected_) revert InvalidGameType();
                            } catch {
                                revert LegacyGame();
                            }
                            // Game must have been created after the respected game type was updated. This check is a
                            // strict inequality because we want to prevent users from being able to prove or finalize
                            // withdrawals against games that were created in the same block that the retirement
                            // timestamp was set. If the retirement timestamp and game type are changed in the same
                            // block, such games could still be considered valid even if they used the old game type
                            // that we intended to invalidate.
                            require(
                                gameProxy.createdAt().raw() > respectedGameTypeUpdatedAt,
                                "OptimismPortal: dispute game created before respected game type was updated"
                            );
                            // Verify that the output root can be generated with the elements in the proof.
                            if (outputRoot.raw() != Hashing.hashOutputRootProof(_outputRootProof)) revert InvalidProof();
                            // Load the ProvenWithdrawal into memory, using the withdrawal hash as a unique identifier.
                            bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
                            // We do not allow for proving withdrawals against dispute games that have resolved against the favor
                            // of the root claim.
                            if (gameProxy.status() == GameStatus.CHALLENGER_WINS) revert InvalidDisputeGame();
                            // Compute the storage slot of the withdrawal hash in the L2ToL1MessagePasser contract.
                            // Refer to the Solidity documentation for more information on how storage layouts are
                            // computed for mappings.
                            bytes32 storageKey = keccak256(
                                abi.encode(
                                    withdrawalHash,
                                    uint256(0) // The withdrawals mapping is at the first slot in the layout.
                                )
                            );
                            // Verify that the hash of this withdrawal was stored in the L2toL1MessagePasser contract
                            // on L2. If this is true, under the assumption that the SecureMerkleTrie does not have
                            // bugs, then we know that this withdrawal was actually triggered on L2 and can therefore
                            // be relayed on L1.
                            if (
                                SecureMerkleTrie.verifyInclusionProof({
                                    _key: abi.encode(storageKey),
                                    _value: hex"01",
                                    _proof: _withdrawalProof,
                                    _root: _outputRootProof.messagePasserStorageRoot
                                }) == false
                            ) revert InvalidMerkleProof();
                            // Designate the withdrawalHash as proven by storing the `disputeGameProxy` & `timestamp` in the
                            // `provenWithdrawals` mapping. A `withdrawalHash` can only be proven once unless the dispute game it proved
                            // against resolves against the favor of the root claim.
                            provenWithdrawals[withdrawalHash][msg.sender] =
                                ProvenWithdrawal({ disputeGameProxy: gameProxy, timestamp: uint64(block.timestamp) });
                            // Emit a `WithdrawalProven` event.
                            emit WithdrawalProven(withdrawalHash, _tx.sender, _tx.target);
                            // Emit a `WithdrawalProvenExtension1` event.
                            emit WithdrawalProvenExtension1(withdrawalHash, msg.sender);
                            // Add the proof submitter to the list of proof submitters for this withdrawal hash.
                            proofSubmitters[withdrawalHash].push(msg.sender);
                        }
                        /// @notice Finalizes a withdrawal transaction.
                        /// @param _tx Withdrawal transaction to finalize.
                        function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external whenNotPaused {
                            finalizeWithdrawalTransactionExternalProof(_tx, msg.sender);
                        }
                        /// @notice Finalizes a withdrawal transaction, using an external proof submitter.
                        /// @param _tx Withdrawal transaction to finalize.
                        /// @param _proofSubmitter Address of the proof submitter.
                        function finalizeWithdrawalTransactionExternalProof(
                            Types.WithdrawalTransaction memory _tx,
                            address _proofSubmitter
                        )
                            public
                            whenNotPaused
                        {
                            // Make sure that the l2Sender has not yet been set. The l2Sender is set to a value other
                            // than the default value when a withdrawal transaction is being finalized. This check is
                            // a defacto reentrancy guard.
                            if (l2Sender != Constants.DEFAULT_L2_SENDER) revert NonReentrant();
                            // Compute the withdrawal hash.
                            bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);
                            // Check that the withdrawal can be finalized.
                            checkWithdrawal(withdrawalHash, _proofSubmitter);
                            // Mark the withdrawal as finalized so it can't be replayed.
                            finalizedWithdrawals[withdrawalHash] = true;
                            // Set the l2Sender so contracts know who triggered this withdrawal on L2.
                            l2Sender = _tx.sender;
                            // Trigger the call to the target contract. We use a custom low level method
                            // SafeCall.callWithMinGas to ensure two key properties
                            //   1. Target contracts cannot force this call to run out of gas by returning a very large
                            //      amount of data (and this is OK because we don't care about the returndata here).
                            //   2. The amount of gas provided to the execution context of the target is at least the
                            //      gas limit specified by the user. If there is not enough gas in the current context
                            //      to accomplish this, `callWithMinGas` will revert.
                            bool success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data);
                            // Reset the l2Sender back to the default value.
                            l2Sender = Constants.DEFAULT_L2_SENDER;
                            // All withdrawals are immediately finalized. Replayability can
                            // be achieved through contracts built on top of this contract
                            emit WithdrawalFinalized(withdrawalHash, success);
                            // Reverting here is useful for determining the exact gas cost to successfully execute the
                            // sub call to the target contract if the minimum gas limit specified by the user would not
                            // be sufficient to execute the sub call.
                            if (!success && tx.origin == Constants.ESTIMATION_ADDRESS) {
                                revert GasEstimation();
                            }
                        }
                        /// @notice Accepts deposits of ETH and data, and emits a TransactionDeposited event for use in
                        ///         deriving deposit transactions. Note that if a deposit is made by a contract, its
                        ///         address will be aliased when retrieved using `tx.origin` or `msg.sender`. Consider
                        ///         using the CrossDomainMessenger contracts for a simpler developer experience.
                        /// @param _to         Target address on L2.
                        /// @param _value      ETH value to send to the recipient.
                        /// @param _gasLimit   Amount of L2 gas to purchase by burning gas on L1.
                        /// @param _isCreation Whether or not the transaction is a contract creation.
                        /// @param _data       Data to trigger the recipient with.
                        function depositTransaction(
                            address _to,
                            uint256 _value,
                            uint64 _gasLimit,
                            bool _isCreation,
                            bytes memory _data
                        )
                            public
                            payable
                            metered(_gasLimit)
                        {
                            // Just to be safe, make sure that people specify address(0) as the target when doing
                            // contract creations.
                            if (_isCreation && _to != address(0)) revert BadTarget();
                            // Prevent depositing transactions that have too small of a gas limit. Users should pay
                            // more for more resource usage.
                            if (_gasLimit < minimumGasLimit(uint64(_data.length))) revert SmallGasLimit();
                            // Prevent the creation of deposit transactions that have too much calldata. This gives an
                            // upper limit on the size of unsafe blocks over the p2p network. 120kb is chosen to ensure
                            // that the transaction can fit into the p2p network policy of 128kb even though deposit
                            // transactions are not gossipped over the p2p network.
                            if (_data.length > 120_000) revert LargeCalldata();
                            // Transform the from-address to its alias if the caller is a contract.
                            address from = msg.sender;
                            if (!EOA.isSenderEOA()) {
                                from = AddressAliasHelper.applyL1ToL2Alias(msg.sender);
                            }
                            // Compute the opaque data that will be emitted as part of the TransactionDeposited event.
                            // We use opaque data so that we can update the TransactionDeposited event in the future
                            // without breaking the current interface.
                            bytes memory opaqueData = abi.encodePacked(msg.value, _value, _gasLimit, _isCreation, _data);
                            // Emit a TransactionDeposited event so that the rollup node can derive a deposit
                            // transaction for this deposit.
                            emit TransactionDeposited(from, _to, DEPOSIT_VERSION, opaqueData);
                        }
                        /// @notice Blacklists a dispute game. Should only be used in the event that a dispute game resolves incorrectly.
                        /// @param _disputeGame Dispute game to blacklist.
                        function blacklistDisputeGame(IDisputeGame _disputeGame) external {
                            if (msg.sender != guardian()) revert Unauthorized();
                            disputeGameBlacklist[_disputeGame] = true;
                            emit DisputeGameBlacklisted(_disputeGame);
                        }
                        /// @notice Sets the respected game type. Changing this value can alter the security properties of the system,
                        ///         depending on the new game's behavior.
                        /// @param _gameType The game type to consult for output proposals.
                        function setRespectedGameType(GameType _gameType) external {
                            if (msg.sender != guardian()) revert Unauthorized();
                            // respectedGameTypeUpdatedAt is now no longer set by default. We want to avoid modifying
                            // this function's signature as that would result in changes to the DeputyGuardianModule.
                            // We use type(uint32).max as a temporary solution to allow us to update the
                            // respectedGameTypeUpdatedAt timestamp without modifying this function's signature.
                            if (_gameType.raw() == type(uint32).max) {
                                respectedGameTypeUpdatedAt = uint64(block.timestamp);
                            } else {
                                respectedGameType = _gameType;
                            }
                            emit RespectedGameTypeSet(respectedGameType, Timestamp.wrap(respectedGameTypeUpdatedAt));
                        }
                        /// @notice Checks if a withdrawal can be finalized. This function will revert if the withdrawal cannot be
                        ///         finalized, and otherwise has no side-effects.
                        /// @param _withdrawalHash Hash of the withdrawal to check.
                        /// @param _proofSubmitter The submitter of the proof for the withdrawal hash
                        function checkWithdrawal(bytes32 _withdrawalHash, address _proofSubmitter) public view {
                            ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[_withdrawalHash][_proofSubmitter];
                            IDisputeGame disputeGameProxy = provenWithdrawal.disputeGameProxy;
                            // The dispute game must not be blacklisted.
                            if (disputeGameBlacklist[disputeGameProxy]) revert Blacklisted();
                            // A withdrawal can only be finalized if it has been proven. We know that a withdrawal has
                            // been proven at least once when its timestamp is non-zero. Unproven withdrawals will have
                            // a timestamp of zero.
                            if (provenWithdrawal.timestamp == 0) revert Unproven();
                            // Grab the createdAt timestamp once.
                            uint64 createdAt = disputeGameProxy.createdAt().raw();
                            // As a sanity check, we make sure that the proven withdrawal's timestamp is greater than
                            // starting timestamp inside the Dispute Game. Not strictly necessary but extra layer of
                            // safety against weird bugs in the proving step.
                            require(
                                provenWithdrawal.timestamp > createdAt,
                                "OptimismPortal: withdrawal timestamp less than dispute game creation timestamp"
                            );
                            // A proven withdrawal must wait at least `PROOF_MATURITY_DELAY_SECONDS` before finalizing.
                            require(
                                block.timestamp - provenWithdrawal.timestamp > PROOF_MATURITY_DELAY_SECONDS,
                                "OptimismPortal: proven withdrawal has not matured yet"
                            );
                            // A proven withdrawal must wait until the dispute game it was proven against has been
                            // resolved in favor of the root claim (the output proposal). This is to prevent users
                            // from finalizing withdrawals proven against non-finalized output roots.
                            if (disputeGameProxy.status() != GameStatus.DEFENDER_WINS) revert ProposalNotValidated();
                            // The game type of the dispute game must have been the respected game type at creation
                            // time. We check that the game type is the respected game type at proving time, but it's
                            // possible that the respected game type has since changed. Users can still use this game
                            // to finalize a withdrawal as long as it has not been otherwise invalidated.
                            // The game type of the DisputeGame must have been the respected game type at creation.
                            // eip150-safe
                            try disputeGameProxy.wasRespectedGameTypeWhenCreated() returns (bool wasRespected_) {
                                if (!wasRespected_) revert InvalidGameType();
                            } catch {
                                revert LegacyGame();
                            }
                            // Game must have been created after the respected game type was updated. This check is a
                            // strict inequality because we want to prevent users from being able to prove or finalize
                            // withdrawals against games that were created in the same block that the retirement
                            // timestamp was set. If the retirement timestamp and game type are changed in the same
                            // block, such games could still be considered valid even if they used the old game type
                            // that we intended to invalidate.
                            require(
                                createdAt > respectedGameTypeUpdatedAt,
                                "OptimismPortal: dispute game created before respected game type was updated"
                            );
                            // Before a withdrawal can be finalized, the dispute game it was proven against must have been
                            // resolved for at least `DISPUTE_GAME_FINALITY_DELAY_SECONDS`. This is to allow for manual
                            // intervention in the event that a dispute game is resolved incorrectly.
                            require(
                                block.timestamp - disputeGameProxy.resolvedAt().raw() > DISPUTE_GAME_FINALITY_DELAY_SECONDS,
                                "OptimismPortal: output proposal in air-gap"
                            );
                            // Check that this withdrawal has not already been finalized, this is replay protection.
                            if (finalizedWithdrawals[_withdrawalHash]) revert AlreadyFinalized();
                        }
                        /// @notice External getter for the number of proof submitters for a withdrawal hash.
                        /// @param _withdrawalHash Hash of the withdrawal.
                        /// @return The number of proof submitters for the withdrawal hash.
                        function numProofSubmitters(bytes32 _withdrawalHash) external view returns (uint256) {
                            return proofSubmitters[_withdrawalHash].length;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
                    pragma solidity ^0.8.2;
                    import "../../utils/Address.sol";
                    /**
                     * @dev 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]
                     * ```
                     * 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]
                     * ```
                     * /// @custom:oz-upgrades-unsafe-allow constructor
                     * constructor() {
                     *     _disableInitializers();
                     * }
                     * ```
                     * ====
                     */
                    abstract contract Initializable {
                        /**
                         * @dev Indicates that the contract has been initialized.
                         * @custom:oz-retyped-from bool
                         */
                        uint8 private _initialized;
                        /**
                         * @dev Indicates that the contract is in the process of being initialized.
                         */
                        bool private _initializing;
                        /**
                         * @dev Triggered when the contract has been initialized or reinitialized.
                         */
                        event Initialized(uint8 version);
                        /**
                         * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
                         * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
                         */
                        modifier initializer() {
                            bool isTopLevelCall = !_initializing;
                            require(
                                (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),
                                "Initializable: contract is already initialized"
                            );
                            _initialized = 1;
                            if (isTopLevelCall) {
                                _initializing = true;
                            }
                            _;
                            if (isTopLevelCall) {
                                _initializing = false;
                                emit Initialized(1);
                            }
                        }
                        /**
                         * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
                         * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
                         * used to initialize parent contracts.
                         *
                         * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
                         * initialization step. This is essential to configure modules that are added through upgrades and that require
                         * initialization.
                         *
                         * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
                         * a contract, executing them in the right order is up to the developer or operator.
                         */
                        modifier reinitializer(uint8 version) {
                            require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
                            _initialized = version;
                            _initializing = true;
                            _;
                            _initializing = false;
                            emit Initialized(version);
                        }
                        /**
                         * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
                         * {initializer} and {reinitializer} modifiers, directly or indirectly.
                         */
                        modifier onlyInitializing() {
                            require(_initializing, "Initializable: contract is not initializing");
                            _;
                        }
                        /**
                         * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
                         * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
                         * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
                         * through proxies.
                         */
                        function _disableInitializers() internal virtual {
                            require(!_initializing, "Initializable: contract is initializing");
                            if (_initialized < type(uint8).max) {
                                _initialized = type(uint8).max;
                                emit Initialized(type(uint8).max);
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    // Contracts
                    import { Initializable } from "@openzeppelin/contracts/proxy/utils/Initializable.sol";
                    // Libraries
                    import { Math } from "@openzeppelin/contracts/utils/math/Math.sol";
                    import { Burn } from "src/libraries/Burn.sol";
                    import { Arithmetic } from "src/libraries/Arithmetic.sol";
                    /// @custom:upgradeable
                    /// @title ResourceMetering
                    /// @notice ResourceMetering implements an EIP-1559 style resource metering system where pricing
                    ///         updates automatically based on current demand.
                    abstract contract ResourceMetering is Initializable {
                        /// @notice Error returned when too much gas resource is consumed.
                        error OutOfGas();
                        /// @notice Represents the various parameters that control the way in which resources are
                        ///         metered. Corresponds to the EIP-1559 resource metering system.
                        /// @custom:field prevBaseFee   Base fee from the previous block(s).
                        /// @custom:field prevBoughtGas Amount of gas bought so far in the current block.
                        /// @custom:field prevBlockNum  Last block number that the base fee was updated.
                        struct ResourceParams {
                            uint128 prevBaseFee;
                            uint64 prevBoughtGas;
                            uint64 prevBlockNum;
                        }
                        /// @notice Represents the configuration for the EIP-1559 based curve for the deposit gas
                        ///         market. These values should be set with care as it is possible to set them in
                        ///         a way that breaks the deposit gas market. The target resource limit is defined as
                        ///         maxResourceLimit / elasticityMultiplier. This struct was designed to fit within a
                        ///         single word. There is additional space for additions in the future.
                        /// @custom:field maxResourceLimit             Represents the maximum amount of deposit gas that
                        ///                                            can be purchased per block.
                        /// @custom:field elasticityMultiplier         Determines the target resource limit along with
                        ///                                            the resource limit.
                        /// @custom:field baseFeeMaxChangeDenominator  Determines max change on fee per block.
                        /// @custom:field minimumBaseFee               The min deposit base fee, it is clamped to this
                        ///                                            value.
                        /// @custom:field systemTxMaxGas               The amount of gas supplied to the system
                        ///                                            transaction. This should be set to the same
                        ///                                            number that the op-node sets as the gas limit
                        ///                                            for the system transaction.
                        /// @custom:field maximumBaseFee               The max deposit base fee, it is clamped to this
                        ///                                            value.
                        struct ResourceConfig {
                            uint32 maxResourceLimit;
                            uint8 elasticityMultiplier;
                            uint8 baseFeeMaxChangeDenominator;
                            uint32 minimumBaseFee;
                            uint32 systemTxMaxGas;
                            uint128 maximumBaseFee;
                        }
                        /// @notice EIP-1559 style gas parameters.
                        ResourceParams public params;
                        /// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.
                        uint256[48] private __gap;
                        /// @notice Meters access to a function based an amount of a requested resource.
                        /// @param _amount Amount of the resource requested.
                        modifier metered(uint64 _amount) {
                            // Record initial gas amount so we can refund for it later.
                            uint256 initialGas = gasleft();
                            // Run the underlying function.
                            _;
                            // Run the metering function.
                            _metered(_amount, initialGas);
                        }
                        /// @notice An internal function that holds all of the logic for metering a resource.
                        /// @param _amount     Amount of the resource requested.
                        /// @param _initialGas The amount of gas before any modifier execution.
                        function _metered(uint64 _amount, uint256 _initialGas) internal {
                            // Update block number and base fee if necessary.
                            uint256 blockDiff = block.number - params.prevBlockNum;
                            ResourceConfig memory config = _resourceConfig();
                            int256 targetResourceLimit =
                                int256(uint256(config.maxResourceLimit)) / int256(uint256(config.elasticityMultiplier));
                            if (blockDiff > 0) {
                                // Handle updating EIP-1559 style gas parameters. We use EIP-1559 to restrict the rate
                                // at which deposits can be created and therefore limit the potential for deposits to
                                // spam the L2 system. Fee scheme is very similar to EIP-1559 with minor changes.
                                int256 gasUsedDelta = int256(uint256(params.prevBoughtGas)) - targetResourceLimit;
                                int256 baseFeeDelta = (int256(uint256(params.prevBaseFee)) * gasUsedDelta)
                                    / (targetResourceLimit * int256(uint256(config.baseFeeMaxChangeDenominator)));
                                // Update base fee by adding the base fee delta and clamp the resulting value between
                                // min and max.
                                int256 newBaseFee = Arithmetic.clamp({
                                    _value: int256(uint256(params.prevBaseFee)) + baseFeeDelta,
                                    _min: int256(uint256(config.minimumBaseFee)),
                                    _max: int256(uint256(config.maximumBaseFee))
                                });
                                // If we skipped more than one block, we also need to account for every empty block.
                                // Empty block means there was no demand for deposits in that block, so we should
                                // reflect this lack of demand in the fee.
                                if (blockDiff > 1) {
                                    // Update the base fee by repeatedly applying the exponent 1-(1/change_denominator)
                                    // blockDiff - 1 times. Simulates multiple empty blocks. Clamp the resulting value
                                    // between min and max.
                                    newBaseFee = Arithmetic.clamp({
                                        _value: Arithmetic.cdexp({
                                            _coefficient: newBaseFee,
                                            _denominator: int256(uint256(config.baseFeeMaxChangeDenominator)),
                                            _exponent: int256(blockDiff - 1)
                                        }),
                                        _min: int256(uint256(config.minimumBaseFee)),
                                        _max: int256(uint256(config.maximumBaseFee))
                                    });
                                }
                                // Update new base fee, reset bought gas, and update block number.
                                params.prevBaseFee = uint128(uint256(newBaseFee));
                                params.prevBoughtGas = 0;
                                params.prevBlockNum = uint64(block.number);
                            }
                            // Make sure we can actually buy the resource amount requested by the user.
                            params.prevBoughtGas += _amount;
                            if (int256(uint256(params.prevBoughtGas)) > int256(uint256(config.maxResourceLimit))) {
                                revert OutOfGas();
                            }
                            // Determine the amount of ETH to be paid.
                            uint256 resourceCost = uint256(_amount) * uint256(params.prevBaseFee);
                            // We currently charge for this ETH amount as an L1 gas burn, so we convert the ETH amount
                            // into gas by dividing by the L1 base fee. We assume a minimum base fee of 1 gwei to avoid
                            // division by zero for L1s that don't support 1559 or to avoid excessive gas burns during
                            // periods of extremely low L1 demand. One-day average gas fee hasn't dipped below 1 gwei
                            // during any 1 day period in the last 5 years, so should be fine.
                            uint256 gasCost = resourceCost / Math.max(block.basefee, 1 gwei);
                            // Give the user a refund based on the amount of gas they used to do all of the work up to
                            // this point. Since we're at the end of the modifier, this should be pretty accurate. Acts
                            // effectively like a dynamic stipend (with a minimum value).
                            uint256 usedGas = _initialGas - gasleft();
                            if (gasCost > usedGas) {
                                Burn.gas(gasCost - usedGas);
                            }
                        }
                        /// @notice Adds an amount of L2 gas consumed to the prev bought gas params. This is meant to be used
                        ///         when L2 system transactions are generated from L1.
                        /// @param _amount Amount of the L2 gas resource requested.
                        function useGas(uint32 _amount) internal {
                            params.prevBoughtGas += uint64(_amount);
                        }
                        /// @notice Virtual function that returns the resource config.
                        ///         Contracts that inherit this contract must implement this function.
                        /// @return ResourceConfig
                        function _resourceConfig() internal virtual returns (ResourceConfig memory);
                        /// @notice Sets initial resource parameter values.
                        ///         This function must either be called by the initializer function of an upgradeable
                        ///         child contract.
                        function __ResourceMetering_init() internal onlyInitializing {
                            if (params.prevBlockNum == 0) {
                                params = ResourceParams({ prevBaseFee: 1 gwei, prevBoughtGas: 0, prevBlockNum: uint64(block.number) });
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)
                    pragma solidity ^0.8.0;
                    import "../IERC20.sol";
                    import "../extensions/draft-IERC20Permit.sol";
                    import "../../../utils/Address.sol";
                    /**
                     * @title SafeERC20
                     * @dev 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.
                     */
                    library SafeERC20 {
                        using Address for address;
                        function safeTransfer(
                            IERC20 token,
                            address to,
                            uint256 value
                        ) internal {
                            _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
                        }
                        function safeTransferFrom(
                            IERC20 token,
                            address from,
                            address to,
                            uint256 value
                        ) internal {
                            _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
                        }
                        /**
                         * @dev Deprecated. This function has issues similar to the ones found in
                         * {IERC20-approve}, and its usage is discouraged.
                         *
                         * Whenever possible, use {safeIncreaseAllowance} and
                         * {safeDecreaseAllowance} instead.
                         */
                        function safeApprove(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            // safeApprove should only be called when setting an initial allowance,
                            // or when resetting it to zero. To increase and decrease it, use
                            // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
                            require(
                                (value == 0) || (token.allowance(address(this), spender) == 0),
                                "SafeERC20: approve from non-zero to non-zero allowance"
                            );
                            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
                        }
                        function safeIncreaseAllowance(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            uint256 newAllowance = token.allowance(address(this), spender) + value;
                            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                        }
                        function safeDecreaseAllowance(
                            IERC20 token,
                            address spender,
                            uint256 value
                        ) internal {
                            unchecked {
                                uint256 oldAllowance = token.allowance(address(this), spender);
                                require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
                                uint256 newAllowance = oldAllowance - value;
                                _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
                            }
                        }
                        function safePermit(
                            IERC20Permit token,
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) internal {
                            uint256 nonceBefore = token.nonces(owner);
                            token.permit(owner, spender, value, deadline, v, r, s);
                            uint256 nonceAfter = token.nonces(owner);
                            require(nonceAfter == nonceBefore + 1, "SafeERC20: permit did not succeed");
                        }
                        /**
                         * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
                         * on the return value: the return value is optional (but if data is returned, it must not be false).
                         * @param token The token targeted by the call.
                         * @param data The call data (encoded using abi.encode or one of its variants).
                         */
                        function _callOptionalReturn(IERC20 token, bytes memory data) private {
                            // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
                            // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
                            // the target address contains contract code and also asserts for success in the low-level call.
                            bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
                            if (returndata.length > 0) {
                                // Return data is optional
                                require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title EOA
                    /// @notice A library for detecting if an address is an EOA.
                    library EOA {
                        /// @notice Returns true if sender address is an EOA.
                        /// @return isEOA_ True if the sender address is an EOA.
                        function isSenderEOA() internal view returns (bool isEOA_) {
                            if (msg.sender == tx.origin) {
                                isEOA_ = true;
                            } else if (address(msg.sender).code.length == 23) {
                                // If the sender is not the origin, check for 7702 delegated EOAs.
                                assembly {
                                    let ptr := mload(0x40)
                                    mstore(0x40, add(ptr, 0x20))
                                    extcodecopy(caller(), ptr, 0, 0x20)
                                    isEOA_ := eq(shr(232, mload(ptr)), 0xEF0100)
                                }
                            } else {
                                // If more or less than 23 bytes of code, not a 7702 delegated EOA.
                                isEOA_ = false;
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title SafeCall
                    /// @notice Perform low level safe calls
                    library SafeCall {
                        /// @notice Performs a low level call without copying any returndata.
                        /// @dev Passes no calldata to the call context.
                        /// @param _target   Address to call
                        /// @param _gas      Amount of gas to pass to the call
                        /// @param _value    Amount of value to pass to the call
                        function send(address _target, uint256 _gas, uint256 _value) internal returns (bool success_) {
                            assembly {
                                success_ :=
                                    call(
                                        _gas, // gas
                                        _target, // recipient
                                        _value, // ether value
                                        0, // inloc
                                        0, // inlen
                                        0, // outloc
                                        0 // outlen
                                    )
                            }
                        }
                        /// @notice Perform a low level call with all gas without copying any returndata
                        /// @param _target   Address to call
                        /// @param _value    Amount of value to pass to the call
                        function send(address _target, uint256 _value) internal returns (bool success_) {
                            success_ = send(_target, gasleft(), _value);
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _gas      Amount of gas to pass to the call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function call(
                            address _target,
                            uint256 _gas,
                            uint256 _value,
                            bytes memory _calldata
                        )
                            internal
                            returns (bool success_)
                        {
                            assembly {
                                success_ :=
                                    call(
                                        _gas, // gas
                                        _target, // recipient
                                        _value, // ether value
                                        add(_calldata, 32), // inloc
                                        mload(_calldata), // inlen
                                        0, // outloc
                                        0 // outlen
                                    )
                            }
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function call(address _target, uint256 _value, bytes memory _calldata) internal returns (bool success_) {
                            success_ = call({ _target: _target, _gas: gasleft(), _value: _value, _calldata: _calldata });
                        }
                        /// @notice Perform a low level call without copying any returndata
                        /// @param _target   Address to call
                        /// @param _calldata Calldata to pass to the call
                        function call(address _target, bytes memory _calldata) internal returns (bool success_) {
                            success_ = call({ _target: _target, _gas: gasleft(), _value: 0, _calldata: _calldata });
                        }
                        /// @notice Helper function to determine if there is sufficient gas remaining within the context
                        ///         to guarantee that the minimum gas requirement for a call will be met as well as
                        ///         optionally reserving a specified amount of gas for after the call has concluded.
                        /// @param _minGas      The minimum amount of gas that may be passed to the target context.
                        /// @param _reservedGas Optional amount of gas to reserve for the caller after the execution
                        ///                     of the target context.
                        /// @return `true` if there is enough gas remaining to safely supply `_minGas` to the target
                        ///         context as well as reserve `_reservedGas` for the caller after the execution of
                        ///         the target context.
                        /// @dev !!!!! FOOTGUN ALERT !!!!!
                        ///      1.) The 40_000 base buffer is to account for the worst case of the dynamic cost of the
                        ///          `CALL` opcode's `address_access_cost`, `positive_value_cost`, and
                        ///          `value_to_empty_account_cost` factors with an added buffer of 5,700 gas. It is
                        ///          still possible to self-rekt by initiating a withdrawal with a minimum gas limit
                        ///          that does not account for the `memory_expansion_cost` & `code_execution_cost`
                        ///          factors of the dynamic cost of the `CALL` opcode.
                        ///      2.) This function should *directly* precede the external call if possible. There is an
                        ///          added buffer to account for gas consumed between this check and the call, but it
                        ///          is only 5,700 gas.
                        ///      3.) Because EIP-150 ensures that a maximum of 63/64ths of the remaining gas in the call
                        ///          frame may be passed to a subcontext, we need to ensure that the gas will not be
                        ///          truncated.
                        ///      4.) Use wisely. This function is not a silver bullet.
                        function hasMinGas(uint256 _minGas, uint256 _reservedGas) internal view returns (bool) {
                            bool _hasMinGas;
                            assembly {
                                // Equation: gas × 63 ≥ minGas × 64 + 63(40_000 + reservedGas)
                                _hasMinGas := iszero(lt(mul(gas(), 63), add(mul(_minGas, 64), mul(add(40000, _reservedGas), 63))))
                            }
                            return _hasMinGas;
                        }
                        /// @notice Perform a low level call without copying any returndata. This function
                        ///         will revert if the call cannot be performed with the specified minimum
                        ///         gas.
                        /// @param _target   Address to call
                        /// @param _minGas   The minimum amount of gas that may be passed to the call
                        /// @param _value    Amount of value to pass to the call
                        /// @param _calldata Calldata to pass to the call
                        function callWithMinGas(
                            address _target,
                            uint256 _minGas,
                            uint256 _value,
                            bytes memory _calldata
                        )
                            internal
                            returns (bool)
                        {
                            bool _success;
                            bool _hasMinGas = hasMinGas(_minGas, 0);
                            assembly {
                                // Assertion: gasleft() >= (_minGas * 64) / 63 + 40_000
                                if iszero(_hasMinGas) {
                                    // Store the "Error(string)" selector in scratch space.
                                    mstore(0, 0x08c379a0)
                                    // Store the pointer to the string length in scratch space.
                                    mstore(32, 32)
                                    // Store the string.
                                    //
                                    // SAFETY:
                                    // - We pad the beginning of the string with two zero bytes as well as the
                                    // length (24) to ensure that we override the free memory pointer at offset
                                    // 0x40. This is necessary because the free memory pointer is likely to
                                    // be greater than 1 byte when this function is called, but it is incredibly
                                    // unlikely that it will be greater than 3 bytes. As for the data within
                                    // 0x60, it is ensured that it is 0 due to 0x60 being the zero offset.
                                    // - It's fine to clobber the free memory pointer, we're reverting.
                                    mstore(88, 0x0000185361666543616c6c3a204e6f7420656e6f75676820676173)
                                    // Revert with 'Error("SafeCall: Not enough gas")'
                                    revert(28, 100)
                                }
                                // The call will be supplied at least ((_minGas * 64) / 63) gas due to the
                                // above assertion. This ensures that, in all circumstances (except for when the
                                // `_minGas` does not account for the `memory_expansion_cost` and `code_execution_cost`
                                // factors of the dynamic cost of the `CALL` opcode), the call will receive at least
                                // the minimum amount of gas specified.
                                _success :=
                                    call(
                                        gas(), // gas
                                        _target, // recipient
                                        _value, // ether value
                                        add(_calldata, 32), // inloc
                                        mload(_calldata), // inlen
                                        0x00, // outloc
                                        0x00 // outlen
                                    )
                            }
                            return _success;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Interfaces
                    import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
                    /// @title Constants
                    /// @notice Constants is a library for storing constants. Simple! Don't put everything in here, just
                    ///         the stuff used in multiple contracts. Constants that only apply to a single contract
                    ///         should be defined in that contract instead.
                    library Constants {
                        /// @notice Special address to be used as the tx origin for gas estimation calls in the
                        ///         OptimismPortal and CrossDomainMessenger calls. You only need to use this address if
                        ///         the minimum gas limit specified by the user is not actually enough to execute the
                        ///         given message and you're attempting to estimate the actual necessary gas limit. We
                        ///         use address(1) because it's the ecrecover precompile and therefore guaranteed to
                        ///         never have any code on any EVM chain.
                        address internal constant ESTIMATION_ADDRESS = address(1);
                        /// @notice Value used for the L2 sender storage slot in both the OptimismPortal and the
                        ///         CrossDomainMessenger contracts before an actual sender is set. This value is
                        ///         non-zero to reduce the gas cost of message passing transactions.
                        address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD;
                        /// @notice The storage slot that holds the address of a proxy implementation.
                        /// @dev `bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)`
                        bytes32 internal constant PROXY_IMPLEMENTATION_ADDRESS =
                            0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                        /// @notice The storage slot that holds the address of the owner.
                        /// @dev `bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)`
                        bytes32 internal constant PROXY_OWNER_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                        /// @notice The address that represents ether when dealing with ERC20 token addresses.
                        address internal constant ETHER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;
                        /// @notice The address that represents the system caller responsible for L1 attributes
                        ///         transactions.
                        address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;
                        /// @notice Returns the default values for the ResourceConfig. These are the recommended values
                        ///         for a production network.
                        function DEFAULT_RESOURCE_CONFIG() internal pure returns (IResourceMetering.ResourceConfig memory) {
                            IResourceMetering.ResourceConfig memory config = IResourceMetering.ResourceConfig({
                                maxResourceLimit: 20_000_000,
                                elasticityMultiplier: 10,
                                baseFeeMaxChangeDenominator: 8,
                                minimumBaseFee: 1 gwei,
                                systemTxMaxGas: 1_000_000,
                                maximumBaseFee: type(uint128).max
                            });
                            return config;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title Types
                    /// @notice Contains various types used throughout the Optimism contract system.
                    library Types {
                        /// @notice OutputProposal represents a commitment to the L2 state. The timestamp is the L1
                        ///         timestamp that the output root is posted. This timestamp is used to verify that the
                        ///         finalization period has passed since the output root was submitted.
                        /// @custom:field outputRoot    Hash of the L2 output.
                        /// @custom:field timestamp     Timestamp of the L1 block that the output root was submitted in.
                        /// @custom:field l2BlockNumber L2 block number that the output corresponds to.
                        struct OutputProposal {
                            bytes32 outputRoot;
                            uint128 timestamp;
                            uint128 l2BlockNumber;
                        }
                        /// @notice Struct representing the elements that are hashed together to generate an output root
                        ///         which itself represents a snapshot of the L2 state.
                        /// @custom:field version                  Version of the output root.
                        /// @custom:field stateRoot                Root of the state trie at the block of this output.
                        /// @custom:field messagePasserStorageRoot Root of the message passer storage trie.
                        /// @custom:field latestBlockhash          Hash of the block this output was generated from.
                        struct OutputRootProof {
                            bytes32 version;
                            bytes32 stateRoot;
                            bytes32 messagePasserStorageRoot;
                            bytes32 latestBlockhash;
                        }
                        /// @notice Struct representing a deposit transaction (L1 => L2 transaction) created by an end
                        ///         user (as opposed to a system deposit transaction generated by the system).
                        /// @custom:field from        Address of the sender of the transaction.
                        /// @custom:field to          Address of the recipient of the transaction.
                        /// @custom:field isCreation  True if the transaction is a contract creation.
                        /// @custom:field value       Value to send to the recipient.
                        /// @custom:field mint        Amount of ETH to mint.
                        /// @custom:field gasLimit    Gas limit of the transaction.
                        /// @custom:field data        Data of the transaction.
                        /// @custom:field l1BlockHash Hash of the block the transaction was submitted in.
                        /// @custom:field logIndex    Index of the log in the block the transaction was submitted in.
                        struct UserDepositTransaction {
                            address from;
                            address to;
                            bool isCreation;
                            uint256 value;
                            uint256 mint;
                            uint64 gasLimit;
                            bytes data;
                            bytes32 l1BlockHash;
                            uint256 logIndex;
                        }
                        /// @notice Struct representing a withdrawal transaction.
                        /// @custom:field nonce    Nonce of the withdrawal transaction
                        /// @custom:field sender   Address of the sender of the transaction.
                        /// @custom:field target   Address of the recipient of the transaction.
                        /// @custom:field value    Value to send to the recipient.
                        /// @custom:field gasLimit Gas limit of the transaction.
                        /// @custom:field data     Data of the transaction.
                        struct WithdrawalTransaction {
                            uint256 nonce;
                            address sender;
                            address target;
                            uint256 value;
                            uint256 gasLimit;
                            bytes data;
                        }
                        /// @notice Enum representing where the FeeVault withdraws funds to.
                        /// @custom:value L1 FeeVault withdraws funds to L1.
                        /// @custom:value L2 FeeVault withdraws funds to L2.
                        enum WithdrawalNetwork {
                            L1,
                            L2
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Libraries
                    import { Types } from "src/libraries/Types.sol";
                    import { Encoding } from "src/libraries/Encoding.sol";
                    /// @title Hashing
                    /// @notice Hashing handles Optimism's various different hashing schemes.
                    library Hashing {
                        /// @notice Computes the hash of the RLP encoded L2 transaction that would be generated when a
                        ///         given deposit is sent to the L2 system. Useful for searching for a deposit in the L2
                        ///         system.
                        /// @param _tx User deposit transaction to hash.
                        /// @return Hash of the RLP encoded L2 deposit transaction.
                        function hashDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes32) {
                            return keccak256(Encoding.encodeDepositTransaction(_tx));
                        }
                        /// @notice Computes the deposit transaction's "source hash", a value that guarantees the hash
                        ///         of the L2 transaction that corresponds to a deposit is unique and is
                        ///         deterministically generated from L1 transaction data.
                        /// @param _l1BlockHash Hash of the L1 block where the deposit was included.
                        /// @param _logIndex    The index of the log that created the deposit transaction.
                        /// @return Hash of the deposit transaction's "source hash".
                        function hashDepositSource(bytes32 _l1BlockHash, uint256 _logIndex) internal pure returns (bytes32) {
                            bytes32 depositId = keccak256(abi.encode(_l1BlockHash, _logIndex));
                            return keccak256(abi.encode(bytes32(0), depositId));
                        }
                        /// @notice Hashes the cross domain message based on the version that is encoded into the
                        ///         message nonce.
                        /// @param _nonce    Message nonce with version encoded into the first two bytes.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Hashed cross domain message.
                        function hashCrossDomainMessage(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            (, uint16 version) = Encoding.decodeVersionedNonce(_nonce);
                            if (version == 0) {
                                return hashCrossDomainMessageV0(_target, _sender, _data, _nonce);
                            } else if (version == 1) {
                                return hashCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data);
                            } else {
                                revert("Hashing: unknown cross domain message version");
                            }
                        }
                        /// @notice Hashes a cross domain message based on the V0 (legacy) encoding.
                        /// @param _target Address of the target of the message.
                        /// @param _sender Address of the sender of the message.
                        /// @param _data   Data to send with the message.
                        /// @param _nonce  Message nonce.
                        /// @return Hashed cross domain message.
                        function hashCrossDomainMessageV0(
                            address _target,
                            address _sender,
                            bytes memory _data,
                            uint256 _nonce
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            return keccak256(Encoding.encodeCrossDomainMessageV0(_target, _sender, _data, _nonce));
                        }
                        /// @notice Hashes a cross domain message based on the V1 (current) encoding.
                        /// @param _nonce    Message nonce.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Hashed cross domain message.
                        function hashCrossDomainMessageV1(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            return keccak256(Encoding.encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data));
                        }
                        /// @notice Derives the withdrawal hash according to the encoding in the L2 Withdrawer contract
                        /// @param _tx Withdrawal transaction to hash.
                        /// @return Hashed withdrawal transaction.
                        function hashWithdrawal(Types.WithdrawalTransaction memory _tx) internal pure returns (bytes32) {
                            return keccak256(abi.encode(_tx.nonce, _tx.sender, _tx.target, _tx.value, _tx.gasLimit, _tx.data));
                        }
                        /// @notice Hashes the various elements of an output root proof into an output root hash which
                        ///         can be used to check if the proof is valid.
                        /// @param _outputRootProof Output root proof which should hash to an output root.
                        /// @return Hashed output root proof.
                        function hashOutputRootProof(Types.OutputRootProof memory _outputRootProof) internal pure returns (bytes32) {
                            return keccak256(
                                abi.encode(
                                    _outputRootProof.version,
                                    _outputRootProof.stateRoot,
                                    _outputRootProof.messagePasserStorageRoot,
                                    _outputRootProof.latestBlockhash
                                )
                            );
                        }
                        /// @notice Generates a unique hash for cross l2 messages. This hash is used to identify
                        ///         the message and ensure it is not relayed more than once.
                        /// @param _destination Chain ID of the destination chain.
                        /// @param _source Chain ID of the source chain.
                        /// @param _nonce Unique nonce associated with the message to prevent replay attacks.
                        /// @param _sender Address of the user who originally sent the message.
                        /// @param _target Address of the contract or wallet that the message is targeting on the destination chain.
                        /// @param _message The message payload to be relayed to the target on the destination chain.
                        /// @return Hash of the encoded message parameters, used to uniquely identify the message.
                        function hashL2toL2CrossDomainMessage(
                            uint256 _destination,
                            uint256 _source,
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            bytes memory _message
                        )
                            internal
                            pure
                            returns (bytes32)
                        {
                            return keccak256(abi.encode(_destination, _source, _nonce, _sender, _target, _message));
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Libraries
                    import { MerkleTrie } from "src/libraries/trie/MerkleTrie.sol";
                    /// @title SecureMerkleTrie
                    /// @notice SecureMerkleTrie is a thin wrapper around the MerkleTrie library that hashes the input
                    ///         keys. Ethereum's state trie hashes input keys before storing them.
                    library SecureMerkleTrie {
                        /// @notice Verifies a proof that a given key/value pair is present in the Merkle trie.
                        /// @param _key   Key of the node to search for, as a hex string.
                        /// @param _value Value of the node to search for, as a hex string.
                        /// @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle
                        ///               trees, this proof is executed top-down and consists of a list of RLP-encoded
                        ///               nodes that make a path down to the target node.
                        /// @param _root  Known root of the Merkle trie. Used to verify that the included proof is
                        ///               correctly constructed.
                        /// @return valid_ Whether or not the proof is valid.
                        function verifyInclusionProof(
                            bytes memory _key,
                            bytes memory _value,
                            bytes[] memory _proof,
                            bytes32 _root
                        )
                            internal
                            pure
                            returns (bool valid_)
                        {
                            bytes memory key = _getSecureKey(_key);
                            valid_ = MerkleTrie.verifyInclusionProof(key, _value, _proof, _root);
                        }
                        /// @notice Retrieves the value associated with a given key.
                        /// @param _key   Key to search for, as hex bytes.
                        /// @param _proof Merkle trie inclusion proof for the key.
                        /// @param _root  Known root of the Merkle trie.
                        /// @return value_ Value of the key if it exists.
                        function get(bytes memory _key, bytes[] memory _proof, bytes32 _root) internal pure returns (bytes memory value_) {
                            bytes memory key = _getSecureKey(_key);
                            value_ = MerkleTrie.get(key, _proof, _root);
                        }
                        /// @notice Computes the hashed version of the input key.
                        /// @param _key Key to hash.
                        /// @return hash_ Hashed version of the key.
                        function _getSecureKey(bytes memory _key) private pure returns (bytes memory hash_) {
                            hash_ = abi.encodePacked(keccak256(_key));
                        }
                    }
                    // SPDX-License-Identifier: Apache-2.0
                    /*
                     * Copyright 2019-2021, Offchain Labs, Inc.
                     *
                     * Licensed under the Apache License, Version 2.0 (the "License");
                     * you may not use this file except in compliance with the License.
                     * You may obtain a copy of the License at
                     *
                     *    http://www.apache.org/licenses/LICENSE-2.0
                     *
                     * Unless required by applicable law or agreed to in writing, software
                     * distributed under the License is distributed on an "AS IS" BASIS,
                     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
                     * See the License for the specific language governing permissions and
                     * limitations under the License.
                     */
                    pragma solidity ^0.8.0;
                    library AddressAliasHelper {
                        uint160 constant offset = uint160(0x1111000000000000000000000000000000001111);
                        /// @notice Utility function that converts the address in the L1 that submitted a tx to
                        /// the inbox to the msg.sender viewed in the L2
                        /// @param l1Address the address in the L1 that triggered the tx to L2
                        /// @return l2Address L2 address as viewed in msg.sender
                        function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {
                            unchecked {
                                l2Address = address(uint160(l1Address) + offset);
                            }
                        }
                        /// @notice Utility function that converts the msg.sender viewed in the L2 to the
                        /// address in the L1 that submitted a tx to the inbox
                        /// @param l2Address L2 address as viewed in msg.sender
                        /// @return l1Address the address in the L1 that triggered the tx to L2
                        function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {
                            unchecked {
                                l1Address = address(uint160(l2Address) - offset);
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @notice Error for when a deposit or withdrawal is to a bad target.
                    error BadTarget();
                    /// @notice Error for when a deposit has too much calldata.
                    error LargeCalldata();
                    /// @notice Error for when a deposit has too small of a gas limit.
                    error SmallGasLimit();
                    /// @notice Error for when a withdrawal transfer fails.
                    error TransferFailed();
                    /// @notice Error for when a method cannot be called with non zero CALLVALUE.
                    error NoValue();
                    /// @notice Error for an unauthorized CALLER.
                    error Unauthorized();
                    /// @notice Error for when a method cannot be called when paused. This could be renamed
                    ///         to `Paused` in the future, but it collides with the `Paused` event.
                    error CallPaused();
                    /// @notice Error for special gas estimation.
                    error GasEstimation();
                    /// @notice Error for when a method is being reentered.
                    error NonReentrant();
                    /// @notice Error for invalid proof.
                    error InvalidProof();
                    /// @notice Error for invalid game type.
                    error InvalidGameType();
                    /// @notice Error for an invalid dispute game.
                    error InvalidDisputeGame();
                    /// @notice Error for an invalid merkle proof.
                    error InvalidMerkleProof();
                    /// @notice Error for when a dispute game has been blacklisted.
                    error Blacklisted();
                    /// @notice Error for when trying to withdrawal without first proven.
                    error Unproven();
                    /// @notice Error for when a proposal is not validated.
                    error ProposalNotValidated();
                    /// @notice Error for when a withdrawal has already been finalized.
                    error AlreadyFinalized();
                    /// @notice Error for when a game is a legacy game.
                    error LegacyGame();
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.15;
                    // Libraries
                    import {
                        Position,
                        Hash,
                        GameType,
                        VMStatus,
                        Timestamp,
                        Duration,
                        Clock,
                        GameId,
                        Claim,
                        LibGameId,
                        LibClock
                    } from "src/dispute/lib/LibUDT.sol";
                    /// @notice The current status of the dispute game.
                    enum GameStatus {
                        // The game is currently in progress, and has not been resolved.
                        IN_PROGRESS,
                        // The game has concluded, and the `rootClaim` was challenged successfully.
                        CHALLENGER_WINS,
                        // The game has concluded, and the `rootClaim` could not be contested.
                        DEFENDER_WINS
                    }
                    /// @notice The game's bond distribution type. Games are expected to start in the `UNDECIDED`
                    ///         state, and then choose either `NORMAL` or `REFUND`.
                    enum BondDistributionMode {
                        // Bond distribution strategy has not been chosen.
                        UNDECIDED,
                        // Bonds should be distributed as normal.
                        NORMAL,
                        // Bonds should be refunded to claimants.
                        REFUND
                    }
                    /// @notice Represents an L2 output root and the L2 block number at which it was generated.
                    /// @custom:field root The output root.
                    /// @custom:field l2BlockNumber The L2 block number at which the output root was generated.
                    struct OutputRoot {
                        Hash root;
                        uint256 l2BlockNumber;
                    }
                    /// @title GameTypes
                    /// @notice A library that defines the IDs of games that can be played.
                    library GameTypes {
                        /// @dev A dispute game type the uses the cannon vm.
                        GameType internal constant CANNON = GameType.wrap(0);
                        /// @dev A permissioned dispute game type that uses the cannon vm.
                        GameType internal constant PERMISSIONED_CANNON = GameType.wrap(1);
                        /// @notice A dispute game type that uses the asterisc vm.
                        GameType internal constant ASTERISC = GameType.wrap(2);
                        /// @notice A dispute game type that uses the asterisc vm with Kona.
                        GameType internal constant ASTERISC_KONA = GameType.wrap(3);
                        /// @notice A dispute game type that uses OP Succinct
                        GameType internal constant OP_SUCCINCT = GameType.wrap(6);
                        /// @notice A dispute game type with short game duration for testing withdrawals.
                        ///         Not intended for production use.
                        GameType internal constant FAST = GameType.wrap(254);
                        /// @notice A dispute game type that uses an alphabet vm.
                        ///         Not intended for production use.
                        GameType internal constant ALPHABET = GameType.wrap(255);
                        /// @notice A dispute game type that uses RISC Zero's Kailua
                        GameType internal constant KAILUA = GameType.wrap(1337);
                    }
                    /// @title VMStatuses
                    /// @notice Named type aliases for the various valid VM status bytes.
                    library VMStatuses {
                        /// @notice The VM has executed successfully and the outcome is valid.
                        VMStatus internal constant VALID = VMStatus.wrap(0);
                        /// @notice The VM has executed successfully and the outcome is invalid.
                        VMStatus internal constant INVALID = VMStatus.wrap(1);
                        /// @notice The VM has paniced.
                        VMStatus internal constant PANIC = VMStatus.wrap(2);
                        /// @notice The VM execution is still in progress.
                        VMStatus internal constant UNFINISHED = VMStatus.wrap(3);
                    }
                    /// @title LocalPreimageKey
                    /// @notice Named type aliases for local `PreimageOracle` key identifiers.
                    library LocalPreimageKey {
                        /// @notice The identifier for the L1 head hash.
                        uint256 internal constant L1_HEAD_HASH = 0x01;
                        /// @notice The identifier for the starting output root.
                        uint256 internal constant STARTING_OUTPUT_ROOT = 0x02;
                        /// @notice The identifier for the disputed output root.
                        uint256 internal constant DISPUTED_OUTPUT_ROOT = 0x03;
                        /// @notice The identifier for the disputed L2 block number.
                        uint256 internal constant DISPUTED_L2_BLOCK_NUMBER = 0x04;
                        /// @notice The identifier for the chain ID.
                        uint256 internal constant CHAIN_ID = 0x05;
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev Interface of the ERC20 standard as defined in the EIP.
                     */
                    interface IERC20 {
                        /**
                         * @dev Emitted when `value` tokens are moved from one account (`from`) to
                         * another (`to`).
                         *
                         * Note that `value` may be zero.
                         */
                        event Transfer(address indexed from, address indexed to, uint256 value);
                        /**
                         * @dev Emitted when the allowance of a `spender` for an `owner` is set by
                         * a call to {approve}. `value` is the new allowance.
                         */
                        event Approval(address indexed owner, address indexed spender, uint256 value);
                        /**
                         * @dev Returns the amount of tokens in existence.
                         */
                        function totalSupply() external view returns (uint256);
                        /**
                         * @dev Returns the amount of tokens owned by `account`.
                         */
                        function balanceOf(address account) external view returns (uint256);
                        /**
                         * @dev Moves `amount` tokens from the caller's account to `to`.
                         *
                         * Returns a boolean value indicating whether the operation succeeded.
                         *
                         * Emits a {Transfer} event.
                         */
                        function transfer(address to, uint256 amount) external returns (bool);
                        /**
                         * @dev 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.
                         */
                        function allowance(address owner, address spender) external view returns (uint256);
                        /**
                         * @dev 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.
                         */
                        function approve(address spender, uint256 amount) external returns (bool);
                        /**
                         * @dev 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.
                         */
                        function transferFrom(
                            address from,
                            address to,
                            uint256 amount
                        ) external returns (bool);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title ISemver
                    /// @notice ISemver is a simple contract for ensuring that contracts are
                    ///         versioned using semantic versioning.
                    interface ISemver {
                        /// @notice Getter for the semantic version of the contract. This is not
                        ///         meant to be used onchain but instead meant to be used by offchain
                        ///         tooling.
                        /// @return Semver contract version as a string.
                        function version() external view returns (string memory);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IResourceMetering } from "interfaces/L1/IResourceMetering.sol";
                    interface ISystemConfig {
                        enum UpdateType {
                            BATCHER,
                            FEE_SCALARS,
                            GAS_LIMIT,
                            UNSAFE_BLOCK_SIGNER,
                            EIP_1559_PARAMS,
                            OPERATOR_FEE_PARAMS
                        }
                        struct Addresses {
                            address l1CrossDomainMessenger;
                            address l1ERC721Bridge;
                            address l1StandardBridge;
                            address disputeGameFactory;
                            address optimismPortal;
                            address optimismMintableERC20Factory;
                        }
                        event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);
                        event Initialized(uint8 version);
                        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                        function BATCH_INBOX_SLOT() external view returns (bytes32);
                        function DISPUTE_GAME_FACTORY_SLOT() external view returns (bytes32);
                        function L1_CROSS_DOMAIN_MESSENGER_SLOT() external view returns (bytes32);
                        function L1_ERC_721_BRIDGE_SLOT() external view returns (bytes32);
                        function L1_STANDARD_BRIDGE_SLOT() external view returns (bytes32);
                        function OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT() external view returns (bytes32);
                        function OPTIMISM_PORTAL_SLOT() external view returns (bytes32);
                        function START_BLOCK_SLOT() external view returns (bytes32);
                        function UNSAFE_BLOCK_SIGNER_SLOT() external view returns (bytes32);
                        function VERSION() external view returns (uint256);
                        function basefeeScalar() external view returns (uint32);
                        function batchInbox() external view returns (address addr_);
                        function batcherHash() external view returns (bytes32);
                        function blobbasefeeScalar() external view returns (uint32);
                        function disputeGameFactory() external view returns (address addr_);
                        function gasLimit() external view returns (uint64);
                        function eip1559Denominator() external view returns (uint32);
                        function eip1559Elasticity() external view returns (uint32);
                        function getAddresses() external view returns (Addresses memory);
                        function initialize(
                            address _owner,
                            uint32 _basefeeScalar,
                            uint32 _blobbasefeeScalar,
                            bytes32 _batcherHash,
                            uint64 _gasLimit,
                            address _unsafeBlockSigner,
                            IResourceMetering.ResourceConfig memory _config,
                            address _batchInbox,
                            Addresses memory _addresses
                        )
                            external;
                        function l1CrossDomainMessenger() external view returns (address addr_);
                        function l1ERC721Bridge() external view returns (address addr_);
                        function l1StandardBridge() external view returns (address addr_);
                        function maximumGasLimit() external pure returns (uint64);
                        function minimumGasLimit() external view returns (uint64);
                        function operatorFeeConstant() external view returns (uint64);
                        function operatorFeeScalar() external view returns (uint32);
                        function optimismMintableERC20Factory() external view returns (address addr_);
                        function optimismPortal() external view returns (address addr_);
                        function overhead() external view returns (uint256);
                        function owner() external view returns (address);
                        function renounceOwnership() external;
                        function resourceConfig() external view returns (IResourceMetering.ResourceConfig memory);
                        function scalar() external view returns (uint256);
                        function setBatcherHash(bytes32 _batcherHash) external;
                        function setGasConfig(uint256 _overhead, uint256 _scalar) external;
                        function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external;
                        function setGasLimit(uint64 _gasLimit) external;
                        function setOperatorFeeScalars(uint32 _operatorFeeScalar, uint64 _operatorFeeConstant) external;
                        function setUnsafeBlockSigner(address _unsafeBlockSigner) external;
                        function setEIP1559Params(uint32 _denominator, uint32 _elasticity) external;
                        function startBlock() external view returns (uint256 startBlock_);
                        function transferOwnership(address newOwner) external; // nosemgrep
                        function unsafeBlockSigner() external view returns (address addr_);
                        function version() external pure returns (string memory);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface IResourceMetering {
                        struct ResourceParams {
                            uint128 prevBaseFee;
                            uint64 prevBoughtGas;
                            uint64 prevBlockNum;
                        }
                        struct ResourceConfig {
                            uint32 maxResourceLimit;
                            uint8 elasticityMultiplier;
                            uint8 baseFeeMaxChangeDenominator;
                            uint32 minimumBaseFee;
                            uint32 systemTxMaxGas;
                            uint128 maximumBaseFee;
                        }
                        error OutOfGas();
                        event Initialized(uint8 version);
                        function params() external view returns (uint128 prevBaseFee, uint64 prevBoughtGas, uint64 prevBlockNum); // nosemgrep
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface ISuperchainConfig {
                        enum UpdateType {
                            GUARDIAN
                        }
                        event ConfigUpdate(UpdateType indexed updateType, bytes data);
                        event Initialized(uint8 version);
                        event Paused(string identifier);
                        event Unpaused();
                        function GUARDIAN_SLOT() external view returns (bytes32);
                        function PAUSED_SLOT() external view returns (bytes32);
                        function guardian() external view returns (address guardian_);
                        function initialize(address _guardian, bool _paused) external;
                        function pause(string memory _identifier) external;
                        function paused() external view returns (bool paused_);
                        function unpause() external;
                        function version() external view returns (string memory);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IDisputeGame } from "interfaces/dispute/IDisputeGame.sol";
                    import { GameId, Timestamp, Claim, Hash, GameType } from "src/dispute/lib/Types.sol";
                    interface IDisputeGameFactory {
                        struct GameSearchResult {
                            uint256 index;
                            GameId metadata;
                            Timestamp timestamp;
                            Claim rootClaim;
                            bytes extraData;
                        }
                        error GameAlreadyExists(Hash uuid);
                        error IncorrectBondAmount();
                        error NoImplementation(GameType gameType);
                        event DisputeGameCreated(address indexed disputeProxy, GameType indexed gameType, Claim indexed rootClaim);
                        event ImplementationSet(address indexed impl, GameType indexed gameType);
                        event InitBondUpdated(GameType indexed gameType, uint256 indexed newBond);
                        event Initialized(uint8 version);
                        event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
                        function create(
                            GameType _gameType,
                            Claim _rootClaim,
                            bytes memory _extraData
                        )
                            external
                            payable
                            returns (IDisputeGame proxy_);
                        function findLatestGames(
                            GameType _gameType,
                            uint256 _start,
                            uint256 _n
                        )
                            external
                            view
                            returns (GameSearchResult[] memory games_);
                        function gameAtIndex(uint256 _index)
                            external
                            view
                            returns (GameType gameType_, Timestamp timestamp_, IDisputeGame proxy_);
                        function gameCount() external view returns (uint256 gameCount_);
                        function gameImpls(GameType) external view returns (IDisputeGame);
                        function games(
                            GameType _gameType,
                            Claim _rootClaim,
                            bytes memory _extraData
                        )
                            external
                            view
                            returns (IDisputeGame proxy_, Timestamp timestamp_);
                        function getGameUUID(
                            GameType _gameType,
                            Claim _rootClaim,
                            bytes memory _extraData
                        )
                            external
                            pure
                            returns (Hash uuid_);
                        function initBonds(GameType) external view returns (uint256);
                        function initialize(address _owner) external;
                        function owner() external view returns (address);
                        function renounceOwnership() external;
                        function setImplementation(GameType _gameType, IDisputeGame _impl) external;
                        function setInitBond(GameType _gameType, uint256 _initBond) external;
                        function transferOwnership(address newOwner) external; // nosemgrep
                        function version() external view returns (string memory);
                        function __constructor__() external;
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    import { IInitializable } from "interfaces/dispute/IInitializable.sol";
                    import { Timestamp, GameStatus, GameType, Claim, Hash } from "src/dispute/lib/Types.sol";
                    interface IDisputeGame is IInitializable {
                        event Resolved(GameStatus indexed status);
                        function createdAt() external view returns (Timestamp);
                        function resolvedAt() external view returns (Timestamp);
                        function status() external view returns (GameStatus);
                        function gameType() external view returns (GameType gameType_);
                        function gameCreator() external pure returns (address creator_);
                        function rootClaim() external pure returns (Claim rootClaim_);
                        function l1Head() external pure returns (Hash l1Head_);
                        function l2BlockNumber() external pure returns (uint256 l2BlockNumber_);
                        function extraData() external pure returns (bytes memory extraData_);
                        function resolve() external returns (GameStatus status_);
                        function gameData() external view returns (GameType gameType_, Claim rootClaim_, bytes memory extraData_);
                        function wasRespectedGameTypeWhenCreated() external view returns (bool);
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
                    pragma solidity ^0.8.1;
                    /**
                     * @dev Collection of functions related to the address type
                     */
                    library Address {
                        /**
                         * @dev Returns true if `account` is a contract.
                         *
                         * [IMPORTANT]
                         * ====
                         * It is unsafe to assume that an address for which this function returns
                         * false is an externally-owned account (EOA) and not a contract.
                         *
                         * Among others, `isContract` will return false for the following
                         * types of addresses:
                         *
                         *  - an externally-owned account
                         *  - a contract in construction
                         *  - an address where a contract will be created
                         *  - an address where a contract lived, but was destroyed
                         * ====
                         *
                         * [IMPORTANT]
                         * ====
                         * You shouldn't rely on `isContract` to protect against flash loan attacks!
                         *
                         * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
                         * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
                         * constructor.
                         * ====
                         */
                        function isContract(address account) internal view returns (bool) {
                            // This method relies on extcodesize/address.code.length, which returns 0
                            // for contracts in construction, since the code is only stored at the end
                            // of the constructor execution.
                            return account.code.length > 0;
                        }
                        /**
                         * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
                         * `recipient`, forwarding all available gas and reverting on errors.
                         *
                         * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
                         * of certain opcodes, possibly making contracts go over the 2300 gas limit
                         * imposed by `transfer`, making them unable to receive funds via
                         * `transfer`. {sendValue} removes this limitation.
                         *
                         * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
                         *
                         * IMPORTANT: because control is transferred to `recipient`, care must be
                         * taken to not create reentrancy vulnerabilities. Consider using
                         * {ReentrancyGuard} or the
                         * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
                         */
                        function sendValue(address payable recipient, uint256 amount) internal {
                            require(address(this).balance >= amount, "Address: insufficient balance");
                            (bool success, ) = recipient.call{value: amount}("");
                            require(success, "Address: unable to send value, recipient may have reverted");
                        }
                        /**
                         * @dev Performs a Solidity function call using a low level `call`. A
                         * plain `call` is an unsafe replacement for a function call: use this
                         * function instead.
                         *
                         * If `target` reverts with a revert reason, it is bubbled up by this
                         * function (like regular Solidity function calls).
                         *
                         * Returns the raw returned data. To convert to the expected return value,
                         * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
                         *
                         * Requirements:
                         *
                         * - `target` must be a contract.
                         * - calling `target` with `data` must not revert.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(address target, bytes memory data) internal returns (bytes memory) {
                            return functionCall(target, data, "Address: low-level call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
                         * `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, 0, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but also transferring `value` wei to `target`.
                         *
                         * Requirements:
                         *
                         * - the calling contract must have an ETH balance of at least `value`.
                         * - the called Solidity function must be `payable`.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value
                        ) internal returns (bytes memory) {
                            return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
                         * with `errorMessage` as a fallback revert reason when `target` reverts.
                         *
                         * _Available since v3.1._
                         */
                        function functionCallWithValue(
                            address target,
                            bytes memory data,
                            uint256 value,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            require(address(this).balance >= value, "Address: insufficient balance for call");
                            require(isContract(target), "Address: call to non-contract");
                            (bool success, bytes memory returndata) = target.call{value: value}(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
                            return functionStaticCall(target, data, "Address: low-level static call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
                         * but performing a static call.
                         *
                         * _Available since v3.3._
                         */
                        function functionStaticCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal view returns (bytes memory) {
                            require(isContract(target), "Address: static call to non-contract");
                            (bool success, bytes memory returndata) = target.staticcall(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
                         * but performing a delegate call.
                         *
                         * _Available since v3.4._
                         */
                        function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
                            return functionDelegateCall(target, data, "Address: low-level delegate call failed");
                        }
                        /**
                         * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
                         * but performing a delegate call.
                         *
                         * _Available since v3.4._
                         */
                        function functionDelegateCall(
                            address target,
                            bytes memory data,
                            string memory errorMessage
                        ) internal returns (bytes memory) {
                            require(isContract(target), "Address: delegate call to non-contract");
                            (bool success, bytes memory returndata) = target.delegatecall(data);
                            return verifyCallResult(success, returndata, errorMessage);
                        }
                        /**
                         * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
                         * revert reason using the provided one.
                         *
                         * _Available since v4.3._
                         */
                        function verifyCallResult(
                            bool success,
                            bytes memory returndata,
                            string memory errorMessage
                        ) internal pure returns (bytes memory) {
                            if (success) {
                                return returndata;
                            } else {
                                // Look for revert reason and bubble it up if present
                                if (returndata.length > 0) {
                                    // The easiest way to bubble the revert reason is using memory via assembly
                                    /// @solidity memory-safe-assembly
                                    assembly {
                                        let returndata_size := mload(returndata)
                                        revert(add(32, returndata), returndata_size)
                                    }
                                } else {
                                    revert(errorMessage);
                                }
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev Standard math utilities missing in the Solidity language.
                     */
                    library Math {
                        enum Rounding {
                            Down, // Toward negative infinity
                            Up, // Toward infinity
                            Zero // Toward zero
                        }
                        /**
                         * @dev Returns the largest of two numbers.
                         */
                        function max(uint256 a, uint256 b) internal pure returns (uint256) {
                            return a >= b ? a : b;
                        }
                        /**
                         * @dev Returns the smallest of two numbers.
                         */
                        function min(uint256 a, uint256 b) internal pure returns (uint256) {
                            return a < b ? a : b;
                        }
                        /**
                         * @dev Returns the average of two numbers. The result is rounded towards
                         * zero.
                         */
                        function average(uint256 a, uint256 b) internal pure returns (uint256) {
                            // (a + b) / 2 can overflow.
                            return (a & b) + (a ^ b) / 2;
                        }
                        /**
                         * @dev Returns the ceiling of the division of two numbers.
                         *
                         * This differs from standard division with `/` in that it rounds up instead
                         * of rounding down.
                         */
                        function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
                            // (a + b - 1) / b can overflow on addition, so we distribute.
                            return a == 0 ? 0 : (a - 1) / b + 1;
                        }
                        /**
                         * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
                         * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
                         * with further edits by Uniswap Labs also under MIT license.
                         */
                        function mulDiv(
                            uint256 x,
                            uint256 y,
                            uint256 denominator
                        ) internal pure returns (uint256 result) {
                            unchecked {
                                // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
                                // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
                                // variables such that product = prod1 * 2^256 + prod0.
                                uint256 prod0; // Least significant 256 bits of the product
                                uint256 prod1; // Most significant 256 bits of the product
                                assembly {
                                    let mm := mulmod(x, y, not(0))
                                    prod0 := mul(x, y)
                                    prod1 := sub(sub(mm, prod0), lt(mm, prod0))
                                }
                                // Handle non-overflow cases, 256 by 256 division.
                                if (prod1 == 0) {
                                    return prod0 / denominator;
                                }
                                // Make sure the result is less than 2^256. Also prevents denominator == 0.
                                require(denominator > prod1);
                                ///////////////////////////////////////////////
                                // 512 by 256 division.
                                ///////////////////////////////////////////////
                                // Make division exact by subtracting the remainder from [prod1 prod0].
                                uint256 remainder;
                                assembly {
                                    // Compute remainder using mulmod.
                                    remainder := mulmod(x, y, denominator)
                                    // Subtract 256 bit number from 512 bit number.
                                    prod1 := sub(prod1, gt(remainder, prod0))
                                    prod0 := sub(prod0, remainder)
                                }
                                // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
                                // See https://cs.stackexchange.com/q/138556/92363.
                                // Does not overflow because the denominator cannot be zero at this stage in the function.
                                uint256 twos = denominator & (~denominator + 1);
                                assembly {
                                    // Divide denominator by twos.
                                    denominator := div(denominator, twos)
                                    // Divide [prod1 prod0] by twos.
                                    prod0 := div(prod0, twos)
                                    // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                                    twos := add(div(sub(0, twos), twos), 1)
                                }
                                // Shift in bits from prod1 into prod0.
                                prod0 |= prod1 * twos;
                                // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
                                // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
                                // four bits. That is, denominator * inv = 1 mod 2^4.
                                uint256 inverse = (3 * denominator) ^ 2;
                                // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
                                // in modular arithmetic, doubling the correct bits in each step.
                                inverse *= 2 - denominator * inverse; // inverse mod 2^8
                                inverse *= 2 - denominator * inverse; // inverse mod 2^16
                                inverse *= 2 - denominator * inverse; // inverse mod 2^32
                                inverse *= 2 - denominator * inverse; // inverse mod 2^64
                                inverse *= 2 - denominator * inverse; // inverse mod 2^128
                                inverse *= 2 - denominator * inverse; // inverse mod 2^256
                                // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
                                // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
                                // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
                                // is no longer required.
                                result = prod0 * inverse;
                                return result;
                            }
                        }
                        /**
                         * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
                         */
                        function mulDiv(
                            uint256 x,
                            uint256 y,
                            uint256 denominator,
                            Rounding rounding
                        ) internal pure returns (uint256) {
                            uint256 result = mulDiv(x, y, denominator);
                            if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
                                result += 1;
                            }
                            return result;
                        }
                        /**
                         * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.
                         *
                         * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
                         */
                        function sqrt(uint256 a) internal pure returns (uint256) {
                            if (a == 0) {
                                return 0;
                            }
                            // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
                            // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
                            // `msb(a) <= a < 2*msb(a)`.
                            // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.
                            // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.
                            // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a
                            // good first aproximation of `sqrt(a)` with at least 1 correct bit.
                            uint256 result = 1;
                            uint256 x = a;
                            if (x >> 128 > 0) {
                                x >>= 128;
                                result <<= 64;
                            }
                            if (x >> 64 > 0) {
                                x >>= 64;
                                result <<= 32;
                            }
                            if (x >> 32 > 0) {
                                x >>= 32;
                                result <<= 16;
                            }
                            if (x >> 16 > 0) {
                                x >>= 16;
                                result <<= 8;
                            }
                            if (x >> 8 > 0) {
                                x >>= 8;
                                result <<= 4;
                            }
                            if (x >> 4 > 0) {
                                x >>= 4;
                                result <<= 2;
                            }
                            if (x >> 2 > 0) {
                                result <<= 1;
                            }
                            // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
                            // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
                            // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
                            // into the expected uint128 result.
                            unchecked {
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                result = (result + a / result) >> 1;
                                return min(result, a / result);
                            }
                        }
                        /**
                         * @notice Calculates sqrt(a), following the selected rounding direction.
                         */
                        function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
                            uint256 result = sqrt(a);
                            if (rounding == Rounding.Up && result * result < a) {
                                result += 1;
                            }
                            return result;
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    /// @title Burn
                    /// @notice Utilities for burning stuff.
                    library Burn {
                        /// @notice Burns a given amount of ETH.
                        /// @param _amount Amount of ETH to burn.
                        function eth(uint256 _amount) internal {
                            new Burner{ value: _amount }();
                        }
                        /// @notice Burns a given amount of gas.
                        /// @param _amount Amount of gas to burn.
                        function gas(uint256 _amount) internal view {
                            uint256 i = 0;
                            uint256 initialGas = gasleft();
                            while (initialGas - gasleft() < _amount) {
                                ++i;
                            }
                        }
                    }
                    /// @title Burner
                    /// @notice Burner self-destructs on creation and sends all ETH to itself, removing all ETH given to
                    ///         the contract from the circulating supply. Self-destructing is the only way to remove ETH
                    ///         from the circulating supply.
                    contract Burner {
                        constructor() payable {
                            selfdestruct(payable(address(this)));
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Libraries
                    import { SignedMath } from "@openzeppelin/contracts/utils/math/SignedMath.sol";
                    import { FixedPointMathLib } from "@rari-capital/solmate/src/utils/FixedPointMathLib.sol";
                    /// @title Arithmetic
                    /// @notice Even more math than before.
                    library Arithmetic {
                        /// @notice Clamps a value between a minimum and maximum.
                        /// @param _value The value to clamp.
                        /// @param _min   The minimum value.
                        /// @param _max   The maximum value.
                        /// @return The clamped value.
                        function clamp(int256 _value, int256 _min, int256 _max) internal pure returns (int256) {
                            return SignedMath.min(SignedMath.max(_value, _min), _max);
                        }
                        /// @notice (c)oefficient (d)enominator (exp)onentiation function.
                        ///         Returns the result of: c * (1 - 1/d)^exp.
                        /// @param _coefficient Coefficient of the function.
                        /// @param _denominator Fractional denominator.
                        /// @param _exponent    Power function exponent.
                        /// @return Result of c * (1 - 1/d)^exp.
                        function cdexp(int256 _coefficient, int256 _denominator, int256 _exponent) internal pure returns (int256) {
                            return (_coefficient * (FixedPointMathLib.powWad(1e18 - (1e18 / _denominator), _exponent * 1e18))) / 1e18;
                        }
                        /// @notice Saturating addition.
                        /// @param _x The first value.
                        /// @param _y The second value.
                        /// @return z_ The sum of the two values, or the maximum value if the sum overflows.
                        /// @dev Returns `min(2 ** 256 - 1, x + y)`.
                        /// @dev Taken from Solady
                        /// https://github.com/Vectorized/solady/blob/63416d60c78aba70a12ca1b3c11125d1061caa12/src/utils/FixedPointMathLib.sol#L673
                        function saturatingAdd(uint256 _x, uint256 _y) internal pure returns (uint256 z_) {
                            assembly ("memory-safe") {
                                z_ := or(sub(0, lt(add(_x, _y), _x)), add(_x, _y))
                            }
                        }
                        /// @notice Saturating multiplication.
                        /// @param _x The first value.
                        /// @param _y The second value.
                        /// @return z_ The product of the two values, or the maximum value if the product overflows.
                        /// @dev Returns `min(2 ** 256 - 1, x * y).
                        /// @dev Taken from Solady
                        /// https://github.com/Vectorized/solady/blob/63416d60c78aba70a12ca1b3c11125d1061caa12/src/utils/FixedPointMathLib.sol#L681
                        function saturatingMul(uint256 _x, uint256 _y) internal pure returns (uint256 z_) {
                            assembly ("memory-safe") {
                                z_ := or(sub(or(iszero(_x), eq(div(mul(_x, _y), _x), _y)), 1), mul(_x, _y))
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev 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.
                     */
                    interface IERC20Permit {
                        /**
                         * @dev 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].
                         */
                        function permit(
                            address owner,
                            address spender,
                            uint256 value,
                            uint256 deadline,
                            uint8 v,
                            bytes32 r,
                            bytes32 s
                        ) external;
                        /**
                         * @dev 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.
                         */
                        function nonces(address owner) external view returns (uint256);
                        /**
                         * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
                         */
                        // solhint-disable-next-line func-name-mixedcase
                        function DOMAIN_SEPARATOR() external view returns (bytes32);
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Libraries
                    import { Types } from "src/libraries/Types.sol";
                    import { Hashing } from "src/libraries/Hashing.sol";
                    import { RLPWriter } from "src/libraries/rlp/RLPWriter.sol";
                    /// @title Encoding
                    /// @notice Encoding handles Optimism's various different encoding schemes.
                    library Encoding {
                        /// @notice RLP encodes the L2 transaction that would be generated when a given deposit is sent
                        ///         to the L2 system. Useful for searching for a deposit in the L2 system. The
                        ///         transaction is prefixed with 0x7e to identify its EIP-2718 type.
                        /// @param _tx User deposit transaction to encode.
                        /// @return RLP encoded L2 deposit transaction.
                        function encodeDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes memory) {
                            bytes32 source = Hashing.hashDepositSource(_tx.l1BlockHash, _tx.logIndex);
                            bytes[] memory raw = new bytes[](8);
                            raw[0] = RLPWriter.writeBytes(abi.encodePacked(source));
                            raw[1] = RLPWriter.writeAddress(_tx.from);
                            raw[2] = _tx.isCreation ? RLPWriter.writeBytes("") : RLPWriter.writeAddress(_tx.to);
                            raw[3] = RLPWriter.writeUint(_tx.mint);
                            raw[4] = RLPWriter.writeUint(_tx.value);
                            raw[5] = RLPWriter.writeUint(uint256(_tx.gasLimit));
                            raw[6] = RLPWriter.writeBool(false);
                            raw[7] = RLPWriter.writeBytes(_tx.data);
                            return abi.encodePacked(uint8(0x7e), RLPWriter.writeList(raw));
                        }
                        /// @notice Encodes the cross domain message based on the version that is encoded into the
                        ///         message nonce.
                        /// @param _nonce    Message nonce with version encoded into the first two bytes.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Encoded cross domain message.
                        function encodeCrossDomainMessage(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            (, uint16 version) = decodeVersionedNonce(_nonce);
                            if (version == 0) {
                                return encodeCrossDomainMessageV0(_target, _sender, _data, _nonce);
                            } else if (version == 1) {
                                return encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data);
                            } else {
                                revert("Encoding: unknown cross domain message version");
                            }
                        }
                        /// @notice Encodes a cross domain message based on the V0 (legacy) encoding.
                        /// @param _target Address of the target of the message.
                        /// @param _sender Address of the sender of the message.
                        /// @param _data   Data to send with the message.
                        /// @param _nonce  Message nonce.
                        /// @return Encoded cross domain message.
                        function encodeCrossDomainMessageV0(
                            address _target,
                            address _sender,
                            bytes memory _data,
                            uint256 _nonce
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            // nosemgrep: sol-style-use-abi-encodecall
                            return abi.encodeWithSignature("relayMessage(address,address,bytes,uint256)", _target, _sender, _data, _nonce);
                        }
                        /// @notice Encodes a cross domain message based on the V1 (current) encoding.
                        /// @param _nonce    Message nonce.
                        /// @param _sender   Address of the sender of the message.
                        /// @param _target   Address of the target of the message.
                        /// @param _value    ETH value to send to the target.
                        /// @param _gasLimit Gas limit to use for the message.
                        /// @param _data     Data to send with the message.
                        /// @return Encoded cross domain message.
                        function encodeCrossDomainMessageV1(
                            uint256 _nonce,
                            address _sender,
                            address _target,
                            uint256 _value,
                            uint256 _gasLimit,
                            bytes memory _data
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            // nosemgrep: sol-style-use-abi-encodecall
                            return abi.encodeWithSignature(
                                "relayMessage(uint256,address,address,uint256,uint256,bytes)",
                                _nonce,
                                _sender,
                                _target,
                                _value,
                                _gasLimit,
                                _data
                            );
                        }
                        /// @notice Adds a version number into the first two bytes of a message nonce.
                        /// @param _nonce   Message nonce to encode into.
                        /// @param _version Version number to encode into the message nonce.
                        /// @return Message nonce with version encoded into the first two bytes.
                        function encodeVersionedNonce(uint240 _nonce, uint16 _version) internal pure returns (uint256) {
                            uint256 nonce;
                            assembly {
                                nonce := or(shl(240, _version), _nonce)
                            }
                            return nonce;
                        }
                        /// @notice Pulls the version out of a version-encoded nonce.
                        /// @param _nonce Message nonce with version encoded into the first two bytes.
                        /// @return Nonce without encoded version.
                        /// @return Version of the message.
                        function decodeVersionedNonce(uint256 _nonce) internal pure returns (uint240, uint16) {
                            uint240 nonce;
                            uint16 version;
                            assembly {
                                nonce := and(_nonce, 0x0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
                                version := shr(240, _nonce)
                            }
                            return (nonce, version);
                        }
                        /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesEcotone
                        /// @param _baseFeeScalar       L1 base fee Scalar
                        /// @param _blobBaseFeeScalar   L1 blob base fee Scalar
                        /// @param _sequenceNumber      Number of L2 blocks since epoch start.
                        /// @param _timestamp           L1 timestamp.
                        /// @param _number              L1 blocknumber.
                        /// @param _baseFee             L1 base fee.
                        /// @param _blobBaseFee         L1 blob base fee.
                        /// @param _hash                L1 blockhash.
                        /// @param _batcherHash         Versioned hash to authenticate batcher by.
                        function encodeSetL1BlockValuesEcotone(
                            uint32 _baseFeeScalar,
                            uint32 _blobBaseFeeScalar,
                            uint64 _sequenceNumber,
                            uint64 _timestamp,
                            uint64 _number,
                            uint256 _baseFee,
                            uint256 _blobBaseFee,
                            bytes32 _hash,
                            bytes32 _batcherHash
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesEcotone()"));
                            return abi.encodePacked(
                                functionSignature,
                                _baseFeeScalar,
                                _blobBaseFeeScalar,
                                _sequenceNumber,
                                _timestamp,
                                _number,
                                _baseFee,
                                _blobBaseFee,
                                _hash,
                                _batcherHash
                            );
                        }
                        /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesIsthmus
                        /// @param _baseFeeScalar       L1 base fee Scalar
                        /// @param _blobBaseFeeScalar   L1 blob base fee Scalar
                        /// @param _sequenceNumber      Number of L2 blocks since epoch start.
                        /// @param _timestamp           L1 timestamp.
                        /// @param _number              L1 blocknumber.
                        /// @param _baseFee             L1 base fee.
                        /// @param _blobBaseFee         L1 blob base fee.
                        /// @param _hash                L1 blockhash.
                        /// @param _batcherHash         Versioned hash to authenticate batcher by.
                        /// @param _operatorFeeScalar   Operator fee scalar.
                        /// @param _operatorFeeConstant Operator fee constant.
                        function encodeSetL1BlockValuesIsthmus(
                            uint32 _baseFeeScalar,
                            uint32 _blobBaseFeeScalar,
                            uint64 _sequenceNumber,
                            uint64 _timestamp,
                            uint64 _number,
                            uint256 _baseFee,
                            uint256 _blobBaseFee,
                            bytes32 _hash,
                            bytes32 _batcherHash,
                            uint32 _operatorFeeScalar,
                            uint64 _operatorFeeConstant
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesIsthmus()"));
                            return abi.encodePacked(
                                functionSignature,
                                _baseFeeScalar,
                                _blobBaseFeeScalar,
                                _sequenceNumber,
                                _timestamp,
                                _number,
                                _baseFee,
                                _blobBaseFee,
                                _hash,
                                _batcherHash,
                                _operatorFeeScalar,
                                _operatorFeeConstant
                            );
                        }
                        /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesInterop
                        /// @param _baseFeeScalar       L1 base fee Scalar
                        /// @param _blobBaseFeeScalar   L1 blob base fee Scalar
                        /// @param _sequenceNumber      Number of L2 blocks since epoch start.
                        /// @param _timestamp           L1 timestamp.
                        /// @param _number              L1 blocknumber.
                        /// @param _baseFee             L1 base fee.
                        /// @param _blobBaseFee         L1 blob base fee.
                        /// @param _hash                L1 blockhash.
                        /// @param _batcherHash         Versioned hash to authenticate batcher by.
                        function encodeSetL1BlockValuesInterop(
                            uint32 _baseFeeScalar,
                            uint32 _blobBaseFeeScalar,
                            uint64 _sequenceNumber,
                            uint64 _timestamp,
                            uint64 _number,
                            uint256 _baseFee,
                            uint256 _blobBaseFee,
                            bytes32 _hash,
                            bytes32 _batcherHash
                        )
                            internal
                            pure
                            returns (bytes memory)
                        {
                            bytes4 functionSignature = bytes4(keccak256("setL1BlockValuesInterop()"));
                            return abi.encodePacked(
                                functionSignature,
                                _baseFeeScalar,
                                _blobBaseFeeScalar,
                                _sequenceNumber,
                                _timestamp,
                                _number,
                                _baseFee,
                                _blobBaseFee,
                                _hash,
                                _batcherHash
                            );
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    // Libraries
                    import { Bytes } from "src/libraries/Bytes.sol";
                    import { RLPReader } from "src/libraries/rlp/RLPReader.sol";
                    /// @title MerkleTrie
                    /// @notice MerkleTrie is a small library for verifying standard Ethereum Merkle-Patricia trie
                    ///         inclusion proofs. By default, this library assumes a hexary trie. One can change the
                    ///         trie radix constant to support other trie radixes.
                    library MerkleTrie {
                        /// @notice Struct representing a node in the trie.
                        /// @custom:field encoded The RLP-encoded node.
                        /// @custom:field decoded The RLP-decoded node.
                        struct TrieNode {
                            bytes encoded;
                            RLPReader.RLPItem[] decoded;
                        }
                        /// @notice Determines the number of elements per branch node.
                        uint256 internal constant TREE_RADIX = 16;
                        /// @notice Branch nodes have TREE_RADIX elements and one value element.
                        uint256 internal constant BRANCH_NODE_LENGTH = TREE_RADIX + 1;
                        /// @notice Leaf nodes and extension nodes have two elements, a `path` and a `value`.
                        uint256 internal constant LEAF_OR_EXTENSION_NODE_LENGTH = 2;
                        /// @notice Prefix for even-nibbled extension node paths.
                        uint8 internal constant PREFIX_EXTENSION_EVEN = 0;
                        /// @notice Prefix for odd-nibbled extension node paths.
                        uint8 internal constant PREFIX_EXTENSION_ODD = 1;
                        /// @notice Prefix for even-nibbled leaf node paths.
                        uint8 internal constant PREFIX_LEAF_EVEN = 2;
                        /// @notice Prefix for odd-nibbled leaf node paths.
                        uint8 internal constant PREFIX_LEAF_ODD = 3;
                        /// @notice Verifies a proof that a given key/value pair is present in the trie.
                        /// @param _key   Key of the node to search for, as a hex string.
                        /// @param _value Value of the node to search for, as a hex string.
                        /// @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle
                        ///               trees, this proof is executed top-down and consists of a list of RLP-encoded
                        ///               nodes that make a path down to the target node.
                        /// @param _root  Known root of the Merkle trie. Used to verify that the included proof is
                        ///               correctly constructed.
                        /// @return valid_ Whether or not the proof is valid.
                        function verifyInclusionProof(
                            bytes memory _key,
                            bytes memory _value,
                            bytes[] memory _proof,
                            bytes32 _root
                        )
                            internal
                            pure
                            returns (bool valid_)
                        {
                            valid_ = Bytes.equal(_value, get(_key, _proof, _root));
                        }
                        /// @notice Retrieves the value associated with a given key.
                        /// @param _key   Key to search for, as hex bytes.
                        /// @param _proof Merkle trie inclusion proof for the key.
                        /// @param _root  Known root of the Merkle trie.
                        /// @return value_ Value of the key if it exists.
                        function get(bytes memory _key, bytes[] memory _proof, bytes32 _root) internal pure returns (bytes memory value_) {
                            require(_key.length > 0, "MerkleTrie: empty key");
                            TrieNode[] memory proof = _parseProof(_proof);
                            bytes memory key = Bytes.toNibbles(_key);
                            bytes memory currentNodeID = abi.encodePacked(_root);
                            uint256 currentKeyIndex = 0;
                            // Proof is top-down, so we start at the first element (root).
                            for (uint256 i = 0; i < proof.length; i++) {
                                TrieNode memory currentNode = proof[i];
                                // Key index should never exceed total key length or we'll be out of bounds.
                                require(currentKeyIndex <= key.length, "MerkleTrie: key index exceeds total key length");
                                if (currentKeyIndex == 0) {
                                    // First proof element is always the root node.
                                    require(
                                        Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID),
                                        "MerkleTrie: invalid root hash"
                                    );
                                } else if (currentNode.encoded.length >= 32) {
                                    // Nodes 32 bytes or larger are hashed inside branch nodes.
                                    require(
                                        Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID),
                                        "MerkleTrie: invalid large internal hash"
                                    );
                                } else {
                                    // Nodes smaller than 32 bytes aren't hashed.
                                    require(Bytes.equal(currentNode.encoded, currentNodeID), "MerkleTrie: invalid internal node hash");
                                }
                                if (currentNode.decoded.length == BRANCH_NODE_LENGTH) {
                                    if (currentKeyIndex == key.length) {
                                        // Value is the last element of the decoded list (for branch nodes). There's
                                        // some ambiguity in the Merkle trie specification because bytes(0) is a
                                        // valid value to place into the trie, but for branch nodes bytes(0) can exist
                                        // even when the value wasn't explicitly placed there. Geth treats a value of
                                        // bytes(0) as "key does not exist" and so we do the same.
                                        value_ = RLPReader.readBytes(currentNode.decoded[TREE_RADIX]);
                                        require(value_.length > 0, "MerkleTrie: value length must be greater than zero (branch)");
                                        // Extra proof elements are not allowed.
                                        require(i == proof.length - 1, "MerkleTrie: value node must be last node in proof (branch)");
                                        return value_;
                                    } else {
                                        // We're not at the end of the key yet.
                                        // Figure out what the next node ID should be and continue.
                                        uint8 branchKey = uint8(key[currentKeyIndex]);
                                        RLPReader.RLPItem memory nextNode = currentNode.decoded[branchKey];
                                        currentNodeID = _getNodeID(nextNode);
                                        currentKeyIndex += 1;
                                    }
                                } else if (currentNode.decoded.length == LEAF_OR_EXTENSION_NODE_LENGTH) {
                                    bytes memory path = _getNodePath(currentNode);
                                    uint8 prefix = uint8(path[0]);
                                    uint8 offset = 2 - (prefix % 2);
                                    bytes memory pathRemainder = Bytes.slice(path, offset);
                                    bytes memory keyRemainder = Bytes.slice(key, currentKeyIndex);
                                    uint256 sharedNibbleLength = _getSharedNibbleLength(pathRemainder, keyRemainder);
                                    // Whether this is a leaf node or an extension node, the path remainder MUST be a
                                    // prefix of the key remainder (or be equal to the key remainder) or the proof is
                                    // considered invalid.
                                    require(
                                        pathRemainder.length == sharedNibbleLength,
                                        "MerkleTrie: path remainder must share all nibbles with key"
                                    );
                                    if (prefix == PREFIX_LEAF_EVEN || prefix == PREFIX_LEAF_ODD) {
                                        // Prefix of 2 or 3 means this is a leaf node. For the leaf node to be valid,
                                        // the key remainder must be exactly equal to the path remainder. We already
                                        // did the necessary byte comparison, so it's more efficient here to check that
                                        // the key remainder length equals the shared nibble length, which implies
                                        // equality with the path remainder (since we already did the same check with
                                        // the path remainder and the shared nibble length).
                                        require(
                                            keyRemainder.length == sharedNibbleLength,
                                            "MerkleTrie: key remainder must be identical to path remainder"
                                        );
                                        // Our Merkle Trie is designed specifically for the purposes of the Ethereum
                                        // state trie. Empty values are not allowed in the state trie, so we can safely
                                        // say that if the value is empty, the key should not exist and the proof is
                                        // invalid.
                                        value_ = RLPReader.readBytes(currentNode.decoded[1]);
                                        require(value_.length > 0, "MerkleTrie: value length must be greater than zero (leaf)");
                                        // Extra proof elements are not allowed.
                                        require(i == proof.length - 1, "MerkleTrie: value node must be last node in proof (leaf)");
                                        return value_;
                                    } else if (prefix == PREFIX_EXTENSION_EVEN || prefix == PREFIX_EXTENSION_ODD) {
                                        // Prefix of 0 or 1 means this is an extension node. We move onto the next node
                                        // in the proof and increment the key index by the length of the path remainder
                                        // which is equal to the shared nibble length.
                                        currentNodeID = _getNodeID(currentNode.decoded[1]);
                                        currentKeyIndex += sharedNibbleLength;
                                    } else {
                                        revert("MerkleTrie: received a node with an unknown prefix");
                                    }
                                } else {
                                    revert("MerkleTrie: received an unparseable node");
                                }
                            }
                            revert("MerkleTrie: ran out of proof elements");
                        }
                        /// @notice Parses an array of proof elements into a new array that contains both the original
                        ///         encoded element and the RLP-decoded element.
                        /// @param _proof Array of proof elements to parse.
                        /// @return proof_ Proof parsed into easily accessible structs.
                        function _parseProof(bytes[] memory _proof) private pure returns (TrieNode[] memory proof_) {
                            uint256 length = _proof.length;
                            proof_ = new TrieNode[](length);
                            for (uint256 i = 0; i < length;) {
                                proof_[i] = TrieNode({ encoded: _proof[i], decoded: RLPReader.readList(_proof[i]) });
                                unchecked {
                                    ++i;
                                }
                            }
                        }
                        /// @notice Picks out the ID for a node. Node ID is referred to as the "hash" within the
                        ///         specification, but nodes < 32 bytes are not actually hashed.
                        /// @param _node Node to pull an ID for.
                        /// @return id_ ID for the node, depending on the size of its contents.
                        function _getNodeID(RLPReader.RLPItem memory _node) private pure returns (bytes memory id_) {
                            id_ = _node.length < 32 ? RLPReader.readRawBytes(_node) : RLPReader.readBytes(_node);
                        }
                        /// @notice Gets the path for a leaf or extension node.
                        /// @param _node Node to get a path for.
                        /// @return nibbles_ Node path, converted to an array of nibbles.
                        function _getNodePath(TrieNode memory _node) private pure returns (bytes memory nibbles_) {
                            nibbles_ = Bytes.toNibbles(RLPReader.readBytes(_node.decoded[0]));
                        }
                        /// @notice Utility; determines the number of nibbles shared between two nibble arrays.
                        /// @param _a First nibble array.
                        /// @param _b Second nibble array.
                        /// @return shared_ Number of shared nibbles.
                        function _getSharedNibbleLength(bytes memory _a, bytes memory _b) private pure returns (uint256 shared_) {
                            uint256 max = (_a.length < _b.length) ? _a.length : _b.length;
                            for (; shared_ < max && _a[shared_] == _b[shared_];) {
                                unchecked {
                                    ++shared_;
                                }
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.15;
                    // Libraries
                    import { Position } from "src/dispute/lib/LibPosition.sol";
                    using LibClaim for Claim global;
                    using LibHash for Hash global;
                    using LibDuration for Duration global;
                    using LibClock for Clock global;
                    using LibGameId for GameId global;
                    using LibTimestamp for Timestamp global;
                    using LibVMStatus for VMStatus global;
                    using LibGameType for GameType global;
                    /// @notice A `Clock` represents a packed `Duration` and `Timestamp`
                    /// @dev The packed layout of this type is as follows:
                    /// ┌────────────┬────────────────┐
                    /// │    Bits    │     Value      │
                    /// ├────────────┼────────────────┤
                    /// │ [0, 64)    │ Duration       │
                    /// │ [64, 128)  │ Timestamp      │
                    /// └────────────┴────────────────┘
                    type Clock is uint128;
                    /// @title LibClock
                    /// @notice This library contains helper functions for working with the `Clock` type.
                    library LibClock {
                        /// @notice Packs a `Duration` and `Timestamp` into a `Clock` type.
                        /// @param _duration The `Duration` to pack into the `Clock` type.
                        /// @param _timestamp The `Timestamp` to pack into the `Clock` type.
                        /// @return clock_ The `Clock` containing the `_duration` and `_timestamp`.
                        function wrap(Duration _duration, Timestamp _timestamp) internal pure returns (Clock clock_) {
                            assembly {
                                clock_ := or(shl(0x40, _duration), _timestamp)
                            }
                        }
                        /// @notice Pull the `Duration` out of a `Clock` type.
                        /// @param _clock The `Clock` type to pull the `Duration` out of.
                        /// @return duration_ The `Duration` pulled out of `_clock`.
                        function duration(Clock _clock) internal pure returns (Duration duration_) {
                            // Shift the high-order 64 bits into the low-order 64 bits, leaving only the `duration`.
                            assembly {
                                duration_ := shr(0x40, _clock)
                            }
                        }
                        /// @notice Pull the `Timestamp` out of a `Clock` type.
                        /// @param _clock The `Clock` type to pull the `Timestamp` out of.
                        /// @return timestamp_ The `Timestamp` pulled out of `_clock`.
                        function timestamp(Clock _clock) internal pure returns (Timestamp timestamp_) {
                            // Clean the high-order 192 bits by shifting the clock left and then right again, leaving
                            // only the `timestamp`.
                            assembly {
                                timestamp_ := shr(0xC0, shl(0xC0, _clock))
                            }
                        }
                        /// @notice Get the value of a `Clock` type in the form of the underlying uint128.
                        /// @param _clock The `Clock` type to get the value of.
                        /// @return clock_ The value of the `Clock` type as a uint128 type.
                        function raw(Clock _clock) internal pure returns (uint128 clock_) {
                            assembly {
                                clock_ := _clock
                            }
                        }
                    }
                    /// @notice A `GameId` represents a packed 4 byte game ID, a 8 byte timestamp, and a 20 byte address.
                    /// @dev The packed layout of this type is as follows:
                    /// ┌───────────┬───────────┐
                    /// │   Bits    │   Value   │
                    /// ├───────────┼───────────┤
                    /// │ [0, 32)   │ Game Type │
                    /// │ [32, 96)  │ Timestamp │
                    /// │ [96, 256) │ Address   │
                    /// └───────────┴───────────┘
                    type GameId is bytes32;
                    /// @title LibGameId
                    /// @notice Utility functions for packing and unpacking GameIds.
                    library LibGameId {
                        /// @notice Packs values into a 32 byte GameId type.
                        /// @param _gameType The game type.
                        /// @param _timestamp The timestamp of the game's creation.
                        /// @param _gameProxy The game proxy address.
                        /// @return gameId_ The packed GameId.
                        function pack(
                            GameType _gameType,
                            Timestamp _timestamp,
                            address _gameProxy
                        )
                            internal
                            pure
                            returns (GameId gameId_)
                        {
                            assembly {
                                gameId_ := or(or(shl(224, _gameType), shl(160, _timestamp)), _gameProxy)
                            }
                        }
                        /// @notice Unpacks values from a 32 byte GameId type.
                        /// @param _gameId The packed GameId.
                        /// @return gameType_ The game type.
                        /// @return timestamp_ The timestamp of the game's creation.
                        /// @return gameProxy_ The game proxy address.
                        function unpack(GameId _gameId)
                            internal
                            pure
                            returns (GameType gameType_, Timestamp timestamp_, address gameProxy_)
                        {
                            assembly {
                                gameType_ := shr(224, _gameId)
                                timestamp_ := and(shr(160, _gameId), 0xFFFFFFFFFFFFFFFF)
                                gameProxy_ := and(_gameId, 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF)
                            }
                        }
                    }
                    /// @notice A claim represents an MPT root representing the state of the fault proof program.
                    type Claim is bytes32;
                    /// @title LibClaim
                    /// @notice This library contains helper functions for working with the `Claim` type.
                    library LibClaim {
                        /// @notice Get the value of a `Claim` type in the form of the underlying bytes32.
                        /// @param _claim The `Claim` type to get the value of.
                        /// @return claim_ The value of the `Claim` type as a bytes32 type.
                        function raw(Claim _claim) internal pure returns (bytes32 claim_) {
                            assembly {
                                claim_ := _claim
                            }
                        }
                        /// @notice Hashes a claim and a position together.
                        /// @param _claim A Claim type.
                        /// @param _position The position of `claim`.
                        /// @param _challengeIndex The index of the claim being moved against.
                        /// @return claimHash_ A hash of abi.encodePacked(claim, position|challengeIndex);
                        function hashClaimPos(
                            Claim _claim,
                            Position _position,
                            uint256 _challengeIndex
                        )
                            internal
                            pure
                            returns (Hash claimHash_)
                        {
                            assembly {
                                mstore(0x00, _claim)
                                mstore(0x20, or(shl(128, _position), and(0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF, _challengeIndex)))
                                claimHash_ := keccak256(0x00, 0x40)
                            }
                        }
                    }
                    /// @notice A dedicated duration type.
                    /// @dev Unit: seconds
                    type Duration is uint64;
                    /// @title LibDuration
                    /// @notice This library contains helper functions for working with the `Duration` type.
                    library LibDuration {
                        /// @notice Get the value of a `Duration` type in the form of the underlying uint64.
                        /// @param _duration The `Duration` type to get the value of.
                        /// @return duration_ The value of the `Duration` type as a uint64 type.
                        function raw(Duration _duration) internal pure returns (uint64 duration_) {
                            assembly {
                                duration_ := _duration
                            }
                        }
                    }
                    /// @notice A custom type for a generic hash.
                    type Hash is bytes32;
                    /// @title LibHash
                    /// @notice This library contains helper functions for working with the `Hash` type.
                    library LibHash {
                        /// @notice Get the value of a `Hash` type in the form of the underlying bytes32.
                        /// @param _hash The `Hash` type to get the value of.
                        /// @return hash_ The value of the `Hash` type as a bytes32 type.
                        function raw(Hash _hash) internal pure returns (bytes32 hash_) {
                            assembly {
                                hash_ := _hash
                            }
                        }
                    }
                    /// @notice A dedicated timestamp type.
                    type Timestamp is uint64;
                    /// @title LibTimestamp
                    /// @notice This library contains helper functions for working with the `Timestamp` type.
                    library LibTimestamp {
                        /// @notice Get the value of a `Timestamp` type in the form of the underlying uint64.
                        /// @param _timestamp The `Timestamp` type to get the value of.
                        /// @return timestamp_ The value of the `Timestamp` type as a uint64 type.
                        function raw(Timestamp _timestamp) internal pure returns (uint64 timestamp_) {
                            assembly {
                                timestamp_ := _timestamp
                            }
                        }
                    }
                    /// @notice A `VMStatus` represents the status of a VM execution.
                    type VMStatus is uint8;
                    /// @title LibVMStatus
                    /// @notice This library contains helper functions for working with the `VMStatus` type.
                    library LibVMStatus {
                        /// @notice Get the value of a `VMStatus` type in the form of the underlying uint8.
                        /// @param _vmstatus The `VMStatus` type to get the value of.
                        /// @return vmstatus_ The value of the `VMStatus` type as a uint8 type.
                        function raw(VMStatus _vmstatus) internal pure returns (uint8 vmstatus_) {
                            assembly {
                                vmstatus_ := _vmstatus
                            }
                        }
                    }
                    /// @notice A `GameType` represents the type of game being played.
                    type GameType is uint32;
                    /// @title LibGameType
                    /// @notice This library contains helper functions for working with the `GameType` type.
                    library LibGameType {
                        /// @notice Get the value of a `GameType` type in the form of the underlying uint32.
                        /// @param _gametype The `GameType` type to get the value of.
                        /// @return gametype_ The value of the `GameType` type as a uint32 type.
                        function raw(GameType _gametype) internal pure returns (uint32 gametype_) {
                            assembly {
                                gametype_ := _gametype
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    interface IInitializable {
                        function initialize() external payable;
                    }
                    // SPDX-License-Identifier: MIT
                    // OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)
                    pragma solidity ^0.8.0;
                    /**
                     * @dev Standard signed math utilities missing in the Solidity language.
                     */
                    library SignedMath {
                        /**
                         * @dev Returns the largest of two signed numbers.
                         */
                        function max(int256 a, int256 b) internal pure returns (int256) {
                            return a >= b ? a : b;
                        }
                        /**
                         * @dev Returns the smallest of two signed numbers.
                         */
                        function min(int256 a, int256 b) internal pure returns (int256) {
                            return a < b ? a : b;
                        }
                        /**
                         * @dev Returns the average of two signed numbers without overflow.
                         * The result is rounded towards zero.
                         */
                        function average(int256 a, int256 b) internal pure returns (int256) {
                            // Formula from the book "Hacker's Delight"
                            int256 x = (a & b) + ((a ^ b) >> 1);
                            return x + (int256(uint256(x) >> 255) & (a ^ b));
                        }
                        /**
                         * @dev Returns the absolute unsigned value of a signed value.
                         */
                        function abs(int256 n) internal pure returns (uint256) {
                            unchecked {
                                // must be unchecked in order to support `n = type(int256).min`
                                return uint256(n >= 0 ? n : -n);
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity >=0.8.0;
                    /// @notice Arithmetic library with operations for fixed-point numbers.
                    /// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)
                    library FixedPointMathLib {
                        /*//////////////////////////////////////////////////////////////
                                        SIMPLIFIED FIXED POINT OPERATIONS
                        //////////////////////////////////////////////////////////////*/
                        uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.
                        function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
                            return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.
                        }
                        function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
                            return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.
                        }
                        function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {
                            return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.
                        }
                        function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {
                            return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.
                        }
                        function powWad(int256 x, int256 y) internal pure returns (int256) {
                            // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)
                            return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.
                        }
                        function expWad(int256 x) internal pure returns (int256 r) {
                            unchecked {
                                // When the result is < 0.5 we return zero. This happens when
                                // x <= floor(log(0.5e18) * 1e18) ~ -42e18
                                if (x <= -42139678854452767551) return 0;
                                // When the result is > (2**255 - 1) / 1e18 we can not represent it as an
                                // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.
                                if (x >= 135305999368893231589) revert("EXP_OVERFLOW");
                                // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96
                                // for more intermediate precision and a binary basis. This base conversion
                                // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.
                                x = (x << 78) / 5**18;
                                // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers
                                // of two such that exp(x) = exp(x') * 2**k, where k is an integer.
                                // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).
                                int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;
                                x = x - k * 54916777467707473351141471128;
                                // k is in the range [-61, 195].
                                // Evaluate using a (6, 7)-term rational approximation.
                                // p is made monic, we'll multiply by a scale factor later.
                                int256 y = x + 1346386616545796478920950773328;
                                y = ((y * x) >> 96) + 57155421227552351082224309758442;
                                int256 p = y + x - 94201549194550492254356042504812;
                                p = ((p * y) >> 96) + 28719021644029726153956944680412240;
                                p = p * x + (4385272521454847904659076985693276 << 96);
                                // We leave p in 2**192 basis so we don't need to scale it back up for the division.
                                int256 q = x - 2855989394907223263936484059900;
                                q = ((q * x) >> 96) + 50020603652535783019961831881945;
                                q = ((q * x) >> 96) - 533845033583426703283633433725380;
                                q = ((q * x) >> 96) + 3604857256930695427073651918091429;
                                q = ((q * x) >> 96) - 14423608567350463180887372962807573;
                                q = ((q * x) >> 96) + 26449188498355588339934803723976023;
                                assembly {
                                    // Div in assembly because solidity adds a zero check despite the unchecked.
                                    // The q polynomial won't have zeros in the domain as all its roots are complex.
                                    // No scaling is necessary because p is already 2**96 too large.
                                    r := sdiv(p, q)
                                }
                                // r should be in the range (0.09, 0.25) * 2**96.
                                // We now need to multiply r by:
                                // * the scale factor s = ~6.031367120.
                                // * the 2**k factor from the range reduction.
                                // * the 1e18 / 2**96 factor for base conversion.
                                // We do this all at once, with an intermediate result in 2**213
                                // basis, so the final right shift is always by a positive amount.
                                r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));
                            }
                        }
                        function lnWad(int256 x) internal pure returns (int256 r) {
                            unchecked {
                                require(x > 0, "UNDEFINED");
                                // We want to convert x from 10**18 fixed point to 2**96 fixed point.
                                // We do this by multiplying by 2**96 / 10**18. But since
                                // ln(x * C) = ln(x) + ln(C), we can simply do nothing here
                                // and add ln(2**96 / 10**18) at the end.
                                // Reduce range of x to (1, 2) * 2**96
                                // ln(2^k * x) = k * ln(2) + ln(x)
                                int256 k = int256(log2(uint256(x))) - 96;
                                x <<= uint256(159 - k);
                                x = int256(uint256(x) >> 159);
                                // Evaluate using a (8, 8)-term rational approximation.
                                // p is made monic, we will multiply by a scale factor later.
                                int256 p = x + 3273285459638523848632254066296;
                                p = ((p * x) >> 96) + 24828157081833163892658089445524;
                                p = ((p * x) >> 96) + 43456485725739037958740375743393;
                                p = ((p * x) >> 96) - 11111509109440967052023855526967;
                                p = ((p * x) >> 96) - 45023709667254063763336534515857;
                                p = ((p * x) >> 96) - 14706773417378608786704636184526;
                                p = p * x - (795164235651350426258249787498 << 96);
                                // We leave p in 2**192 basis so we don't need to scale it back up for the division.
                                // q is monic by convention.
                                int256 q = x + 5573035233440673466300451813936;
                                q = ((q * x) >> 96) + 71694874799317883764090561454958;
                                q = ((q * x) >> 96) + 283447036172924575727196451306956;
                                q = ((q * x) >> 96) + 401686690394027663651624208769553;
                                q = ((q * x) >> 96) + 204048457590392012362485061816622;
                                q = ((q * x) >> 96) + 31853899698501571402653359427138;
                                q = ((q * x) >> 96) + 909429971244387300277376558375;
                                assembly {
                                    // Div in assembly because solidity adds a zero check despite the unchecked.
                                    // The q polynomial is known not to have zeros in the domain.
                                    // No scaling required because p is already 2**96 too large.
                                    r := sdiv(p, q)
                                }
                                // r is in the range (0, 0.125) * 2**96
                                // Finalization, we need to:
                                // * multiply by the scale factor s = 5.549…
                                // * add ln(2**96 / 10**18)
                                // * add k * ln(2)
                                // * multiply by 10**18 / 2**96 = 5**18 >> 78
                                // mul s * 5e18 * 2**96, base is now 5**18 * 2**192
                                r *= 1677202110996718588342820967067443963516166;
                                // add ln(2) * k * 5e18 * 2**192
                                r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;
                                // add ln(2**96 / 10**18) * 5e18 * 2**192
                                r += 600920179829731861736702779321621459595472258049074101567377883020018308;
                                // base conversion: mul 2**18 / 2**192
                                r >>= 174;
                            }
                        }
                        /*//////////////////////////////////////////////////////////////
                                        LOW LEVEL FIXED POINT OPERATIONS
                        //////////////////////////////////////////////////////////////*/
                        function mulDivDown(
                            uint256 x,
                            uint256 y,
                            uint256 denominator
                        ) internal pure returns (uint256 z) {
                            assembly {
                                // Store x * y in z for now.
                                z := mul(x, y)
                                // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
                                if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
                                    revert(0, 0)
                                }
                                // Divide z by the denominator.
                                z := div(z, denominator)
                            }
                        }
                        function mulDivUp(
                            uint256 x,
                            uint256 y,
                            uint256 denominator
                        ) internal pure returns (uint256 z) {
                            assembly {
                                // Store x * y in z for now.
                                z := mul(x, y)
                                // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))
                                if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {
                                    revert(0, 0)
                                }
                                // First, divide z - 1 by the denominator and add 1.
                                // We allow z - 1 to underflow if z is 0, because we multiply the
                                // end result by 0 if z is zero, ensuring we return 0 if z is zero.
                                z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))
                            }
                        }
                        function rpow(
                            uint256 x,
                            uint256 n,
                            uint256 scalar
                        ) internal pure returns (uint256 z) {
                            assembly {
                                switch x
                                case 0 {
                                    switch n
                                    case 0 {
                                        // 0 ** 0 = 1
                                        z := scalar
                                    }
                                    default {
                                        // 0 ** n = 0
                                        z := 0
                                    }
                                }
                                default {
                                    switch mod(n, 2)
                                    case 0 {
                                        // If n is even, store scalar in z for now.
                                        z := scalar
                                    }
                                    default {
                                        // If n is odd, store x in z for now.
                                        z := x
                                    }
                                    // Shifting right by 1 is like dividing by 2.
                                    let half := shr(1, scalar)
                                    for {
                                        // Shift n right by 1 before looping to halve it.
                                        n := shr(1, n)
                                    } n {
                                        // Shift n right by 1 each iteration to halve it.
                                        n := shr(1, n)
                                    } {
                                        // Revert immediately if x ** 2 would overflow.
                                        // Equivalent to iszero(eq(div(xx, x), x)) here.
                                        if shr(128, x) {
                                            revert(0, 0)
                                        }
                                        // Store x squared.
                                        let xx := mul(x, x)
                                        // Round to the nearest number.
                                        let xxRound := add(xx, half)
                                        // Revert if xx + half overflowed.
                                        if lt(xxRound, xx) {
                                            revert(0, 0)
                                        }
                                        // Set x to scaled xxRound.
                                        x := div(xxRound, scalar)
                                        // If n is even:
                                        if mod(n, 2) {
                                            // Compute z * x.
                                            let zx := mul(z, x)
                                            // If z * x overflowed:
                                            if iszero(eq(div(zx, x), z)) {
                                                // Revert if x is non-zero.
                                                if iszero(iszero(x)) {
                                                    revert(0, 0)
                                                }
                                            }
                                            // Round to the nearest number.
                                            let zxRound := add(zx, half)
                                            // Revert if zx + half overflowed.
                                            if lt(zxRound, zx) {
                                                revert(0, 0)
                                            }
                                            // Return properly scaled zxRound.
                                            z := div(zxRound, scalar)
                                        }
                                    }
                                }
                            }
                        }
                        /*//////////////////////////////////////////////////////////////
                                            GENERAL NUMBER UTILITIES
                        //////////////////////////////////////////////////////////////*/
                        function sqrt(uint256 x) internal pure returns (uint256 z) {
                            assembly {
                                let y := x // We start y at x, which will help us make our initial estimate.
                                z := 181 // The "correct" value is 1, but this saves a multiplication later.
                                // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad
                                // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.
                                // We check y >= 2^(k + 8) but shift right by k bits
                                // each branch to ensure that if x >= 256, then y >= 256.
                                if iszero(lt(y, 0x10000000000000000000000000000000000)) {
                                    y := shr(128, y)
                                    z := shl(64, z)
                                }
                                if iszero(lt(y, 0x1000000000000000000)) {
                                    y := shr(64, y)
                                    z := shl(32, z)
                                }
                                if iszero(lt(y, 0x10000000000)) {
                                    y := shr(32, y)
                                    z := shl(16, z)
                                }
                                if iszero(lt(y, 0x1000000)) {
                                    y := shr(16, y)
                                    z := shl(8, z)
                                }
                                // Goal was to get z*z*y within a small factor of x. More iterations could
                                // get y in a tighter range. Currently, we will have y in [256, 256*2^16).
                                // We ensured y >= 256 so that the relative difference between y and y+1 is small.
                                // That's not possible if x < 256 but we can just verify those cases exhaustively.
                                // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.
                                // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.
                                // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.
                                // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range
                                // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.
                                // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate
                                // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.
                                // There is no overflow risk here since y < 2^136 after the first branch above.
                                z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.
                                // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.
                                z := shr(1, add(z, div(x, z)))
                                z := shr(1, add(z, div(x, z)))
                                z := shr(1, add(z, div(x, z)))
                                z := shr(1, add(z, div(x, z)))
                                z := shr(1, add(z, div(x, z)))
                                z := shr(1, add(z, div(x, z)))
                                z := shr(1, add(z, div(x, z)))
                                // If x+1 is a perfect square, the Babylonian method cycles between
                                // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.
                                // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division
                                // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.
                                // If you don't care whether the floor or ceil square root is returned, you can remove this statement.
                                z := sub(z, lt(div(x, z), z))
                            }
                        }
                        function log2(uint256 x) internal pure returns (uint256 r) {
                            require(x > 0, "UNDEFINED");
                            assembly {
                                r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))
                                r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))
                                r := or(r, shl(5, lt(0xffffffff, shr(r, x))))
                                r := or(r, shl(4, lt(0xffff, shr(r, x))))
                                r := or(r, shl(3, lt(0xff, shr(r, x))))
                                r := or(r, shl(2, lt(0xf, shr(r, x))))
                                r := or(r, shl(1, lt(0x3, shr(r, x))))
                                r := or(r, lt(0x1, shr(r, x)))
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @custom:attribution https://github.com/bakaoh/solidity-rlp-encode
                    /// @title RLPWriter
                    /// @author RLPWriter is a library for encoding Solidity types to RLP bytes. Adapted from Bakaoh's
                    ///         RLPEncode library (https://github.com/bakaoh/solidity-rlp-encode) with minor
                    ///         modifications to improve legibility.
                    library RLPWriter {
                        /// @notice RLP encodes a byte string.
                        /// @param _in The byte string to encode.
                        /// @return out_ The RLP encoded string in bytes.
                        function writeBytes(bytes memory _in) internal pure returns (bytes memory out_) {
                            if (_in.length == 1 && uint8(_in[0]) < 128) {
                                out_ = _in;
                            } else {
                                out_ = abi.encodePacked(_writeLength(_in.length, 128), _in);
                            }
                        }
                        /// @notice RLP encodes a list of RLP encoded byte byte strings.
                        /// @param _in The list of RLP encoded byte strings.
                        /// @return list_ The RLP encoded list of items in bytes.
                        function writeList(bytes[] memory _in) internal pure returns (bytes memory list_) {
                            list_ = _flatten(_in);
                            list_ = abi.encodePacked(_writeLength(list_.length, 192), list_);
                        }
                        /// @notice RLP encodes a string.
                        /// @param _in The string to encode.
                        /// @return out_ The RLP encoded string in bytes.
                        function writeString(string memory _in) internal pure returns (bytes memory out_) {
                            out_ = writeBytes(bytes(_in));
                        }
                        /// @notice RLP encodes an address.
                        /// @param _in The address to encode.
                        /// @return out_ The RLP encoded address in bytes.
                        function writeAddress(address _in) internal pure returns (bytes memory out_) {
                            out_ = writeBytes(abi.encodePacked(_in));
                        }
                        /// @notice RLP encodes a uint.
                        /// @param _in The uint256 to encode.
                        /// @return out_ The RLP encoded uint256 in bytes.
                        function writeUint(uint256 _in) internal pure returns (bytes memory out_) {
                            out_ = writeBytes(_toBinary(_in));
                        }
                        /// @notice RLP encodes a bool.
                        /// @param _in The bool to encode.
                        /// @return out_ The RLP encoded bool in bytes.
                        function writeBool(bool _in) internal pure returns (bytes memory out_) {
                            out_ = new bytes(1);
                            out_[0] = (_in ? bytes1(0x01) : bytes1(0x80));
                        }
                        /// @notice Encode the first byte and then the `len` in binary form if `length` is more than 55.
                        /// @param _len    The length of the string or the payload.
                        /// @param _offset 128 if item is string, 192 if item is list.
                        /// @return out_ RLP encoded bytes.
                        function _writeLength(uint256 _len, uint256 _offset) private pure returns (bytes memory out_) {
                            if (_len < 56) {
                                out_ = new bytes(1);
                                out_[0] = bytes1(uint8(_len) + uint8(_offset));
                            } else {
                                uint256 lenLen;
                                uint256 i = 1;
                                while (_len / i != 0) {
                                    lenLen++;
                                    i *= 256;
                                }
                                out_ = new bytes(lenLen + 1);
                                out_[0] = bytes1(uint8(lenLen) + uint8(_offset) + 55);
                                for (i = 1; i <= lenLen; i++) {
                                    out_[i] = bytes1(uint8((_len / (256 ** (lenLen - i))) % 256));
                                }
                            }
                        }
                        /// @notice Encode integer in big endian binary form with no leading zeroes.
                        /// @param _x The integer to encode.
                        /// @return out_ RLP encoded bytes.
                        function _toBinary(uint256 _x) private pure returns (bytes memory out_) {
                            bytes memory b = abi.encodePacked(_x);
                            uint256 i = 0;
                            for (; i < 32; i++) {
                                if (b[i] != 0) {
                                    break;
                                }
                            }
                            out_ = new bytes(32 - i);
                            for (uint256 j = 0; j < out_.length; j++) {
                                out_[j] = b[i++];
                            }
                        }
                        /// @custom:attribution https://github.com/Arachnid/solidity-stringutils
                        /// @notice Copies a piece of memory to another location.
                        /// @param _dest Destination location.
                        /// @param _src  Source location.
                        /// @param _len  Length of memory to copy.
                        function _memcpy(uint256 _dest, uint256 _src, uint256 _len) private pure {
                            uint256 dest = _dest;
                            uint256 src = _src;
                            uint256 len = _len;
                            for (; len >= 32; len -= 32) {
                                assembly {
                                    mstore(dest, mload(src))
                                }
                                dest += 32;
                                src += 32;
                            }
                            uint256 mask;
                            unchecked {
                                mask = 256 ** (32 - len) - 1;
                            }
                            assembly {
                                let srcpart := and(mload(src), not(mask))
                                let destpart := and(mload(dest), mask)
                                mstore(dest, or(destpart, srcpart))
                            }
                        }
                        /// @custom:attribution https://github.com/sammayo/solidity-rlp-encoder
                        /// @notice Flattens a list of byte strings into one byte string.
                        /// @param _list List of byte strings to flatten.
                        /// @return out_ The flattened byte string.
                        function _flatten(bytes[] memory _list) private pure returns (bytes memory out_) {
                            if (_list.length == 0) {
                                return new bytes(0);
                            }
                            uint256 len;
                            uint256 i = 0;
                            for (; i < _list.length; i++) {
                                len += _list[i].length;
                            }
                            out_ = new bytes(len);
                            uint256 flattenedPtr;
                            assembly {
                                flattenedPtr := add(out_, 0x20)
                            }
                            for (i = 0; i < _list.length; i++) {
                                bytes memory item = _list[i];
                                uint256 listPtr;
                                assembly {
                                    listPtr := add(item, 0x20)
                                }
                                _memcpy(flattenedPtr, listPtr, item.length);
                                flattenedPtr += _list[i].length;
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @title Bytes
                    /// @notice Bytes is a library for manipulating byte arrays.
                    library Bytes {
                        /// @custom:attribution https://github.com/GNSPS/solidity-bytes-utils
                        /// @notice Slices a byte array with a given starting index and length. Returns a new byte array
                        ///         as opposed to a pointer to the original array. Will throw if trying to slice more
                        ///         bytes than exist in the array.
                        /// @param _bytes Byte array to slice.
                        /// @param _start Starting index of the slice.
                        /// @param _length Length of the slice.
                        /// @return Slice of the input byte array.
                        function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) {
                            unchecked {
                                require(_length + 31 >= _length, "slice_overflow");
                                require(_start + _length >= _start, "slice_overflow");
                                require(_bytes.length >= _start + _length, "slice_outOfBounds");
                            }
                            bytes memory tempBytes;
                            assembly {
                                switch iszero(_length)
                                case 0 {
                                    // Get a location of some free memory and store it in tempBytes as
                                    // Solidity does for memory variables.
                                    tempBytes := mload(0x40)
                                    // The first word of the slice result is potentially a partial
                                    // word read from the original array. To read it, we calculate
                                    // the length of that partial word and start copying that many
                                    // bytes into the array. The first word we copy will start with
                                    // data we don't care about, but the last `lengthmod` bytes will
                                    // land at the beginning of the contents of the new array. When
                                    // we're done copying, we overwrite the full first word with
                                    // the actual length of the slice.
                                    let lengthmod := and(_length, 31)
                                    // The multiplication in the next line is necessary
                                    // because when slicing multiples of 32 bytes (lengthmod == 0)
                                    // the following copy loop was copying the origin's length
                                    // and then ending prematurely not copying everything it should.
                                    let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))
                                    let end := add(mc, _length)
                                    for {
                                        // The multiplication in the next line has the same exact purpose
                                        // as the one above.
                                        let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)
                                    } lt(mc, end) {
                                        mc := add(mc, 0x20)
                                        cc := add(cc, 0x20)
                                    } { mstore(mc, mload(cc)) }
                                    mstore(tempBytes, _length)
                                    //update free-memory pointer
                                    //allocating the array padded to 32 bytes like the compiler does now
                                    mstore(0x40, and(add(mc, 31), not(31)))
                                }
                                //if we want a zero-length slice let's just return a zero-length array
                                default {
                                    tempBytes := mload(0x40)
                                    //zero out the 32 bytes slice we are about to return
                                    //we need to do it because Solidity does not garbage collect
                                    mstore(tempBytes, 0)
                                    mstore(0x40, add(tempBytes, 0x20))
                                }
                            }
                            return tempBytes;
                        }
                        /// @notice Slices a byte array with a given starting index up to the end of the original byte
                        ///         array. Returns a new array rathern than a pointer to the original.
                        /// @param _bytes Byte array to slice.
                        /// @param _start Starting index of the slice.
                        /// @return Slice of the input byte array.
                        function slice(bytes memory _bytes, uint256 _start) internal pure returns (bytes memory) {
                            if (_start >= _bytes.length) {
                                return bytes("");
                            }
                            return slice(_bytes, _start, _bytes.length - _start);
                        }
                        /// @notice Converts a byte array into a nibble array by splitting each byte into two nibbles.
                        ///         Resulting nibble array will be exactly twice as long as the input byte array.
                        /// @param _bytes Input byte array to convert.
                        /// @return Resulting nibble array.
                        function toNibbles(bytes memory _bytes) internal pure returns (bytes memory) {
                            bytes memory _nibbles;
                            assembly {
                                // Grab a free memory offset for the new array
                                _nibbles := mload(0x40)
                                // Load the length of the passed bytes array from memory
                                let bytesLength := mload(_bytes)
                                // Calculate the length of the new nibble array
                                // This is the length of the input array times 2
                                let nibblesLength := shl(0x01, bytesLength)
                                // Update the free memory pointer to allocate memory for the new array.
                                // To do this, we add the length of the new array + 32 bytes for the array length
                                // rounded up to the nearest 32 byte boundary to the current free memory pointer.
                                mstore(0x40, add(_nibbles, and(not(0x1F), add(nibblesLength, 0x3F))))
                                // Store the length of the new array in memory
                                mstore(_nibbles, nibblesLength)
                                // Store the memory offset of the _bytes array's contents on the stack
                                let bytesStart := add(_bytes, 0x20)
                                // Store the memory offset of the nibbles array's contents on the stack
                                let nibblesStart := add(_nibbles, 0x20)
                                // Loop through each byte in the input array
                                for { let i := 0x00 } lt(i, bytesLength) { i := add(i, 0x01) } {
                                    // Get the starting offset of the next 2 bytes in the nibbles array
                                    let offset := add(nibblesStart, shl(0x01, i))
                                    // Load the byte at the current index within the `_bytes` array
                                    let b := byte(0x00, mload(add(bytesStart, i)))
                                    // Pull out the first nibble and store it in the new array
                                    mstore8(offset, shr(0x04, b))
                                    // Pull out the second nibble and store it in the new array
                                    mstore8(add(offset, 0x01), and(b, 0x0F))
                                }
                            }
                            return _nibbles;
                        }
                        /// @notice Compares two byte arrays by comparing their keccak256 hashes.
                        /// @param _bytes First byte array to compare.
                        /// @param _other Second byte array to compare.
                        /// @return True if the two byte arrays are equal, false otherwise.
                        function equal(bytes memory _bytes, bytes memory _other) internal pure returns (bool) {
                            return keccak256(_bytes) == keccak256(_other);
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.8;
                    // Libraries
                    import {
                        EmptyItem,
                        UnexpectedString,
                        InvalidDataRemainder,
                        ContentLengthMismatch,
                        InvalidHeader,
                        UnexpectedList
                    } from "src/libraries/rlp/RLPErrors.sol";
                    /// @custom:attribution https://github.com/hamdiallam/Solidity-RLP
                    /// @title RLPReader
                    /// @notice RLPReader is a library for parsing RLP-encoded byte arrays into Solidity types. Adapted
                    ///         from Solidity-RLP (https://github.com/hamdiallam/Solidity-RLP) by Hamdi Allam with
                    ///         various tweaks to improve readability.
                    library RLPReader {
                        /// @notice Custom pointer type to avoid confusion between pointers and uint256s.
                        type MemoryPointer is uint256;
                        /// @notice RLP item types.
                        /// @custom:value DATA_ITEM Represents an RLP data item (NOT a list).
                        /// @custom:value LIST_ITEM Represents an RLP list item.
                        enum RLPItemType {
                            DATA_ITEM,
                            LIST_ITEM
                        }
                        /// @notice Struct representing an RLP item.
                        /// @custom:field length Length of the RLP item.
                        /// @custom:field ptr    Pointer to the RLP item in memory.
                        struct RLPItem {
                            uint256 length;
                            MemoryPointer ptr;
                        }
                        /// @notice Max list length that this library will accept.
                        uint256 internal constant MAX_LIST_LENGTH = 32;
                        /// @notice Converts bytes to a reference to memory position and length.
                        /// @param _in Input bytes to convert.
                        /// @return out_ Output memory reference.
                        function toRLPItem(bytes memory _in) internal pure returns (RLPItem memory out_) {
                            // Empty arrays are not RLP items.
                            if (_in.length == 0) revert EmptyItem();
                            MemoryPointer ptr;
                            assembly {
                                ptr := add(_in, 32)
                            }
                            out_ = RLPItem({ length: _in.length, ptr: ptr });
                        }
                        /// @notice Reads an RLP list value into a list of RLP items.
                        /// @param _in RLP list value.
                        /// @return out_ Decoded RLP list items.
                        function readList(RLPItem memory _in) internal pure returns (RLPItem[] memory out_) {
                            (uint256 listOffset, uint256 listLength, RLPItemType itemType) = _decodeLength(_in);
                            if (itemType != RLPItemType.LIST_ITEM) revert UnexpectedString();
                            if (listOffset + listLength != _in.length) revert InvalidDataRemainder();
                            // Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by
                            // writing to the length. Since we can't know the number of RLP items without looping over
                            // the entire input, we'd have to loop twice to accurately size this array. It's easier to
                            // simply set a reasonable maximum list length and decrease the size before we finish.
                            out_ = new RLPItem[](MAX_LIST_LENGTH);
                            uint256 itemCount = 0;
                            uint256 offset = listOffset;
                            while (offset < _in.length) {
                                (uint256 itemOffset, uint256 itemLength,) = _decodeLength(
                                    RLPItem({ length: _in.length - offset, ptr: MemoryPointer.wrap(MemoryPointer.unwrap(_in.ptr) + offset) })
                                );
                                // We don't need to check itemCount < out.length explicitly because Solidity already
                                // handles this check on our behalf, we'd just be wasting gas.
                                out_[itemCount] = RLPItem({
                                    length: itemLength + itemOffset,
                                    ptr: MemoryPointer.wrap(MemoryPointer.unwrap(_in.ptr) + offset)
                                });
                                itemCount += 1;
                                offset += itemOffset + itemLength;
                            }
                            // Decrease the array size to match the actual item count.
                            assembly {
                                mstore(out_, itemCount)
                            }
                        }
                        /// @notice Reads an RLP list value into a list of RLP items.
                        /// @param _in RLP list value.
                        /// @return out_ Decoded RLP list items.
                        function readList(bytes memory _in) internal pure returns (RLPItem[] memory out_) {
                            out_ = readList(toRLPItem(_in));
                        }
                        /// @notice Reads an RLP bytes value into bytes.
                        /// @param _in RLP bytes value.
                        /// @return out_ Decoded bytes.
                        function readBytes(RLPItem memory _in) internal pure returns (bytes memory out_) {
                            (uint256 itemOffset, uint256 itemLength, RLPItemType itemType) = _decodeLength(_in);
                            if (itemType != RLPItemType.DATA_ITEM) revert UnexpectedList();
                            if (_in.length != itemOffset + itemLength) revert InvalidDataRemainder();
                            out_ = _copy(_in.ptr, itemOffset, itemLength);
                        }
                        /// @notice Reads an RLP bytes value into bytes.
                        /// @param _in RLP bytes value.
                        /// @return out_ Decoded bytes.
                        function readBytes(bytes memory _in) internal pure returns (bytes memory out_) {
                            out_ = readBytes(toRLPItem(_in));
                        }
                        /// @notice Reads the raw bytes of an RLP item.
                        /// @param _in RLP item to read.
                        /// @return out_ Raw RLP bytes.
                        function readRawBytes(RLPItem memory _in) internal pure returns (bytes memory out_) {
                            out_ = _copy(_in.ptr, 0, _in.length);
                        }
                        /// @notice Decodes the length of an RLP item.
                        /// @param _in RLP item to decode.
                        /// @return offset_ Offset of the encoded data.
                        /// @return length_ Length of the encoded data.
                        /// @return type_ RLP item type (LIST_ITEM or DATA_ITEM).
                        function _decodeLength(RLPItem memory _in)
                            private
                            pure
                            returns (uint256 offset_, uint256 length_, RLPItemType type_)
                        {
                            // Short-circuit if there's nothing to decode, note that we perform this check when
                            // the user creates an RLP item via toRLPItem, but it's always possible for them to bypass
                            // that function and create an RLP item directly. So we need to check this anyway.
                            if (_in.length == 0) revert EmptyItem();
                            MemoryPointer ptr = _in.ptr;
                            uint256 prefix;
                            assembly {
                                prefix := byte(0, mload(ptr))
                            }
                            if (prefix <= 0x7f) {
                                // Single byte.
                                return (0, 1, RLPItemType.DATA_ITEM);
                            } else if (prefix <= 0xb7) {
                                // Short string.
                                // slither-disable-next-line variable-scope
                                uint256 strLen = prefix - 0x80;
                                if (_in.length <= strLen) revert ContentLengthMismatch();
                                bytes1 firstByteOfContent;
                                assembly {
                                    firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))
                                }
                                if (strLen == 1 && firstByteOfContent < 0x80) revert InvalidHeader();
                                return (1, strLen, RLPItemType.DATA_ITEM);
                            } else if (prefix <= 0xbf) {
                                // Long string.
                                uint256 lenOfStrLen = prefix - 0xb7;
                                if (_in.length <= lenOfStrLen) revert ContentLengthMismatch();
                                bytes1 firstByteOfContent;
                                assembly {
                                    firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))
                                }
                                if (firstByteOfContent == 0x00) revert InvalidHeader();
                                uint256 strLen;
                                assembly {
                                    strLen := shr(sub(256, mul(8, lenOfStrLen)), mload(add(ptr, 1)))
                                }
                                if (strLen <= 55) revert InvalidHeader();
                                if (_in.length <= lenOfStrLen + strLen) revert ContentLengthMismatch();
                                return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM);
                            } else if (prefix <= 0xf7) {
                                // Short list.
                                // slither-disable-next-line variable-scope
                                uint256 listLen = prefix - 0xc0;
                                if (_in.length <= listLen) revert ContentLengthMismatch();
                                return (1, listLen, RLPItemType.LIST_ITEM);
                            } else {
                                // Long list.
                                uint256 lenOfListLen = prefix - 0xf7;
                                if (_in.length <= lenOfListLen) revert ContentLengthMismatch();
                                bytes1 firstByteOfContent;
                                assembly {
                                    firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))
                                }
                                if (firstByteOfContent == 0x00) revert InvalidHeader();
                                uint256 listLen;
                                assembly {
                                    listLen := shr(sub(256, mul(8, lenOfListLen)), mload(add(ptr, 1)))
                                }
                                if (listLen <= 55) revert InvalidHeader();
                                if (_in.length <= lenOfListLen + listLen) revert ContentLengthMismatch();
                                return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM);
                            }
                        }
                        /// @notice Copies the bytes from a memory location.
                        /// @param _src    Pointer to the location to read from.
                        /// @param _offset Offset to start reading from.
                        /// @param _length Number of bytes to read.
                        /// @return out_ Copied bytes.
                        function _copy(MemoryPointer _src, uint256 _offset, uint256 _length) private pure returns (bytes memory out_) {
                            out_ = new bytes(_length);
                            if (_length == 0) {
                                return out_;
                            }
                            // Mostly based on Solidity's copy_memory_to_memory:
                            // https://github.com/ethereum/solidity/blob/34dd30d71b4da730488be72ff6af7083cf2a91f6/libsolidity/codegen/YulUtilFunctions.cpp#L102-L114
                            uint256 src = MemoryPointer.unwrap(_src) + _offset;
                            assembly {
                                let dest := add(out_, 32)
                                let i := 0
                                for { } lt(i, _length) { i := add(i, 32) } { mstore(add(dest, i), mload(add(src, i))) }
                                if gt(i, _length) { mstore(add(dest, _length), 0) }
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.15;
                    using LibPosition for Position global;
                    /// @notice A `Position` represents a position of a claim within the game tree.
                    /// @dev This is represented as a "generalized index" where the high-order bit
                    /// is the level in the tree and the remaining bits is a unique bit pattern, allowing
                    /// a unique identifier for each node in the tree. Mathematically, it is calculated
                    /// as 2^{depth} + indexAtDepth.
                    type Position is uint128;
                    /// @title LibPosition
                    /// @notice This library contains helper functions for working with the `Position` type.
                    library LibPosition {
                        /// @notice the `MAX_POSITION_BITLEN` is the number of bits that the `Position` type, and the implementation of
                        ///         its behavior within this library, can safely support.
                        uint8 internal constant MAX_POSITION_BITLEN = 126;
                        /// @notice Computes a generalized index (2^{depth} + indexAtDepth).
                        /// @param _depth The depth of the position.
                        /// @param _indexAtDepth The index at the depth of the position.
                        /// @return position_ The computed generalized index.
                        function wrap(uint8 _depth, uint128 _indexAtDepth) internal pure returns (Position position_) {
                            assembly {
                                // gindex = 2^{_depth} + _indexAtDepth
                                position_ := add(shl(_depth, 1), _indexAtDepth)
                            }
                        }
                        /// @notice Pulls the `depth` out of a `Position` type.
                        /// @param _position The generalized index to get the `depth` of.
                        /// @return depth_ The `depth` of the `position` gindex.
                        /// @custom:attribution Solady <https://github.com/Vectorized/Solady>
                        function depth(Position _position) internal pure returns (uint8 depth_) {
                            // Return the most significant bit offset, which signifies the depth of the gindex.
                            assembly {
                                depth_ := or(depth_, shl(6, lt(0xffffffffffffffff, shr(depth_, _position))))
                                depth_ := or(depth_, shl(5, lt(0xffffffff, shr(depth_, _position))))
                                // For the remaining 32 bits, use a De Bruijn lookup.
                                _position := shr(depth_, _position)
                                _position := or(_position, shr(1, _position))
                                _position := or(_position, shr(2, _position))
                                _position := or(_position, shr(4, _position))
                                _position := or(_position, shr(8, _position))
                                _position := or(_position, shr(16, _position))
                                depth_ :=
                                    or(
                                        depth_,
                                        byte(
                                            shr(251, mul(_position, shl(224, 0x07c4acdd))),
                                            0x0009010a0d15021d0b0e10121619031e080c141c0f111807131b17061a05041f
                                        )
                                    )
                            }
                        }
                        /// @notice Pulls the `indexAtDepth` out of a `Position` type.
                        ///         The `indexAtDepth` is the left/right index of a position at a specific depth within
                        ///         the binary tree, starting from index 0. For example, at gindex 2, the `depth` = 1
                        ///         and the `indexAtDepth` = 0.
                        /// @param _position The generalized index to get the `indexAtDepth` of.
                        /// @return indexAtDepth_ The `indexAtDepth` of the `position` gindex.
                        function indexAtDepth(Position _position) internal pure returns (uint128 indexAtDepth_) {
                            // Return bits p_{msb-1}...p_{0}. This effectively pulls the 2^{depth} out of the gindex,
                            // leaving only the `indexAtDepth`.
                            uint256 msb = depth(_position);
                            assembly {
                                indexAtDepth_ := sub(_position, shl(msb, 1))
                            }
                        }
                        /// @notice Get the left child of `_position`.
                        /// @param _position The position to get the left position of.
                        /// @return left_ The position to the left of `position`.
                        function left(Position _position) internal pure returns (Position left_) {
                            assembly {
                                left_ := shl(1, _position)
                            }
                        }
                        /// @notice Get the right child of `_position`
                        /// @param _position The position to get the right position of.
                        /// @return right_ The position to the right of `position`.
                        function right(Position _position) internal pure returns (Position right_) {
                            assembly {
                                right_ := or(1, shl(1, _position))
                            }
                        }
                        /// @notice Get the parent position of `_position`.
                        /// @param _position The position to get the parent position of.
                        /// @return parent_ The parent position of `position`.
                        function parent(Position _position) internal pure returns (Position parent_) {
                            assembly {
                                parent_ := shr(1, _position)
                            }
                        }
                        /// @notice Get the deepest, right most gindex relative to the `position`. This is equivalent to
                        ///         calling `right` on a position until the maximum depth is reached.
                        /// @param _position The position to get the relative deepest, right most gindex of.
                        /// @param _maxDepth The maximum depth of the game.
                        /// @return rightIndex_ The deepest, right most gindex relative to the `position`.
                        function rightIndex(Position _position, uint256 _maxDepth) internal pure returns (Position rightIndex_) {
                            uint256 msb = depth(_position);
                            assembly {
                                let remaining := sub(_maxDepth, msb)
                                rightIndex_ := or(shl(remaining, _position), sub(shl(remaining, 1), 1))
                            }
                        }
                        /// @notice Get the deepest, right most trace index relative to the `position`. This is
                        ///         equivalent to calling `right` on a position until the maximum depth is reached and
                        ///         then finding its index at depth.
                        /// @param _position The position to get the relative trace index of.
                        /// @param _maxDepth The maximum depth of the game.
                        /// @return traceIndex_ The trace index relative to the `position`.
                        function traceIndex(Position _position, uint256 _maxDepth) internal pure returns (uint256 traceIndex_) {
                            uint256 msb = depth(_position);
                            assembly {
                                let remaining := sub(_maxDepth, msb)
                                traceIndex_ := sub(or(shl(remaining, _position), sub(shl(remaining, 1), 1)), shl(_maxDepth, 1))
                            }
                        }
                        /// @notice Gets the position of the highest ancestor of `_position` that commits to the same
                        ///         trace index.
                        /// @param _position The position to get the highest ancestor of.
                        /// @return ancestor_ The highest ancestor of `position` that commits to the same trace index.
                        function traceAncestor(Position _position) internal pure returns (Position ancestor_) {
                            // Create a field with only the lowest unset bit of `_position` set.
                            Position lsb;
                            assembly {
                                lsb := and(not(_position), add(_position, 1))
                            }
                            // Find the index of the lowest unset bit within the field.
                            uint256 msb = depth(lsb);
                            // The highest ancestor that commits to the same trace index is the original position
                            // shifted right by the index of the lowest unset bit.
                            assembly {
                                let a := shr(msb, _position)
                                // Bound the ancestor to the minimum gindex, 1.
                                ancestor_ := or(a, iszero(a))
                            }
                        }
                        /// @notice Gets the position of the highest ancestor of `_position` that commits to the same
                        ///         trace index, while still being below `_upperBoundExclusive`.
                        /// @param _position The position to get the highest ancestor of.
                        /// @param _upperBoundExclusive The exclusive upper depth bound, used to inform where to stop in order
                        ///                             to not escape a sub-tree.
                        /// @return ancestor_ The highest ancestor of `position` that commits to the same trace index.
                        function traceAncestorBounded(
                            Position _position,
                            uint256 _upperBoundExclusive
                        )
                            internal
                            pure
                            returns (Position ancestor_)
                        {
                            // This function only works for positions that are below the upper bound.
                            if (_position.depth() <= _upperBoundExclusive) {
                                assembly {
                                    // Revert with `ClaimAboveSplit()`
                                    mstore(0x00, 0xb34b5c22)
                                    revert(0x1C, 0x04)
                                }
                            }
                            // Grab the global trace ancestor.
                            ancestor_ = traceAncestor(_position);
                            // If the ancestor is above or at the upper bound, shift it to be below the upper bound.
                            // This should be a special case that only covers positions that commit to the final leaf
                            // in a sub-tree.
                            if (ancestor_.depth() <= _upperBoundExclusive) {
                                ancestor_ = ancestor_.rightIndex(_upperBoundExclusive + 1);
                            }
                        }
                        /// @notice Get the move position of `_position`, which is the left child of:
                        ///         1. `_position` if `_isAttack` is true.
                        ///         2. `_position | 1` if `_isAttack` is false.
                        /// @param _position The position to get the relative attack/defense position of.
                        /// @param _isAttack Whether or not the move is an attack move.
                        /// @return move_ The move position relative to `position`.
                        function move(Position _position, bool _isAttack) internal pure returns (Position move_) {
                            assembly {
                                move_ := shl(1, or(iszero(_isAttack), _position))
                            }
                        }
                        /// @notice Get the value of a `Position` type in the form of the underlying uint128.
                        /// @param _position The position to get the value of.
                        /// @return raw_ The value of the `position` as a uint128 type.
                        function raw(Position _position) internal pure returns (uint128 raw_) {
                            assembly {
                                raw_ := _position
                            }
                        }
                    }
                    // SPDX-License-Identifier: MIT
                    pragma solidity ^0.8.0;
                    /// @notice The length of an RLP item must be greater than zero to be decodable
                    error EmptyItem();
                    /// @notice The decoded item type for list is not a list item
                    error UnexpectedString();
                    /// @notice The RLP item has an invalid data remainder
                    error InvalidDataRemainder();
                    /// @notice Decoded item type for bytes is not a string item
                    error UnexpectedList();
                    /// @notice The length of the content must be greater than the RLP item length
                    error ContentLengthMismatch();
                    /// @notice Invalid RLP header for RLP item
                    error InvalidHeader();
                    

                    File 11 of 11: Proxy
                    // SPDX-License-Identifier: MIT
                    pragma solidity 0.8.15;
                    /**
                     * @title Proxy
                     * @notice Proxy is a transparent proxy that passes through the call if the caller is the owner or
                     *         if the caller is address(0), meaning that the call originated from an off-chain
                     *         simulation.
                     */
                    contract Proxy {
                        /**
                         * @notice The storage slot that holds the address of the implementation.
                         *         bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)
                         */
                        bytes32 internal constant IMPLEMENTATION_KEY =
                            0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
                        /**
                         * @notice The storage slot that holds the address of the owner.
                         *         bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)
                         */
                        bytes32 internal constant OWNER_KEY =
                            0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;
                        /**
                         * @notice An event that is emitted each time the implementation is changed. This event is part
                         *         of the EIP-1967 specification.
                         *
                         * @param implementation The address of the implementation contract
                         */
                        event Upgraded(address indexed implementation);
                        /**
                         * @notice An event that is emitted each time the owner is upgraded. This event is part of the
                         *         EIP-1967 specification.
                         *
                         * @param previousAdmin The previous owner of the contract
                         * @param newAdmin      The new owner of the contract
                         */
                        event AdminChanged(address previousAdmin, address newAdmin);
                        /**
                         * @notice A modifier that reverts if not called by the owner or by address(0) to allow
                         *         eth_call to interact with this proxy without needing to use low-level storage
                         *         inspection. We assume that nobody is able to trigger calls from address(0) during
                         *         normal EVM execution.
                         */
                        modifier proxyCallIfNotAdmin() {
                            if (msg.sender == _getAdmin() || msg.sender == address(0)) {
                                _;
                            } else {
                                // This WILL halt the call frame on completion.
                                _doProxyCall();
                            }
                        }
                        /**
                         * @notice Sets the initial admin during contract deployment. Admin address is stored at the
                         *         EIP-1967 admin storage slot so that accidental storage collision with the
                         *         implementation is not possible.
                         *
                         * @param _admin Address of the initial contract admin. Admin as the ability to access the
                         *               transparent proxy interface.
                         */
                        constructor(address _admin) {
                            _changeAdmin(_admin);
                        }
                        // slither-disable-next-line locked-ether
                        receive() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        // slither-disable-next-line locked-ether
                        fallback() external payable {
                            // Proxy call by default.
                            _doProxyCall();
                        }
                        /**
                         * @notice Set the implementation contract address. The code at the given address will execute
                         *         when this contract is called.
                         *
                         * @param _implementation Address of the implementation contract.
                         */
                        function upgradeTo(address _implementation) public virtual proxyCallIfNotAdmin {
                            _setImplementation(_implementation);
                        }
                        /**
                         * @notice Set the implementation and call a function in a single transaction. Useful to ensure
                         *         atomic execution of initialization-based upgrades.
                         *
                         * @param _implementation Address of the implementation contract.
                         * @param _data           Calldata to delegatecall the new implementation with.
                         */
                        function upgradeToAndCall(address _implementation, bytes calldata _data)
                            public
                            payable
                            virtual
                            proxyCallIfNotAdmin
                            returns (bytes memory)
                        {
                            _setImplementation(_implementation);
                            (bool success, bytes memory returndata) = _implementation.delegatecall(_data);
                            require(success, "Proxy: delegatecall to new implementation contract failed");
                            return returndata;
                        }
                        /**
                         * @notice Changes the owner of the proxy contract. Only callable by the owner.
                         *
                         * @param _admin New owner of the proxy contract.
                         */
                        function changeAdmin(address _admin) public virtual proxyCallIfNotAdmin {
                            _changeAdmin(_admin);
                        }
                        /**
                         * @notice Gets the owner of the proxy contract.
                         *
                         * @return Owner address.
                         */
                        function admin() public virtual proxyCallIfNotAdmin returns (address) {
                            return _getAdmin();
                        }
                        /**
                         * @notice Queries the implementation address.
                         *
                         * @return Implementation address.
                         */
                        function implementation() public virtual proxyCallIfNotAdmin returns (address) {
                            return _getImplementation();
                        }
                        /**
                         * @notice Sets the implementation address.
                         *
                         * @param _implementation New implementation address.
                         */
                        function _setImplementation(address _implementation) internal {
                            assembly {
                                sstore(IMPLEMENTATION_KEY, _implementation)
                            }
                            emit Upgraded(_implementation);
                        }
                        /**
                         * @notice Changes the owner of the proxy contract.
                         *
                         * @param _admin New owner of the proxy contract.
                         */
                        function _changeAdmin(address _admin) internal {
                            address previous = _getAdmin();
                            assembly {
                                sstore(OWNER_KEY, _admin)
                            }
                            emit AdminChanged(previous, _admin);
                        }
                        /**
                         * @notice Performs the proxy call via a delegatecall.
                         */
                        function _doProxyCall() internal {
                            address impl = _getImplementation();
                            require(impl != address(0), "Proxy: implementation not initialized");
                            assembly {
                                // Copy calldata into memory at 0x0....calldatasize.
                                calldatacopy(0x0, 0x0, calldatasize())
                                // Perform the delegatecall, make sure to pass all available gas.
                                let success := delegatecall(gas(), impl, 0x0, calldatasize(), 0x0, 0x0)
                                // Copy returndata into memory at 0x0....returndatasize. Note that this *will*
                                // overwrite the calldata that we just copied into memory but that doesn't really
                                // matter because we'll be returning in a second anyway.
                                returndatacopy(0x0, 0x0, returndatasize())
                                // Success == 0 means a revert. We'll revert too and pass the data up.
                                if iszero(success) {
                                    revert(0x0, returndatasize())
                                }
                                // Otherwise we'll just return and pass the data up.
                                return(0x0, returndatasize())
                            }
                        }
                        /**
                         * @notice Queries the implementation address.
                         *
                         * @return Implementation address.
                         */
                        function _getImplementation() internal view returns (address) {
                            address impl;
                            assembly {
                                impl := sload(IMPLEMENTATION_KEY)
                            }
                            return impl;
                        }
                        /**
                         * @notice Queries the owner of the proxy contract.
                         *
                         * @return Owner address.
                         */
                        function _getAdmin() internal view returns (address) {
                            address owner;
                            assembly {
                                owner := sload(OWNER_KEY)
                            }
                            return owner;
                        }
                    }