creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/L1/L1StandardBridge.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { Predeploys } from \"src/libraries/Predeploys.sol\";\nimport { StandardBridge } from \"src/universal/StandardBridge.sol\";\nimport { ISemver } from \"src/universal/ISemver.sol\";\nimport { CrossDomainMessenger } from \"src/universal/CrossDomainMessenger.sol\";\nimport { SuperchainConfig } from \"src/L1/SuperchainConfig.sol\";\nimport { Constants } from \"src/libraries/Constants.sol\";\n\n/// @custom:proxied\n/// @title L1StandardBridge\n/// @notice The L1StandardBridge is responsible for transfering ETH and ERC20 tokens between L1 and\n///         L2. In the case that an ERC20 token is native to L1, it will be escrowed within this\n///         contract. If the ERC20 token is native to L2, it will be burnt. Before Bedrock, ETH was\n///         stored within this contract. After Bedrock, ETH is instead stored inside the\n///         OptimismPortal contract.\n///         NOTE: this contract is not intended to support all variations of ERC20 tokens. Examples\n///         of some token types that may not be properly supported by this contract include, but are\n///         not limited to: tokens with transfer fees, rebasing tokens, and tokens with blocklists.\ncontract L1StandardBridge is StandardBridge, ISemver {\n    /// @custom:legacy\n    /// @notice Emitted whenever a deposit of ETH from L1 into L2 is initiated.\n    /// @param from      Address of the depositor.\n    /// @param to        Address of the recipient on L2.\n    /// @param amount    Amount of ETH deposited.\n    /// @param extraData Extra data attached to the deposit.\n    event ETHDepositInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData);\n\n    /// @custom:legacy\n    /// @notice Emitted whenever a withdrawal of ETH from L2 to L1 is finalized.\n    /// @param from      Address of the withdrawer.\n    /// @param to        Address of the recipient on L1.\n    /// @param amount    Amount of ETH withdrawn.\n    /// @param extraData Extra data attached to the withdrawal.\n    event ETHWithdrawalFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData);\n\n    /// @custom:legacy\n    /// @notice Emitted whenever an ERC20 deposit is initiated.\n    /// @param l1Token   Address of the token on L1.\n    /// @param l2Token   Address of the corresponding token on L2.\n    /// @param from      Address of the depositor.\n    /// @param to        Address of the recipient on L2.\n    /// @param amount    Amount of the ERC20 deposited.\n    /// @param extraData Extra data attached to the deposit.\n    event ERC20DepositInitiated(\n        address indexed l1Token,\n        address indexed l2Token,\n        address indexed from,\n        address to,\n        uint256 amount,\n        bytes extraData\n    );\n\n    /// @custom:legacy\n    /// @notice Emitted whenever an ERC20 withdrawal is finalized.\n    /// @param l1Token   Address of the token on L1.\n    /// @param l2Token   Address of the corresponding token on L2.\n    /// @param from      Address of the withdrawer.\n    /// @param to        Address of the recipient on L1.\n    /// @param amount    Amount of the ERC20 withdrawn.\n    /// @param extraData Extra data attached to the withdrawal.\n    event ERC20WithdrawalFinalized(\n        address indexed l1Token,\n        address indexed l2Token,\n        address indexed from,\n        address to,\n        uint256 amount,\n        bytes extraData\n    );\n\n    /// @notice Semantic version.\n    /// @custom:semver 2.1.0\n    string public constant version = \"2.1.0\";\n\n    /// @notice Address of the SuperchainConfig contract.\n    SuperchainConfig public superchainConfig;\n\n    /// @notice Constructs the L1StandardBridge contract.\n    constructor() StandardBridge() {\n        initialize({ _messenger: CrossDomainMessenger(address(0)), _superchainConfig: SuperchainConfig(address(0)) });\n    }\n\n    /// @notice Initializer.\n    /// @param _messenger        Contract for the CrossDomainMessenger on this network.\n    /// @param _superchainConfig Contract for the SuperchainConfig on this network.\n    function initialize(CrossDomainMessenger _messenger, SuperchainConfig _superchainConfig) public initializer {\n        superchainConfig = _superchainConfig;\n        __StandardBridge_init({\n            _messenger: _messenger,\n            _otherBridge: StandardBridge(payable(Predeploys.L2_STANDARD_BRIDGE))\n        });\n    }\n\n    /// @inheritdoc StandardBridge\n    function paused() public view override returns (bool) {\n        return superchainConfig.paused();\n    }\n\n    /// @notice Allows EOAs to bridge ETH by sending directly to the bridge.\n    receive() external payable override onlyEOA {\n        _initiateETHDeposit(msg.sender, msg.sender, RECEIVE_DEFAULT_GAS_LIMIT, bytes(\"\"));\n    }\n\n    /// @custom:legacy\n    /// @notice Deposits some amount of ETH into the sender's account on L2.\n    /// @param _minGasLimit Minimum gas limit for the deposit message on L2.\n    /// @param _extraData   Optional data to forward to L2.\n    ///                     Data supplied here will not be used to execute any code on L2 and is\n    ///                     only emitted as extra data for the convenience of off-chain tooling.\n    function depositETH(uint32 _minGasLimit, bytes calldata _extraData) external payable onlyEOA {\n        _initiateETHDeposit(msg.sender, msg.sender, _minGasLimit, _extraData);\n    }\n\n    /// @custom:legacy\n    /// @notice Deposits some amount of ETH into a target account on L2.\n    ///         Note that if ETH is sent to a contract on L2 and the call fails, then that ETH will\n    ///         be locked in the L2StandardBridge. ETH may be recoverable if the call can be\n    ///         successfully replayed by increasing the amount of gas supplied to the call. If the\n    ///         call will fail for any amount of gas, then the ETH will be locked permanently.\n    /// @param _to          Address of the recipient on L2.\n    /// @param _minGasLimit Minimum gas limit for the deposit message on L2.\n    /// @param _extraData   Optional data to forward to L2.\n    ///                     Data supplied here will not be used to execute any code on L2 and is\n    ///                     only emitted as extra data for the convenience of off-chain tooling.\n    function depositETHTo(address _to, uint32 _minGasLimit, bytes calldata _extraData) external payable {\n        _initiateETHDeposit(msg.sender, _to, _minGasLimit, _extraData);\n    }\n\n    /// @custom:legacy\n    /// @notice Deposits some amount of ERC20 tokens into the sender's account on L2.\n    /// @param _l1Token     Address of the L1 token being deposited.\n    /// @param _l2Token     Address of the corresponding token on L2.\n    /// @param _amount      Amount of the ERC20 to deposit.\n    /// @param _minGasLimit Minimum gas limit for the deposit message on L2.\n    /// @param _extraData   Optional data to forward to L2.\n    ///                     Data supplied here will not be used to execute any code on L2 and is\n    ///                     only emitted as extra data for the convenience of off-chain tooling.\n    function depositERC20(\n        address _l1Token,\n        address _l2Token,\n        uint256 _amount,\n        uint32 _minGasLimit,\n        bytes calldata _extraData\n    )\n        external\n        virtual\n        onlyEOA\n    {\n        _initiateERC20Deposit(_l1Token, _l2Token, msg.sender, msg.sender, _amount, _minGasLimit, _extraData);\n    }\n\n    /// @custom:legacy\n    /// @notice Deposits some amount of ERC20 tokens into a target account on L2.\n    /// @param _l1Token     Address of the L1 token being deposited.\n    /// @param _l2Token     Address of the corresponding token on L2.\n    /// @param _to          Address of the recipient on L2.\n    /// @param _amount      Amount of the ERC20 to deposit.\n    /// @param _minGasLimit Minimum gas limit for the deposit message on L2.\n    /// @param _extraData   Optional data to forward to L2.\n    ///                     Data supplied here will not be used to execute any code on L2 and is\n    ///                     only emitted as extra data for the convenience of off-chain tooling.\n    function depositERC20To(\n        address _l1Token,\n        address _l2Token,\n        address _to,\n        uint256 _amount,\n        uint32 _minGasLimit,\n        bytes calldata _extraData\n    )\n        external\n        virtual\n    {\n        _initiateERC20Deposit(_l1Token, _l2Token, msg.sender, _to, _amount, _minGasLimit, _extraData);\n    }\n\n    /// @custom:legacy\n    /// @notice Finalizes a withdrawal of ETH from L2.\n    /// @param _from      Address of the withdrawer on L2.\n    /// @param _to        Address of the recipient on L1.\n    /// @param _amount    Amount of ETH to withdraw.\n    /// @param _extraData Optional data forwarded from L2.\n    function finalizeETHWithdrawal(\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes calldata _extraData\n    )\n        external\n        payable\n    {\n        finalizeBridgeETH(_from, _to, _amount, _extraData);\n    }\n\n    /// @custom:legacy\n    /// @notice Finalizes a withdrawal of ERC20 tokens from L2.\n    /// @param _l1Token   Address of the token on L1.\n    /// @param _l2Token   Address of the corresponding token on L2.\n    /// @param _from      Address of the withdrawer on L2.\n    /// @param _to        Address of the recipient on L1.\n    /// @param _amount    Amount of the ERC20 to withdraw.\n    /// @param _extraData Optional data forwarded from L2.\n    function finalizeERC20Withdrawal(\n        address _l1Token,\n        address _l2Token,\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes calldata _extraData\n    )\n        external\n    {\n        finalizeBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _extraData);\n    }\n\n    /// @custom:legacy\n    /// @notice Retrieves the access of the corresponding L2 bridge contract.\n    /// @return Address of the corresponding L2 bridge contract.\n    function l2TokenBridge() external view returns (address) {\n        return address(otherBridge);\n    }\n\n    /// @notice Internal function for initiating an ETH deposit.\n    /// @param _from        Address of the sender on L1.\n    /// @param _to          Address of the recipient on L2.\n    /// @param _minGasLimit Minimum gas limit for the deposit message on L2.\n    /// @param _extraData   Optional data to forward to L2.\n    function _initiateETHDeposit(address _from, address _to, uint32 _minGasLimit, bytes memory _extraData) internal {\n        _initiateBridgeETH(_from, _to, msg.value, _minGasLimit, _extraData);\n    }\n\n    /// @notice Internal function for initiating an ERC20 deposit.\n    /// @param _l1Token     Address of the L1 token being deposited.\n    /// @param _l2Token     Address of the corresponding token on L2.\n    /// @param _from        Address of the sender on L1.\n    /// @param _to          Address of the recipient on L2.\n    /// @param _amount      Amount of the ERC20 to deposit.\n    /// @param _minGasLimit Minimum gas limit for the deposit message on L2.\n    /// @param _extraData   Optional data to forward to L2.\n    function _initiateERC20Deposit(\n        address _l1Token,\n        address _l2Token,\n        address _from,\n        address _to,\n        uint256 _amount,\n        uint32 _minGasLimit,\n        bytes memory _extraData\n    )\n        internal\n    {\n        _initiateBridgeERC20(_l1Token, _l2Token, _from, _to, _amount, _minGasLimit, _extraData);\n    }\n\n    /// @inheritdoc StandardBridge\n    /// @notice Emits the legacy ETHDepositInitiated event followed by the ETHBridgeInitiated event.\n    ///         This is necessary for backwards compatibility with the legacy bridge.\n    function _emitETHBridgeInitiated(\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        override\n    {\n        emit ETHDepositInitiated(_from, _to, _amount, _extraData);\n        super._emitETHBridgeInitiated(_from, _to, _amount, _extraData);\n    }\n\n    /// @inheritdoc StandardBridge\n    /// @notice Emits the legacy ERC20DepositInitiated event followed by the ERC20BridgeInitiated\n    ///         event. This is necessary for backwards compatibility with the legacy bridge.\n    function _emitETHBridgeFinalized(\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        override\n    {\n        emit ETHWithdrawalFinalized(_from, _to, _amount, _extraData);\n        super._emitETHBridgeFinalized(_from, _to, _amount, _extraData);\n    }\n\n    /// @inheritdoc StandardBridge\n    /// @notice Emits the legacy ERC20WithdrawalFinalized event followed by the ERC20BridgeFinalized\n    ///         event. This is necessary for backwards compatibility with the legacy bridge.\n    function _emitERC20BridgeInitiated(\n        address _localToken,\n        address _remoteToken,\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        override\n    {\n        emit ERC20DepositInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n        super._emitERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n    }\n\n    /// @inheritdoc StandardBridge\n    /// @notice Emits the legacy ERC20WithdrawalFinalized event followed by the ERC20BridgeFinalized\n    ///         event. This is necessary for backwards compatibility with the legacy bridge.\n    function _emitERC20BridgeFinalized(\n        address _localToken,\n        address _remoteToken,\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        override\n    {\n        emit ERC20WithdrawalFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n        super._emitERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n    }\n}\n"
      },
      "src/libraries/Predeploys.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title Predeploys\n/// @notice Contains constant addresses for contracts that are pre-deployed to the L2 system.\nlibrary Predeploys {\n    /// @notice Address of the L2ToL1MessagePasser predeploy.\n    address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000016;\n\n    /// @notice Address of the L2CrossDomainMessenger predeploy.\n    address internal constant L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007;\n\n    /// @notice Address of the L2StandardBridge predeploy.\n    address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;\n\n    /// @notice Address of the L2ERC721Bridge predeploy.\n    address internal constant L2_ERC721_BRIDGE = 0x4200000000000000000000000000000000000014;\n\n    //// @notice Address of the SequencerFeeWallet predeploy.\n    address internal constant SEQUENCER_FEE_WALLET = 0x4200000000000000000000000000000000000011;\n\n    /// @notice Address of the OptimismMintableERC20Factory predeploy.\n    address internal constant OPTIMISM_MINTABLE_ERC20_FACTORY = 0x4200000000000000000000000000000000000012;\n\n    /// @notice Address of the OptimismMintableERC721Factory predeploy.\n    address internal constant OPTIMISM_MINTABLE_ERC721_FACTORY = 0x4200000000000000000000000000000000000017;\n\n    /// @notice Address of the L1Block predeploy.\n    address internal constant L1_BLOCK_ATTRIBUTES = 0x4200000000000000000000000000000000000015;\n\n    /// @notice Address of the GasPriceOracle predeploy. Includes fee information\n    ///         and helpers for computing the L1 portion of the transaction fee.\n    address internal constant GAS_PRICE_ORACLE = 0x420000000000000000000000000000000000000F;\n\n    /// @custom:legacy\n    /// @notice Address of the L1MessageSender predeploy. Deprecated. Use L2CrossDomainMessenger\n    ///         or access tx.origin (or msg.sender) in a L1 to L2 transaction instead.\n    address internal constant L1_MESSAGE_SENDER = 0x4200000000000000000000000000000000000001;\n\n    /// @custom:legacy\n    /// @notice Address of the DeployerWhitelist predeploy. No longer active.\n    address internal constant DEPLOYER_WHITELIST = 0x4200000000000000000000000000000000000002;\n\n    /// @notice Address of the canonical WETH9 contract.\n    address internal constant WETH9 = 0x4200000000000000000000000000000000000006;\n\n    /// @custom:legacy\n    /// @notice Address of the LegacyERC20ETH predeploy. Deprecated. Balances are migrated to the\n    ///         state trie as of the Bedrock upgrade. Contract has been locked and write functions\n    ///         can no longer be accessed.\n    address internal constant LEGACY_ERC20_ETH = 0xDeadDeAddeAddEAddeadDEaDDEAdDeaDDeAD0000;\n\n    /// @custom:legacy\n    /// @notice Address of the L1BlockNumber predeploy. Deprecated. Use the L1Block predeploy\n    ///         instead, which exposes more information about the L1 state.\n    address internal constant L1_BLOCK_NUMBER = 0x4200000000000000000000000000000000000013;\n\n    /// @custom:legacy\n    /// @notice Address of the LegacyMessagePasser predeploy. Deprecate. Use the updated\n    ///         L2ToL1MessagePasser contract instead.\n    address internal constant LEGACY_MESSAGE_PASSER = 0x4200000000000000000000000000000000000000;\n\n    /// @notice Address of the ProxyAdmin predeploy.\n    address internal constant PROXY_ADMIN = 0x4200000000000000000000000000000000000018;\n\n    /// @notice Address of the BaseFeeVault predeploy.\n    address internal constant BASE_FEE_VAULT = 0x4200000000000000000000000000000000000019;\n\n    /// @notice Address of the L1FeeVault predeploy.\n    address internal constant L1_FEE_VAULT = 0x420000000000000000000000000000000000001A;\n\n    /// @notice Address of the GovernanceToken predeploy.\n    address internal constant GOVERNANCE_TOKEN = 0x4200000000000000000000000000000000000042;\n\n    /// @notice Address of the SchemaRegistry predeploy.\n    address internal constant SCHEMA_REGISTRY = 0x4200000000000000000000000000000000000020;\n\n    /// @notice Address of the EAS predeploy.\n    address internal constant EAS = 0x4200000000000000000000000000000000000021;\n\n    /// @notice Address of the MultiCall3 predeploy.\n    address internal constant MultiCall3 = 0xcA11bde05977b3631167028862bE2a173976CA11;\n\n    /// @notice Address of the Create2Deployer predeploy.\n    address internal constant Create2Deployer = 0x13b0D85CcB8bf860b6b79AF3029fCA081AE9beF2;\n\n    /// @notice Address of the Safe_v130 predeploy.\n    address internal constant Safe_v130 = 0x69f4D1788e39c87893C980c06EdF4b7f686e2938;\n\n    /// @notice Address of the SafeL2_v130 predeploy.\n    address internal constant SafeL2_v130 = 0xfb1bffC9d739B8D520DaF37dF666da4C687191EA;\n\n    /// @notice Address of the MultiSendCallOnly_v130 predeploy.\n    address internal constant MultiSendCallOnly_v130 = 0xA1dabEF33b3B82c7814B6D82A79e50F4AC44102B;\n\n    /// @notice Address of the SafeSingletonFactory predeploy.\n    address internal constant SafeSingletonFactory = 0x914d7Fec6aaC8cd542e72Bca78B30650d45643d7;\n\n    /// @notice Address of the DeterministicDeploymentProxy predeploy.\n    address internal constant DeterministicDeploymentProxy = 0x4e59b44847b379578588920cA78FbF26c0B4956C;\n\n    /// @notice Address of the MultiSend_v130 predeploy.\n    address internal constant MultiSend_v130 = 0x998739BFdAAdde7C933B942a68053933098f9EDa;\n\n    /// @notice Address of the Permit2 predeploy.\n    address internal constant Permit2 = 0x000000000022D473030F116dDEE9F6B43aC78BA3;\n\n    /// @notice Address of the SenderCreator predeploy.\n    address internal constant SenderCreator = 0x7fc98430eAEdbb6070B35B39D798725049088348;\n\n    /// @notice Address of the EntryPoint predeploy.\n    address internal constant EntryPoint = 0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789;\n}\n"
      },
      "src/universal/StandardBridge.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { ERC165Checker } from \"@openzeppelin/contracts/utils/introspection/ERC165Checker.sol\";\nimport { Address } from \"@openzeppelin/contracts/utils/Address.sol\";\nimport { SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { SafeCall } from \"src/libraries/SafeCall.sol\";\nimport { IOptimismMintableERC20, ILegacyMintableERC20 } from \"src/universal/IOptimismMintableERC20.sol\";\nimport { CrossDomainMessenger } from \"src/universal/CrossDomainMessenger.sol\";\nimport { OptimismMintableERC20 } from \"src/universal/OptimismMintableERC20.sol\";\nimport { Initializable } from \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\n\n/// @custom:upgradeable\n/// @title StandardBridge\n/// @notice StandardBridge is a base contract for the L1 and L2 standard ERC20 bridges. It handles\n///         the core bridging logic, including escrowing tokens that are native to the local chain\n///         and minting/burning tokens that are native to the remote chain.\nabstract contract StandardBridge is Initializable {\n    using SafeERC20 for IERC20;\n\n    /// @notice The L2 gas limit set when eth is depoisited using the receive() function.\n    uint32 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 200_000;\n\n    /// @custom:legacy\n    /// @custom:spacer messenger\n    /// @notice Spacer for backwards compatibility.\n    bytes30 private spacer_0_2_30;\n\n    /// @custom:legacy\n    /// @custom:spacer l2TokenBridge\n    /// @notice Spacer for backwards compatibility.\n    address private spacer_1_0_20;\n\n    /// @notice Mapping that stores deposits for a given pair of local and remote tokens.\n    mapping(address => mapping(address => uint256)) public deposits;\n\n    /// @notice Messenger contract on this domain.\n    /// @custom:network-specific\n    CrossDomainMessenger public messenger;\n\n    /// @notice Corresponding bridge on the other domain.\n    /// @custom:network-specific\n    StandardBridge public otherBridge;\n\n    /// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.\n    ///         A gap size of 45 was chosen here, so that the first slot used in a child contract\n    ///         would be a multiple of 50.\n    uint256[45] private __gap;\n\n    /// @notice Emitted when an ETH bridge is initiated to the other chain.\n    /// @param from      Address of the sender.\n    /// @param to        Address of the receiver.\n    /// @param amount    Amount of ETH sent.\n    /// @param extraData Extra data sent with the transaction.\n    event ETHBridgeInitiated(address indexed from, address indexed to, uint256 amount, bytes extraData);\n\n    /// @notice Emitted when an ETH bridge is finalized on this chain.\n    /// @param from      Address of the sender.\n    /// @param to        Address of the receiver.\n    /// @param amount    Amount of ETH sent.\n    /// @param extraData Extra data sent with the transaction.\n    event ETHBridgeFinalized(address indexed from, address indexed to, uint256 amount, bytes extraData);\n\n    /// @notice Emitted when an ERC20 bridge is initiated to the other chain.\n    /// @param localToken  Address of the ERC20 on this chain.\n    /// @param remoteToken Address of the ERC20 on the remote chain.\n    /// @param from        Address of the sender.\n    /// @param to          Address of the receiver.\n    /// @param amount      Amount of the ERC20 sent.\n    /// @param extraData   Extra data sent with the transaction.\n    event ERC20BridgeInitiated(\n        address indexed localToken,\n        address indexed remoteToken,\n        address indexed from,\n        address to,\n        uint256 amount,\n        bytes extraData\n    );\n\n    /// @notice Emitted when an ERC20 bridge is finalized on this chain.\n    /// @param localToken  Address of the ERC20 on this chain.\n    /// @param remoteToken Address of the ERC20 on the remote chain.\n    /// @param from        Address of the sender.\n    /// @param to          Address of the receiver.\n    /// @param amount      Amount of the ERC20 sent.\n    /// @param extraData   Extra data sent with the transaction.\n    event ERC20BridgeFinalized(\n        address indexed localToken,\n        address indexed remoteToken,\n        address indexed from,\n        address to,\n        uint256 amount,\n        bytes extraData\n    );\n\n    /// @notice Only allow EOAs to call the functions. Note that this is not safe against contracts\n    ///         calling code within their constructors, but also doesn't really matter since we're\n    ///         just trying to prevent users accidentally depositing with smart contract wallets.\n    modifier onlyEOA() {\n        require(!Address.isContract(msg.sender), \"StandardBridge: function can only be called from an EOA\");\n        _;\n    }\n\n    /// @notice Ensures that the caller is a cross-chain message from the other bridge.\n    modifier onlyOtherBridge() {\n        require(\n            msg.sender == address(messenger) && messenger.xDomainMessageSender() == address(otherBridge),\n            \"StandardBridge: function can only be called from the other bridge\"\n        );\n        _;\n    }\n\n    /// @notice Initializer.\n    /// @param _messenger   Contract for CrossDomainMessenger on this network.\n    /// @param _otherBridge Contract for the other StandardBridge contract.\n    // solhint-disable-next-line func-name-mixedcase\n    function __StandardBridge_init(\n        CrossDomainMessenger _messenger,\n        StandardBridge _otherBridge\n    )\n        internal\n        onlyInitializing\n    {\n        messenger = _messenger;\n        otherBridge = _otherBridge;\n    }\n\n    /// @notice Allows EOAs to bridge ETH by sending directly to the bridge.\n    ///         Must be implemented by contracts that inherit.\n    receive() external payable virtual;\n\n    /// @notice Getter for messenger contract.\n    ///         Public getter is legacy and will be removed in the future. Use `messenger` instead.\n    /// @return Contract of the messenger on this domain.\n    /// @custom:legacy\n    function MESSENGER() external view returns (CrossDomainMessenger) {\n        return messenger;\n    }\n\n    /// @notice Getter for the other bridge contract.\n    ///         Public getter is legacy and will be removed in the future. Use `otherBridge` instead.\n    /// @return Contract of the bridge on the other network.\n    /// @custom:legacy\n    function OTHER_BRIDGE() external view returns (StandardBridge) {\n        return otherBridge;\n    }\n\n    /// @notice This function should return true if the contract is paused.\n    ///         On L1 this function will check the SuperchainConfig for its paused status.\n    ///         On L2 this function should be a no-op.\n    /// @return Whether or not the contract is paused.\n    function paused() public view virtual returns (bool) {\n        return false;\n    }\n\n    /// @notice Sends ETH to the sender's address on the other chain.\n    /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.\n    /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will\n    ///                     not be triggered with this data, but it will be emitted and can be used\n    ///                     to identify the transaction.\n    function bridgeETH(uint32 _minGasLimit, bytes calldata _extraData) public payable onlyEOA {\n        _initiateBridgeETH(msg.sender, msg.sender, msg.value, _minGasLimit, _extraData);\n    }\n\n    /// @notice Sends ETH to a receiver's address on the other chain. Note that if ETH is sent to a\n    ///         smart contract and the call fails, the ETH will be temporarily locked in the\n    ///         StandardBridge on the other chain until the call is replayed. If the call cannot be\n    ///         replayed with any amount of gas (call always reverts), then the ETH will be\n    ///         permanently locked in the StandardBridge on the other chain. ETH will also\n    ///         be locked if the receiver is the other bridge, because finalizeBridgeETH will revert\n    ///         in that case.\n    /// @param _to          Address of the receiver.\n    /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.\n    /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will\n    ///                     not be triggered with this data, but it will be emitted and can be used\n    ///                     to identify the transaction.\n    function bridgeETHTo(address _to, uint32 _minGasLimit, bytes calldata _extraData) public payable {\n        _initiateBridgeETH(msg.sender, _to, msg.value, _minGasLimit, _extraData);\n    }\n\n    /// @notice Sends ERC20 tokens to the sender's address on the other chain. Note that if the\n    ///         ERC20 token on the other chain does not recognize the local token as the correct\n    ///         pair token, the ERC20 bridge will fail and the tokens will be returned to sender on\n    ///         this chain.\n    /// @param _localToken  Address of the ERC20 on this chain.\n    /// @param _remoteToken Address of the corresponding token on the remote chain.\n    /// @param _amount      Amount of local tokens to deposit.\n    /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.\n    /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will\n    ///                     not be triggered with this data, but it will be emitted and can be used\n    ///                     to identify the transaction.\n    function bridgeERC20(\n        address _localToken,\n        address _remoteToken,\n        uint256 _amount,\n        uint32 _minGasLimit,\n        bytes calldata _extraData\n    )\n        public\n        virtual\n        onlyEOA\n    {\n        _initiateBridgeERC20(_localToken, _remoteToken, msg.sender, msg.sender, _amount, _minGasLimit, _extraData);\n    }\n\n    /// @notice Sends ERC20 tokens to a receiver's address on the other chain. Note that if the\n    ///         ERC20 token on the other chain does not recognize the local token as the correct\n    ///         pair token, the ERC20 bridge will fail and the tokens will be returned to sender on\n    ///         this chain.\n    /// @param _localToken  Address of the ERC20 on this chain.\n    /// @param _remoteToken Address of the corresponding token on the remote chain.\n    /// @param _to          Address of the receiver.\n    /// @param _amount      Amount of local tokens to deposit.\n    /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.\n    /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will\n    ///                     not be triggered with this data, but it will be emitted and can be used\n    ///                     to identify the transaction.\n    function bridgeERC20To(\n        address _localToken,\n        address _remoteToken,\n        address _to,\n        uint256 _amount,\n        uint32 _minGasLimit,\n        bytes calldata _extraData\n    )\n        public\n        virtual\n    {\n        _initiateBridgeERC20(_localToken, _remoteToken, msg.sender, _to, _amount, _minGasLimit, _extraData);\n    }\n\n    /// @notice Finalizes an ETH bridge on this chain. Can only be triggered by the other\n    ///         StandardBridge contract on the remote chain.\n    /// @param _from      Address of the sender.\n    /// @param _to        Address of the receiver.\n    /// @param _amount    Amount of ETH being bridged.\n    /// @param _extraData Extra data to be sent with the transaction. Note that the recipient will\n    ///                   not be triggered with this data, but it will be emitted and can be used\n    ///                   to identify the transaction.\n    function finalizeBridgeETH(\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes calldata _extraData\n    )\n        public\n        payable\n        onlyOtherBridge\n    {\n        require(paused() == false, \"StandardBridge: paused\");\n        require(msg.value == _amount, \"StandardBridge: amount sent does not match amount required\");\n        require(_to != address(this), \"StandardBridge: cannot send to self\");\n        require(_to != address(messenger), \"StandardBridge: cannot send to messenger\");\n\n        // Emit the correct events. By default this will be _amount, but child\n        // contracts may override this function in order to emit legacy events as well.\n        _emitETHBridgeFinalized(_from, _to, _amount, _extraData);\n\n        bool success = SafeCall.call(_to, gasleft(), _amount, hex\"\");\n        require(success, \"StandardBridge: ETH transfer failed\");\n    }\n\n    /// @notice Finalizes an ERC20 bridge on this chain. Can only be triggered by the other\n    ///         StandardBridge contract on the remote chain.\n    /// @param _localToken  Address of the ERC20 on this chain.\n    /// @param _remoteToken Address of the corresponding token on the remote chain.\n    /// @param _from        Address of the sender.\n    /// @param _to          Address of the receiver.\n    /// @param _amount      Amount of the ERC20 being bridged.\n    /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will\n    ///                     not be triggered with this data, but it will be emitted and can be used\n    ///                     to identify the transaction.\n    function finalizeBridgeERC20(\n        address _localToken,\n        address _remoteToken,\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes calldata _extraData\n    )\n        public\n        onlyOtherBridge\n    {\n        require(paused() == false, \"StandardBridge: paused\");\n        if (_isOptimismMintableERC20(_localToken)) {\n            require(\n                _isCorrectTokenPair(_localToken, _remoteToken),\n                \"StandardBridge: wrong remote token for Optimism Mintable ERC20 local token\"\n            );\n\n            OptimismMintableERC20(_localToken).mint(_to, _amount);\n        } else {\n            deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] - _amount;\n            IERC20(_localToken).safeTransfer(_to, _amount);\n        }\n\n        // Emit the correct events. By default this will be ERC20BridgeFinalized, but child\n        // contracts may override this function in order to emit legacy events as well.\n        _emitERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n    }\n\n    /// @notice Initiates a bridge of ETH through the CrossDomainMessenger.\n    /// @param _from        Address of the sender.\n    /// @param _to          Address of the receiver.\n    /// @param _amount      Amount of ETH being bridged.\n    /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.\n    /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will\n    ///                     not be triggered with this data, but it will be emitted and can be used\n    ///                     to identify the transaction.\n    function _initiateBridgeETH(\n        address _from,\n        address _to,\n        uint256 _amount,\n        uint32 _minGasLimit,\n        bytes memory _extraData\n    )\n        internal\n    {\n        require(msg.value == _amount, \"StandardBridge: bridging ETH must include sufficient ETH value\");\n\n        // Emit the correct events. By default this will be _amount, but child\n        // contracts may override this function in order to emit legacy events as well.\n        _emitETHBridgeInitiated(_from, _to, _amount, _extraData);\n\n        messenger.sendMessage{ value: _amount }({\n            _target: address(otherBridge),\n            _message: abi.encodeWithSelector(this.finalizeBridgeETH.selector, _from, _to, _amount, _extraData),\n            _minGasLimit: _minGasLimit\n        });\n    }\n\n    /// @notice Sends ERC20 tokens to a receiver's address on the other chain.\n    /// @param _localToken  Address of the ERC20 on this chain.\n    /// @param _remoteToken Address of the corresponding token on the remote chain.\n    /// @param _to          Address of the receiver.\n    /// @param _amount      Amount of local tokens to deposit.\n    /// @param _minGasLimit Minimum amount of gas that the bridge can be relayed with.\n    /// @param _extraData   Extra data to be sent with the transaction. Note that the recipient will\n    ///                     not be triggered with this data, but it will be emitted and can be used\n    ///                     to identify the transaction.\n    function _initiateBridgeERC20(\n        address _localToken,\n        address _remoteToken,\n        address _from,\n        address _to,\n        uint256 _amount,\n        uint32 _minGasLimit,\n        bytes memory _extraData\n    )\n        internal\n    {\n        if (_isOptimismMintableERC20(_localToken)) {\n            require(\n                _isCorrectTokenPair(_localToken, _remoteToken),\n                \"StandardBridge: wrong remote token for Optimism Mintable ERC20 local token\"\n            );\n\n            OptimismMintableERC20(_localToken).burn(_from, _amount);\n        } else {\n            IERC20(_localToken).safeTransferFrom(_from, address(this), _amount);\n            deposits[_localToken][_remoteToken] = deposits[_localToken][_remoteToken] + _amount;\n        }\n\n        // Emit the correct events. By default this will be ERC20BridgeInitiated, but child\n        // contracts may override this function in order to emit legacy events as well.\n        _emitERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n\n        messenger.sendMessage({\n            _target: address(otherBridge),\n            _message: abi.encodeWithSelector(\n                this.finalizeBridgeERC20.selector,\n                // Because this call will be executed on the remote chain, we reverse the order of\n                // the remote and local token addresses relative to their order in the\n                // finalizeBridgeERC20 function.\n                _remoteToken,\n                _localToken,\n                _from,\n                _to,\n                _amount,\n                _extraData\n                ),\n            _minGasLimit: _minGasLimit\n        });\n    }\n\n    /// @notice Checks if a given address is an OptimismMintableERC20. Not perfect, but good enough.\n    ///         Just the way we like it.\n    /// @param _token Address of the token to check.\n    /// @return True if the token is an OptimismMintableERC20.\n    function _isOptimismMintableERC20(address _token) internal view returns (bool) {\n        return ERC165Checker.supportsInterface(_token, type(ILegacyMintableERC20).interfaceId)\n            || ERC165Checker.supportsInterface(_token, type(IOptimismMintableERC20).interfaceId);\n    }\n\n    /// @notice Checks if the \"other token\" is the correct pair token for the OptimismMintableERC20.\n    ///         Calls can be saved in the future by combining this logic with\n    ///         `_isOptimismMintableERC20`.\n    /// @param _mintableToken OptimismMintableERC20 to check against.\n    /// @param _otherToken    Pair token to check.\n    /// @return True if the other token is the correct pair token for the OptimismMintableERC20.\n    function _isCorrectTokenPair(address _mintableToken, address _otherToken) internal view returns (bool) {\n        if (ERC165Checker.supportsInterface(_mintableToken, type(ILegacyMintableERC20).interfaceId)) {\n            return _otherToken == ILegacyMintableERC20(_mintableToken).l1Token();\n        } else {\n            return _otherToken == IOptimismMintableERC20(_mintableToken).remoteToken();\n        }\n    }\n\n    /// @notice Emits the ETHBridgeInitiated event and if necessary the appropriate legacy event\n    ///         when an ETH bridge is finalized on this chain.\n    /// @param _from      Address of the sender.\n    /// @param _to        Address of the receiver.\n    /// @param _amount    Amount of ETH sent.\n    /// @param _extraData Extra data sent with the transaction.\n    function _emitETHBridgeInitiated(\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        virtual\n    {\n        emit ETHBridgeInitiated(_from, _to, _amount, _extraData);\n    }\n\n    /// @notice Emits the ETHBridgeFinalized and if necessary the appropriate legacy event when an\n    ///         ETH bridge is finalized on this chain.\n    /// @param _from      Address of the sender.\n    /// @param _to        Address of the receiver.\n    /// @param _amount    Amount of ETH sent.\n    /// @param _extraData Extra data sent with the transaction.\n    function _emitETHBridgeFinalized(\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        virtual\n    {\n        emit ETHBridgeFinalized(_from, _to, _amount, _extraData);\n    }\n\n    /// @notice Emits the ERC20BridgeInitiated event and if necessary the appropriate legacy\n    ///         event when an ERC20 bridge is initiated to the other chain.\n    /// @param _localToken  Address of the ERC20 on this chain.\n    /// @param _remoteToken Address of the ERC20 on the remote chain.\n    /// @param _from        Address of the sender.\n    /// @param _to          Address of the receiver.\n    /// @param _amount      Amount of the ERC20 sent.\n    /// @param _extraData   Extra data sent with the transaction.\n    function _emitERC20BridgeInitiated(\n        address _localToken,\n        address _remoteToken,\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        virtual\n    {\n        emit ERC20BridgeInitiated(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n    }\n\n    /// @notice Emits the ERC20BridgeFinalized event and if necessary the appropriate legacy\n    ///         event when an ERC20 bridge is initiated to the other chain.\n    /// @param _localToken  Address of the ERC20 on this chain.\n    /// @param _remoteToken Address of the ERC20 on the remote chain.\n    /// @param _from        Address of the sender.\n    /// @param _to          Address of the receiver.\n    /// @param _amount      Amount of the ERC20 sent.\n    /// @param _extraData   Extra data sent with the transaction.\n    function _emitERC20BridgeFinalized(\n        address _localToken,\n        address _remoteToken,\n        address _from,\n        address _to,\n        uint256 _amount,\n        bytes memory _extraData\n    )\n        internal\n        virtual\n    {\n        emit ERC20BridgeFinalized(_localToken, _remoteToken, _from, _to, _amount, _extraData);\n    }\n}\n"
      },
      "src/universal/ISemver.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title ISemver\n/// @notice ISemver is a simple contract for ensuring that contracts are\n///         versioned using semantic versioning.\ninterface ISemver {\n    /// @notice Getter for the semantic version of the contract. This is not\n    ///         meant to be used onchain but instead meant to be used by offchain\n    ///         tooling.\n    /// @return Semver contract version as a string.\n    function version() external view returns (string memory);\n}\n"
      },
      "src/universal/CrossDomainMessenger.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { Initializable } from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport { SafeCall } from \"src/libraries/SafeCall.sol\";\nimport { Hashing } from \"src/libraries/Hashing.sol\";\nimport { Encoding } from \"src/libraries/Encoding.sol\";\nimport { Constants } from \"src/libraries/Constants.sol\";\n\n/// @custom:legacy\n/// @title CrossDomainMessengerLegacySpacer0\n/// @notice Contract only exists to add a spacer to the CrossDomainMessenger where the\n///         libAddressManager variable used to exist. Must be the first contract in the inheritance\n///         tree of the CrossDomainMessenger.\ncontract CrossDomainMessengerLegacySpacer0 {\n    /// @custom:legacy\n    /// @custom:spacer libAddressManager\n    /// @notice Spacer for backwards compatibility.\n    address private spacer_0_0_20;\n}\n\n/// @custom:legacy\n/// @title CrossDomainMessengerLegacySpacer1\n/// @notice Contract only exists to add a spacer to the CrossDomainMessenger where the\n///         PausableUpgradable and OwnableUpgradeable variables used to exist. Must be\n///         the third contract in the inheritance tree of the CrossDomainMessenger.\ncontract CrossDomainMessengerLegacySpacer1 {\n    /// @custom:legacy\n    /// @custom:spacer ContextUpgradable's __gap\n    /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin\n    ///         ContextUpgradable.\n    uint256[50] private spacer_1_0_1600;\n\n    /// @custom:legacy\n    /// @custom:spacer OwnableUpgradeable's _owner\n    /// @notice Spacer for backwards compatibility.\n    ///         Come from OpenZeppelin OwnableUpgradeable.\n    address private spacer_51_0_20;\n\n    /// @custom:legacy\n    /// @custom:spacer OwnableUpgradeable's __gap\n    /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin\n    ///         OwnableUpgradeable.\n    uint256[49] private spacer_52_0_1568;\n\n    /// @custom:legacy\n    /// @custom:spacer PausableUpgradable's _paused\n    /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin\n    ///         PausableUpgradable.\n    bool private spacer_101_0_1;\n\n    /// @custom:legacy\n    /// @custom:spacer PausableUpgradable's __gap\n    /// @notice Spacer for backwards compatibility. Comes from OpenZeppelin\n    ///         PausableUpgradable.\n    uint256[49] private spacer_102_0_1568;\n\n    /// @custom:legacy\n    /// @custom:spacer ReentrancyGuardUpgradeable's `_status` field.\n    /// @notice Spacer for backwards compatibility.\n    uint256 private spacer_151_0_32;\n\n    /// @custom:legacy\n    /// @custom:spacer ReentrancyGuardUpgradeable's __gap\n    /// @notice Spacer for backwards compatibility.\n    uint256[49] private spacer_152_0_1568;\n\n    /// @custom:legacy\n    /// @custom:spacer blockedMessages\n    /// @notice Spacer for backwards compatibility.\n    mapping(bytes32 => bool) private spacer_201_0_32;\n\n    /// @custom:legacy\n    /// @custom:spacer relayedMessages\n    /// @notice Spacer for backwards compatibility.\n    mapping(bytes32 => bool) private spacer_202_0_32;\n}\n\n/// @custom:upgradeable\n/// @title CrossDomainMessenger\n/// @notice CrossDomainMessenger is a base contract that provides the core logic for the L1 and L2\n///         cross-chain messenger contracts. It's designed to be a universal interface that only\n///         needs to be extended slightly to provide low-level message passing functionality on each\n///         chain it's deployed on. Currently only designed for message passing between two paired\n///         chains and does not support one-to-many interactions.\n///         Any changes to this contract MUST result in a semver bump for contracts that inherit it.\nabstract contract CrossDomainMessenger is\n    CrossDomainMessengerLegacySpacer0,\n    Initializable,\n    CrossDomainMessengerLegacySpacer1\n{\n    /// @notice Current message version identifier.\n    uint16 public constant MESSAGE_VERSION = 1;\n\n    /// @notice Constant overhead added to the base gas for a message.\n    uint64 public constant RELAY_CONSTANT_OVERHEAD = 200_000;\n\n    /// @notice Numerator for dynamic overhead added to the base gas for a message.\n    uint64 public constant MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR = 64;\n\n    /// @notice Denominator for dynamic overhead added to the base gas for a message.\n    uint64 public constant MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR = 63;\n\n    /// @notice Extra gas added to base gas for each byte of calldata in a message.\n    uint64 public constant MIN_GAS_CALLDATA_OVERHEAD = 16;\n\n    /// @notice Gas reserved for performing the external call in `relayMessage`.\n    uint64 public constant RELAY_CALL_OVERHEAD = 40_000;\n\n    /// @notice Gas reserved for finalizing the execution of `relayMessage` after the safe call.\n    uint64 public constant RELAY_RESERVED_GAS = 40_000;\n\n    /// @notice Gas reserved for the execution between the `hasMinGas` check and the external\n    ///         call in `relayMessage`.\n    uint64 public constant RELAY_GAS_CHECK_BUFFER = 5_000;\n\n    /// @notice Mapping of message hashes to boolean receipt values. Note that a message will only\n    ///         be present in this mapping if it has successfully been relayed on this chain, and\n    ///         can therefore not be relayed again.\n    mapping(bytes32 => bool) public successfulMessages;\n\n    /// @notice Address of the sender of the currently executing message on the other chain. If the\n    ///         value of this variable is the default value (0x00000000...dead) then no message is\n    ///         currently being executed. Use the xDomainMessageSender getter which will throw an\n    ///         error if this is the case.\n    address internal xDomainMsgSender;\n\n    /// @notice Nonce for the next message to be sent, without the message version applied. Use the\n    ///         messageNonce getter which will insert the message version into the nonce to give you\n    ///         the actual nonce to be used for the message.\n    uint240 internal msgNonce;\n\n    /// @notice Mapping of message hashes to a boolean if and only if the message has failed to be\n    ///         executed at least once. A message will not be present in this mapping if it\n    ///         successfully executed on the first attempt.\n    mapping(bytes32 => bool) public failedMessages;\n\n    /// @notice CrossDomainMessenger contract on the other chain.\n    /// @custom:network-specific\n    CrossDomainMessenger public otherMessenger;\n\n    /// @notice Reserve extra slots in the storage layout for future upgrades.\n    ///         A gap size of 43 was chosen here, so that the first slot used in a child contract\n    ///         would be 1 plus a multiple of 50.\n    uint256[43] private __gap;\n\n    /// @notice Emitted whenever a message is sent to the other chain.\n    /// @param target       Address of the recipient of the message.\n    /// @param sender       Address of the sender of the message.\n    /// @param message      Message to trigger the recipient address with.\n    /// @param messageNonce Unique nonce attached to the message.\n    /// @param gasLimit     Minimum gas limit that the message can be executed with.\n    event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit);\n\n    /// @notice Additional event data to emit, required as of Bedrock. Cannot be merged with the\n    ///         SentMessage event without breaking the ABI of this contract, this is good enough.\n    /// @param sender Address of the sender of the message.\n    /// @param value  ETH value sent along with the message to the recipient.\n    event SentMessageExtension1(address indexed sender, uint256 value);\n\n    /// @notice Emitted whenever a message is successfully relayed on this chain.\n    /// @param msgHash Hash of the message that was relayed.\n    event RelayedMessage(bytes32 indexed msgHash);\n\n    /// @notice Emitted whenever a message fails to be relayed on this chain.\n    /// @param msgHash Hash of the message that failed to be relayed.\n    event FailedRelayedMessage(bytes32 indexed msgHash);\n\n    /// @notice Sends a message to some target address on the other chain. Note that if the call\n    ///         always reverts, then the message will be unrelayable, and any ETH sent will be\n    ///         permanently locked. The same will occur if the target on the other chain is\n    ///         considered unsafe (see the _isUnsafeTarget() function).\n    /// @param _target      Target contract or wallet address.\n    /// @param _message     Message to trigger the target address with.\n    /// @param _minGasLimit Minimum gas limit that the message can be executed with.\n    function sendMessage(address _target, bytes calldata _message, uint32 _minGasLimit) external payable {\n        // Triggers a message to the other messenger. Note that the amount of gas provided to the\n        // message is the amount of gas requested by the user PLUS the base gas value. We want to\n        // guarantee the property that the call to the target contract will always have at least\n        // the minimum gas limit specified by the user.\n        _sendMessage({\n            _to: address(otherMessenger),\n            _gasLimit: baseGas(_message, _minGasLimit),\n            _value: msg.value,\n            _data: abi.encodeWithSelector(\n                this.relayMessage.selector, messageNonce(), msg.sender, _target, msg.value, _minGasLimit, _message\n                )\n        });\n\n        emit SentMessage(_target, msg.sender, _message, messageNonce(), _minGasLimit);\n        emit SentMessageExtension1(msg.sender, msg.value);\n\n        unchecked {\n            ++msgNonce;\n        }\n    }\n\n    /// @notice Relays a message that was sent by the other CrossDomainMessenger contract. Can only\n    ///         be executed via cross-chain call from the other messenger OR if the message was\n    ///         already received once and is currently being replayed.\n    /// @param _nonce       Nonce of the message being relayed.\n    /// @param _sender      Address of the user who sent the message.\n    /// @param _target      Address that the message is targeted at.\n    /// @param _value       ETH value to send with the message.\n    /// @param _minGasLimit Minimum amount of gas that the message can be executed with.\n    /// @param _message     Message to send to the target.\n    function relayMessage(\n        uint256 _nonce,\n        address _sender,\n        address _target,\n        uint256 _value,\n        uint256 _minGasLimit,\n        bytes calldata _message\n    )\n        external\n        payable\n    {\n        // On L1 this function will check the Portal for its paused status.\n        // On L2 this function should be a no-op, because paused will always return false.\n        require(paused() == false, \"CrossDomainMessenger: paused\");\n\n        (, uint16 version) = Encoding.decodeVersionedNonce(_nonce);\n        require(version < 2, \"CrossDomainMessenger: only version 0 or 1 messages are supported at this time\");\n\n        // If the message is version 0, then it's a migrated legacy withdrawal. We therefore need\n        // to check that the legacy version of the message has not already been relayed.\n        if (version == 0) {\n            bytes32 oldHash = Hashing.hashCrossDomainMessageV0(_target, _sender, _message, _nonce);\n            require(successfulMessages[oldHash] == false, \"CrossDomainMessenger: legacy withdrawal already relayed\");\n        }\n\n        // We use the v1 message hash as the unique identifier for the message because it commits\n        // to the value and minimum gas limit of the message.\n        bytes32 versionedHash =\n            Hashing.hashCrossDomainMessageV1(_nonce, _sender, _target, _value, _minGasLimit, _message);\n\n        if (_isOtherMessenger()) {\n            // These properties should always hold when the message is first submitted (as\n            // opposed to being replayed).\n            assert(msg.value == _value);\n            assert(!failedMessages[versionedHash]);\n        } else {\n            require(msg.value == 0, \"CrossDomainMessenger: value must be zero unless message is from a system address\");\n\n            require(failedMessages[versionedHash], \"CrossDomainMessenger: message cannot be replayed\");\n        }\n\n        require(\n            _isUnsafeTarget(_target) == false, \"CrossDomainMessenger: cannot send message to blocked system address\"\n        );\n\n        require(successfulMessages[versionedHash] == false, \"CrossDomainMessenger: message has already been relayed\");\n\n        // If there is not enough gas left to perform the external call and finish the execution,\n        // return early and assign the message to the failedMessages mapping.\n        // We are asserting that we have enough gas to:\n        // 1. Call the target contract (_minGasLimit + RELAY_CALL_OVERHEAD + RELAY_GAS_CHECK_BUFFER)\n        //   1.a. The RELAY_CALL_OVERHEAD is included in `hasMinGas`.\n        // 2. Finish the execution after the external call (RELAY_RESERVED_GAS).\n        //\n        // If `xDomainMsgSender` is not the default L2 sender, this function\n        // is being re-entered. This marks the message as failed to allow it to be replayed.\n        if (\n            !SafeCall.hasMinGas(_minGasLimit, RELAY_RESERVED_GAS + RELAY_GAS_CHECK_BUFFER)\n                || xDomainMsgSender != Constants.DEFAULT_L2_SENDER\n        ) {\n            failedMessages[versionedHash] = true;\n            emit FailedRelayedMessage(versionedHash);\n\n            // Revert in this case if the transaction was triggered by the estimation address. This\n            // should only be possible during gas estimation or we have bigger problems. Reverting\n            // here will make the behavior of gas estimation change such that the gas limit\n            // computed will be the amount required to relay the message, even if that amount is\n            // greater than the minimum gas limit specified by the user.\n            if (tx.origin == Constants.ESTIMATION_ADDRESS) {\n                revert(\"CrossDomainMessenger: failed to relay message\");\n            }\n\n            return;\n        }\n\n        xDomainMsgSender = _sender;\n        bool success = SafeCall.call(_target, gasleft() - RELAY_RESERVED_GAS, _value, _message);\n        xDomainMsgSender = Constants.DEFAULT_L2_SENDER;\n\n        if (success) {\n            // This check is identical to one above, but it ensures that the same message cannot be relayed\n            // twice, and adds a layer of protection against rentrancy.\n            assert(successfulMessages[versionedHash] == false);\n            successfulMessages[versionedHash] = true;\n            emit RelayedMessage(versionedHash);\n        } else {\n            failedMessages[versionedHash] = true;\n            emit FailedRelayedMessage(versionedHash);\n\n            // Revert in this case if the transaction was triggered by the estimation address. This\n            // should only be possible during gas estimation or we have bigger problems. Reverting\n            // here will make the behavior of gas estimation change such that the gas limit\n            // computed will be the amount required to relay the message, even if that amount is\n            // greater than the minimum gas limit specified by the user.\n            if (tx.origin == Constants.ESTIMATION_ADDRESS) {\n                revert(\"CrossDomainMessenger: failed to relay message\");\n            }\n        }\n    }\n\n    /// @notice Retrieves the address of the contract or wallet that initiated the currently\n    ///         executing message on the other chain. Will throw an error if there is no message\n    ///         currently being executed. Allows the recipient of a call to see who triggered it.\n    /// @return Address of the sender of the currently executing message on the other chain.\n    function xDomainMessageSender() external view returns (address) {\n        require(\n            xDomainMsgSender != Constants.DEFAULT_L2_SENDER, \"CrossDomainMessenger: xDomainMessageSender is not set\"\n        );\n\n        return xDomainMsgSender;\n    }\n\n    /// @notice Retrieves the address of the paired CrossDomainMessenger contract on the other chain\n    ///         Public getter is legacy and will be removed in the future. Use `otherMessenger()` instead.\n    /// @return CrossDomainMessenger contract on the other chain.\n    /// @custom:legacy\n    function OTHER_MESSENGER() public view returns (CrossDomainMessenger) {\n        return otherMessenger;\n    }\n\n    /// @notice Retrieves the next message nonce. Message version will be added to the upper two\n    ///         bytes of the message nonce. Message version allows us to treat messages as having\n    ///         different structures.\n    /// @return Nonce of the next message to be sent, with added message version.\n    function messageNonce() public view returns (uint256) {\n        return Encoding.encodeVersionedNonce(msgNonce, MESSAGE_VERSION);\n    }\n\n    /// @notice Computes the amount of gas required to guarantee that a given message will be\n    ///         received on the other chain without running out of gas. Guaranteeing that a message\n    ///         will not run out of gas is important because this ensures that a message can always\n    ///         be replayed on the other chain if it fails to execute completely.\n    /// @param _message     Message to compute the amount of required gas for.\n    /// @param _minGasLimit Minimum desired gas limit when message goes to target.\n    /// @return Amount of gas required to guarantee message receipt.\n    function baseGas(bytes calldata _message, uint32 _minGasLimit) public pure returns (uint64) {\n        return\n        // Constant overhead\n        RELAY_CONSTANT_OVERHEAD\n        // Calldata overhead\n        + (uint64(_message.length) * MIN_GAS_CALLDATA_OVERHEAD)\n        // Dynamic overhead (EIP-150)\n        + ((_minGasLimit * MIN_GAS_DYNAMIC_OVERHEAD_NUMERATOR) / MIN_GAS_DYNAMIC_OVERHEAD_DENOMINATOR)\n        // Gas reserved for the worst-case cost of 3/5 of the `CALL` opcode's dynamic gas\n        // factors. (Conservative)\n        + RELAY_CALL_OVERHEAD\n        // Relay reserved gas (to ensure execution of `relayMessage` completes after the\n        // subcontext finishes executing) (Conservative)\n        + RELAY_RESERVED_GAS\n        // Gas reserved for the execution between the `hasMinGas` check and the `CALL`\n        // opcode. (Conservative)\n        + RELAY_GAS_CHECK_BUFFER;\n    }\n\n    /// @notice Initializer.\n    /// @param _otherMessenger CrossDomainMessenger contract on the other chain.\n    // solhint-disable-next-line func-name-mixedcase\n    function __CrossDomainMessenger_init(CrossDomainMessenger _otherMessenger) internal onlyInitializing {\n        // We only want to set the xDomainMsgSender to the default value if it hasn't been initialized yet,\n        // meaning that this is a fresh contract deployment.\n        // This prevents resetting the xDomainMsgSender to the default value during an upgrade, which would enable\n        // a reentrant withdrawal to sandwhich the upgrade replay a withdrawal twice.\n        if (xDomainMsgSender == address(0)) {\n            xDomainMsgSender = Constants.DEFAULT_L2_SENDER;\n        }\n        otherMessenger = _otherMessenger;\n    }\n\n    /// @notice Sends a low-level message to the other messenger. Needs to be implemented by child\n    ///         contracts because the logic for this depends on the network where the messenger is\n    ///         being deployed.\n    /// @param _to       Recipient of the message on the other chain.\n    /// @param _gasLimit Minimum gas limit the message can be executed with.\n    /// @param _value    Amount of ETH to send with the message.\n    /// @param _data     Message data.\n    function _sendMessage(address _to, uint64 _gasLimit, uint256 _value, bytes memory _data) internal virtual;\n\n    /// @notice Checks whether the message is coming from the other messenger. Implemented by child\n    ///         contracts because the logic for this depends on the network where the messenger is\n    ///         being deployed.\n    /// @return Whether the message is coming from the other messenger.\n    function _isOtherMessenger() internal view virtual returns (bool);\n\n    /// @notice Checks whether a given call target is a system address that could cause the\n    ///         messenger to peform an unsafe action. This is NOT a mechanism for blocking user\n    ///         addresses. This is ONLY used to prevent the execution of messages to specific\n    ///         system addresses that could cause security issues, e.g., having the\n    ///         CrossDomainMessenger send messages to itself.\n    /// @param _target Address of the contract to check.\n    /// @return Whether or not the address is an unsafe system address.\n    function _isUnsafeTarget(address _target) internal view virtual returns (bool);\n\n    /// @notice This function should return true if the contract is paused.\n    ///         On L1 this function will check the SuperchainConfig for its paused status.\n    ///         On L2 this function should be a no-op.\n    /// @return Whether or not the contract is paused.\n    function paused() public view virtual returns (bool) {\n        return false;\n    }\n}\n"
      },
      "src/L1/SuperchainConfig.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { Initializable } from \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport { ISemver } from \"src/universal/ISemver.sol\";\nimport { Storage } from \"src/libraries/Storage.sol\";\n\n/// @custom:audit none This contracts is not yet audited.\n/// @title SuperchainConfig\n/// @notice The SuperchainConfig contract is used to manage configuration of global superchain values.\ncontract SuperchainConfig is Initializable, ISemver {\n    /// @notice Enum representing different types of updates.\n    /// @custom:value GUARDIAN            Represents an update to the guardian.\n    enum UpdateType {\n        GUARDIAN\n    }\n\n    /// @notice Whether or not the Superchain is paused.\n    bytes32 public constant PAUSED_SLOT = bytes32(uint256(keccak256(\"superchainConfig.paused\")) - 1);\n\n    /// @notice The address of the guardian, which can pause withdrawals from the System.\n    ///         It can only be modified by an upgrade.\n    bytes32 public constant GUARDIAN_SLOT = bytes32(uint256(keccak256(\"superchainConfig.guardian\")) - 1);\n\n    /// @notice Emitted when the pause is triggered.\n    /// @param identifier A string helping to identify provenance of the pause transaction.\n    event Paused(string identifier);\n\n    /// @notice Emitted when the pause is lifted.\n    event Unpaused();\n\n    /// @notice Emitted when configuration is updated.\n    /// @param updateType Type of update.\n    /// @param data       Encoded update data.\n    event ConfigUpdate(UpdateType indexed updateType, bytes data);\n\n    /// @notice Semantic version.\n    /// @custom:semver 1.1.0\n    string public constant version = \"1.1.0\";\n\n    /// @notice Constructs the SuperchainConfig contract.\n    constructor() {\n        initialize({ _guardian: address(0), _paused: false });\n    }\n\n    /// @notice Initializer.\n    /// @param _guardian    Address of the guardian, can pause the OptimismPortal.\n    /// @param _paused      Initial paused status.\n    function initialize(address _guardian, bool _paused) public initializer {\n        _setGuardian(_guardian);\n        if (_paused) {\n            _pause(\"Initializer paused\");\n        }\n    }\n\n    /// @notice Getter for the guardian address.\n    function guardian() public view returns (address guardian_) {\n        guardian_ = Storage.getAddress(GUARDIAN_SLOT);\n    }\n\n    /// @notice Getter for the current paused status.\n    function paused() public view returns (bool paused_) {\n        paused_ = Storage.getBool(PAUSED_SLOT);\n    }\n\n    /// @notice Pauses withdrawals.\n    /// @param _identifier (Optional) A string to identify provenance of the pause transaction.\n    function pause(string memory _identifier) external {\n        require(msg.sender == guardian(), \"SuperchainConfig: only guardian can pause\");\n        _pause(_identifier);\n    }\n\n    /// @notice Pauses withdrawals.\n    /// @param _identifier (Optional) A string to identify provenance of the pause transaction.\n    function _pause(string memory _identifier) internal {\n        Storage.setBool(PAUSED_SLOT, true);\n        emit Paused(_identifier);\n    }\n\n    /// @notice Unpauses withdrawals.\n    function unpause() external {\n        require(msg.sender == guardian(), \"SuperchainConfig: only guardian can unpause\");\n        Storage.setBool(PAUSED_SLOT, false);\n        emit Unpaused();\n    }\n\n    /// @notice Sets the guardian address. This is only callable during initialization, so an upgrade\n    ///         will be required to change the guardian.\n    /// @param _guardian The new guardian address.\n    function _setGuardian(address _guardian) internal {\n        Storage.setAddress(GUARDIAN_SLOT, _guardian);\n        emit ConfigUpdate(UpdateType.GUARDIAN, abi.encode(_guardian));\n    }\n}\n"
      },
      "src/libraries/Constants.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { ResourceMetering } from \"src/L1/ResourceMetering.sol\";\n\n/// @title Constants\n/// @notice Constants is a library for storing constants. Simple! Don't put everything in here, just\n///         the stuff used in multiple contracts. Constants that only apply to a single contract\n///         should be defined in that contract instead.\nlibrary Constants {\n    /// @notice Special address to be used as the tx origin for gas estimation calls in the\n    ///         OptimismPortal and CrossDomainMessenger calls. You only need to use this address if\n    ///         the minimum gas limit specified by the user is not actually enough to execute the\n    ///         given message and you're attempting to estimate the actual necessary gas limit. We\n    ///         use address(1) because it's the ecrecover precompile and therefore guaranteed to\n    ///         never have any code on any EVM chain.\n    address internal constant ESTIMATION_ADDRESS = address(1);\n\n    /// @notice Value used for the L2 sender storage slot in both the OptimismPortal and the\n    ///         CrossDomainMessenger contracts before an actual sender is set. This value is\n    ///         non-zero to reduce the gas cost of message passing transactions.\n    address internal constant DEFAULT_L2_SENDER = 0x000000000000000000000000000000000000dEaD;\n\n    /// @notice The storage slot that holds the address of a proxy implementation.\n    /// @dev `bytes32(uint256(keccak256('eip1967.proxy.implementation')) - 1)`\n    bytes32 internal constant PROXY_IMPLEMENTATION_ADDRESS =\n        0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /// @notice The storage slot that holds the address of the owner.\n    /// @dev `bytes32(uint256(keccak256('eip1967.proxy.admin')) - 1)`\n    bytes32 internal constant PROXY_OWNER_ADDRESS = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /// @notice Returns the default values for the ResourceConfig. These are the recommended values\n    ///         for a production network.\n    function DEFAULT_RESOURCE_CONFIG() internal pure returns (ResourceMetering.ResourceConfig memory) {\n        ResourceMetering.ResourceConfig memory config = ResourceMetering.ResourceConfig({\n            maxResourceLimit: 20_000_000,\n            elasticityMultiplier: 10,\n            baseFeeMaxChangeDenominator: 8,\n            minimumBaseFee: 1 gwei,\n            systemTxMaxGas: 1_000_000,\n            maximumBaseFee: type(uint128).max\n        });\n        return config;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/introspection/ERC165Checker.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.2) (utils/introspection/ERC165Checker.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Library used to query support of an interface declared via {IERC165}.\n *\n * Note that these functions return the actual result of the query: they do not\n * `revert` if an interface is not supported. It is up to the caller to decide\n * what to do in these cases.\n */\nlibrary ERC165Checker {\n    // As per the EIP-165 spec, no interface should ever match 0xffffffff\n    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;\n\n    /**\n     * @dev Returns true if `account` supports the {IERC165} interface,\n     */\n    function supportsERC165(address account) internal view returns (bool) {\n        // Any contract that implements ERC165 must explicitly indicate support of\n        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid\n        return\n            _supportsERC165Interface(account, type(IERC165).interfaceId) &&\n            !_supportsERC165Interface(account, _INTERFACE_ID_INVALID);\n    }\n\n    /**\n     * @dev Returns true if `account` supports the interface defined by\n     * `interfaceId`. Support for {IERC165} itself is queried automatically.\n     *\n     * See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {\n        // query support of both ERC165 as per the spec and support of _interfaceId\n        return supportsERC165(account) && _supportsERC165Interface(account, interfaceId);\n    }\n\n    /**\n     * @dev Returns a boolean array where each value corresponds to the\n     * interfaces passed in and whether they're supported or not. This allows\n     * you to batch check interfaces for a contract where your expectation\n     * is that some interfaces may not be supported.\n     *\n     * See {IERC165-supportsInterface}.\n     *\n     * _Available since v3.4._\n     */\n    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)\n        internal\n        view\n        returns (bool[] memory)\n    {\n        // an array of booleans corresponding to interfaceIds and whether they're supported or not\n        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);\n\n        // query support of ERC165 itself\n        if (supportsERC165(account)) {\n            // query support of each interface in interfaceIds\n            for (uint256 i = 0; i < interfaceIds.length; i++) {\n                interfaceIdsSupported[i] = _supportsERC165Interface(account, interfaceIds[i]);\n            }\n        }\n\n        return interfaceIdsSupported;\n    }\n\n    /**\n     * @dev Returns true if `account` supports all the interfaces defined in\n     * `interfaceIds`. Support for {IERC165} itself is queried automatically.\n     *\n     * Batch-querying can lead to gas savings by skipping repeated checks for\n     * {IERC165} support.\n     *\n     * See {IERC165-supportsInterface}.\n     */\n    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {\n        // query support of ERC165 itself\n        if (!supportsERC165(account)) {\n            return false;\n        }\n\n        // query support of each interface in _interfaceIds\n        for (uint256 i = 0; i < interfaceIds.length; i++) {\n            if (!_supportsERC165Interface(account, interfaceIds[i])) {\n                return false;\n            }\n        }\n\n        // all interfaces supported\n        return true;\n    }\n\n    /**\n     * @notice Query if a contract implements an interface, does not check ERC165 support\n     * @param account The address of the contract to query for support of an interface\n     * @param interfaceId The interface identifier, as specified in ERC-165\n     * @return true if the contract at account indicates support of the interface with\n     * identifier interfaceId, false otherwise\n     * @dev Assumes that account contains a contract that supports ERC165, otherwise\n     * the behavior of this method is undefined. This precondition can be checked\n     * with {supportsERC165}.\n     * Interface identification is specified in ERC-165.\n     */\n    function _supportsERC165Interface(address account, bytes4 interfaceId) private view returns (bool) {\n        // prepare call\n        bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);\n\n        // perform static call\n        bool success;\n        uint256 returnSize;\n        uint256 returnValue;\n        assembly {\n            success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)\n            returnSize := returndatasize()\n            returnValue := mload(0x00)\n        }\n\n        return success && returnSize >= 0x20 && returnValue > 0;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/draft-IERC20Permit.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    function safeTransfer(\n        IERC20 token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
      },
      "src/libraries/SafeCall.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\n/// @title SafeCall\n/// @notice Perform low level safe calls\nlibrary SafeCall {\n    /// @notice Performs a low level call without copying any returndata.\n    /// @dev Passes no calldata to the call context.\n    /// @param _target   Address to call\n    /// @param _gas      Amount of gas to pass to the call\n    /// @param _value    Amount of value to pass to the call\n    function send(address _target, uint256 _gas, uint256 _value) internal returns (bool) {\n        bool _success;\n        assembly {\n            _success :=\n                call(\n                    _gas, // gas\n                    _target, // recipient\n                    _value, // ether value\n                    0, // inloc\n                    0, // inlen\n                    0, // outloc\n                    0 // outlen\n                )\n        }\n        return _success;\n    }\n\n    /// @notice Perform a low level call without copying any returndata\n    /// @param _target   Address to call\n    /// @param _gas      Amount of gas to pass to the call\n    /// @param _value    Amount of value to pass to the call\n    /// @param _calldata Calldata to pass to the call\n    function call(address _target, uint256 _gas, uint256 _value, bytes memory _calldata) internal returns (bool) {\n        bool _success;\n        assembly {\n            _success :=\n                call(\n                    _gas, // gas\n                    _target, // recipient\n                    _value, // ether value\n                    add(_calldata, 32), // inloc\n                    mload(_calldata), // inlen\n                    0, // outloc\n                    0 // outlen\n                )\n        }\n        return _success;\n    }\n\n    /// @notice Helper function to determine if there is sufficient gas remaining within the context\n    ///         to guarantee that the minimum gas requirement for a call will be met as well as\n    ///         optionally reserving a specified amount of gas for after the call has concluded.\n    /// @param _minGas      The minimum amount of gas that may be passed to the target context.\n    /// @param _reservedGas Optional amount of gas to reserve for the caller after the execution\n    ///                     of the target context.\n    /// @return `true` if there is enough gas remaining to safely supply `_minGas` to the target\n    ///         context as well as reserve `_reservedGas` for the caller after the execution of\n    ///         the target context.\n    /// @dev !!!!! FOOTGUN ALERT !!!!!\n    ///      1.) The 40_000 base buffer is to account for the worst case of the dynamic cost of the\n    ///          `CALL` opcode's `address_access_cost`, `positive_value_cost`, and\n    ///          `value_to_empty_account_cost` factors with an added buffer of 5,700 gas. It is\n    ///          still possible to self-rekt by initiating a withdrawal with a minimum gas limit\n    ///          that does not account for the `memory_expansion_cost` & `code_execution_cost`\n    ///          factors of the dynamic cost of the `CALL` opcode.\n    ///      2.) This function should *directly* precede the external call if possible. There is an\n    ///          added buffer to account for gas consumed between this check and the call, but it\n    ///          is only 5,700 gas.\n    ///      3.) Because EIP-150 ensures that a maximum of 63/64ths of the remaining gas in the call\n    ///          frame may be passed to a subcontext, we need to ensure that the gas will not be\n    ///          truncated.\n    ///      4.) Use wisely. This function is not a silver bullet.\n    function hasMinGas(uint256 _minGas, uint256 _reservedGas) internal view returns (bool) {\n        bool _hasMinGas;\n        assembly {\n            // Equation: gas × 63 ≥ minGas × 64 + 63(40_000 + reservedGas)\n            _hasMinGas := iszero(lt(mul(gas(), 63), add(mul(_minGas, 64), mul(add(40000, _reservedGas), 63))))\n        }\n        return _hasMinGas;\n    }\n\n    /// @notice Perform a low level call without copying any returndata. This function\n    ///         will revert if the call cannot be performed with the specified minimum\n    ///         gas.\n    /// @param _target   Address to call\n    /// @param _minGas   The minimum amount of gas that may be passed to the call\n    /// @param _value    Amount of value to pass to the call\n    /// @param _calldata Calldata to pass to the call\n    function callWithMinGas(\n        address _target,\n        uint256 _minGas,\n        uint256 _value,\n        bytes memory _calldata\n    )\n        internal\n        returns (bool)\n    {\n        bool _success;\n        bool _hasMinGas = hasMinGas(_minGas, 0);\n        assembly {\n            // Assertion: gasleft() >= (_minGas * 64) / 63 + 40_000\n            if iszero(_hasMinGas) {\n                // Store the \"Error(string)\" selector in scratch space.\n                mstore(0, 0x08c379a0)\n                // Store the pointer to the string length in scratch space.\n                mstore(32, 32)\n                // Store the string.\n                //\n                // SAFETY:\n                // - We pad the beginning of the string with two zero bytes as well as the\n                // length (24) to ensure that we override the free memory pointer at offset\n                // 0x40. This is necessary because the free memory pointer is likely to\n                // be greater than 1 byte when this function is called, but it is incredibly\n                // unlikely that it will be greater than 3 bytes. As for the data within\n                // 0x60, it is ensured that it is 0 due to 0x60 being the zero offset.\n                // - It's fine to clobber the free memory pointer, we're reverting.\n                mstore(88, 0x0000185361666543616c6c3a204e6f7420656e6f75676820676173)\n\n                // Revert with 'Error(\"SafeCall: Not enough gas\")'\n                revert(28, 100)\n            }\n\n            // The call will be supplied at least ((_minGas * 64) / 63) gas due to the\n            // above assertion. This ensures that, in all circumstances (except for when the\n            // `_minGas` does not account for the `memory_expansion_cost` and `code_execution_cost`\n            // factors of the dynamic cost of the `CALL` opcode), the call will receive at least\n            // the minimum amount of gas specified.\n            _success :=\n                call(\n                    gas(), // gas\n                    _target, // recipient\n                    _value, // ether value\n                    add(_calldata, 32), // inloc\n                    mload(_calldata), // inlen\n                    0x00, // outloc\n                    0x00 // outlen\n                )\n        }\n        return _success;\n    }\n}\n"
      },
      "src/universal/IOptimismMintableERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { IERC165 } from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\n\n/// @title IOptimismMintableERC20\n/// @notice This interface is available on the OptimismMintableERC20 contract.\n///         We declare it as a separate interface so that it can be used in\n///         custom implementations of OptimismMintableERC20.\ninterface IOptimismMintableERC20 is IERC165 {\n    function remoteToken() external view returns (address);\n\n    function bridge() external returns (address);\n\n    function mint(address _to, uint256 _amount) external;\n\n    function burn(address _from, uint256 _amount) external;\n}\n\n/// @custom:legacy\n/// @title ILegacyMintableERC20\n/// @notice This interface was available on the legacy L2StandardERC20 contract.\n///         It remains available on the OptimismMintableERC20 contract for\n///         backwards compatibility.\ninterface ILegacyMintableERC20 is IERC165 {\n    function l1Token() external view returns (address);\n\n    function mint(address _to, uint256 _amount) external;\n\n    function burn(address _from, uint256 _amount) external;\n}\n"
      },
      "src/universal/OptimismMintableERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { ERC20 } from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport { IERC165 } from \"@openzeppelin/contracts/utils/introspection/IERC165.sol\";\nimport { ILegacyMintableERC20, IOptimismMintableERC20 } from \"src/universal/IOptimismMintableERC20.sol\";\nimport { ISemver } from \"src/universal/ISemver.sol\";\n\n/// @title OptimismMintableERC20\n/// @notice OptimismMintableERC20 is a standard extension of the base ERC20 token contract designed\n///         to allow the StandardBridge contracts to mint and burn tokens. This makes it possible to\n///         use an OptimismMintablERC20 as the L2 representation of an L1 token, or vice-versa.\n///         Designed to be backwards compatible with the older StandardL2ERC20 token which was only\n///         meant for use on L2.\ncontract OptimismMintableERC20 is IOptimismMintableERC20, ILegacyMintableERC20, ERC20, ISemver {\n    /// @notice Address of the corresponding version of this token on the remote chain.\n    address public immutable REMOTE_TOKEN;\n\n    /// @notice Address of the StandardBridge on this network.\n    address public immutable BRIDGE;\n\n    /// @notice Decimals of the token\n    uint8 private immutable DECIMALS;\n\n    /// @notice Emitted whenever tokens are minted for an account.\n    /// @param account Address of the account tokens are being minted for.\n    /// @param amount  Amount of tokens minted.\n    event Mint(address indexed account, uint256 amount);\n\n    /// @notice Emitted whenever tokens are burned from an account.\n    /// @param account Address of the account tokens are being burned from.\n    /// @param amount  Amount of tokens burned.\n    event Burn(address indexed account, uint256 amount);\n\n    /// @notice A modifier that only allows the bridge to call\n    modifier onlyBridge() {\n        require(msg.sender == BRIDGE, \"OptimismMintableERC20: only bridge can mint and burn\");\n        _;\n    }\n\n    /// @notice Semantic version.\n    /// @custom:semver 1.3.0\n    string public constant version = \"1.3.0\";\n\n    /// @param _bridge      Address of the L2 standard bridge.\n    /// @param _remoteToken Address of the corresponding L1 token.\n    /// @param _name        ERC20 name.\n    /// @param _symbol      ERC20 symbol.\n    constructor(\n        address _bridge,\n        address _remoteToken,\n        string memory _name,\n        string memory _symbol,\n        uint8 _decimals\n    )\n        ERC20(_name, _symbol)\n    {\n        REMOTE_TOKEN = _remoteToken;\n        BRIDGE = _bridge;\n        DECIMALS = _decimals;\n    }\n\n    /// @notice Allows the StandardBridge on this network to mint tokens.\n    /// @param _to     Address to mint tokens to.\n    /// @param _amount Amount of tokens to mint.\n    function mint(\n        address _to,\n        uint256 _amount\n    )\n        external\n        virtual\n        override(IOptimismMintableERC20, ILegacyMintableERC20)\n        onlyBridge\n    {\n        _mint(_to, _amount);\n        emit Mint(_to, _amount);\n    }\n\n    /// @notice Allows the StandardBridge on this network to burn tokens.\n    /// @param _from   Address to burn tokens from.\n    /// @param _amount Amount of tokens to burn.\n    function burn(\n        address _from,\n        uint256 _amount\n    )\n        external\n        virtual\n        override(IOptimismMintableERC20, ILegacyMintableERC20)\n        onlyBridge\n    {\n        _burn(_from, _amount);\n        emit Burn(_from, _amount);\n    }\n\n    /// @notice ERC165 interface check function.\n    /// @param _interfaceId Interface ID to check.\n    /// @return Whether or not the interface is supported by this contract.\n    function supportsInterface(bytes4 _interfaceId) external pure virtual returns (bool) {\n        bytes4 iface1 = type(IERC165).interfaceId;\n        // Interface corresponding to the legacy L2StandardERC20.\n        bytes4 iface2 = type(ILegacyMintableERC20).interfaceId;\n        // Interface corresponding to the updated OptimismMintableERC20 (this contract).\n        bytes4 iface3 = type(IOptimismMintableERC20).interfaceId;\n        return _interfaceId == iface1 || _interfaceId == iface2 || _interfaceId == iface3;\n    }\n\n    /// @custom:legacy\n    /// @notice Legacy getter for the remote token. Use REMOTE_TOKEN going forward.\n    function l1Token() public view returns (address) {\n        return REMOTE_TOKEN;\n    }\n\n    /// @custom:legacy\n    /// @notice Legacy getter for the bridge. Use BRIDGE going forward.\n    function l2Bridge() public view returns (address) {\n        return BRIDGE;\n    }\n\n    /// @custom:legacy\n    /// @notice Legacy getter for REMOTE_TOKEN.\n    function remoteToken() public view returns (address) {\n        return REMOTE_TOKEN;\n    }\n\n    /// @custom:legacy\n    /// @notice Legacy getter for BRIDGE.\n    function bridge() public view returns (address) {\n        return BRIDGE;\n    }\n\n    /// @dev Returns the number of decimals used to get its user representation.\n    /// For example, if `decimals` equals `2`, a balance of `505` tokens should\n    /// be displayed to a user as `5.05` (`505 / 10 ** 2`).\n    /// NOTE: This information is only used for _display_ purposes: it in\n    /// no way affects any of the arithmetic of the contract, including\n    /// {IERC20-balanceOf} and {IERC20-transfer}.\n    function decimals() public view override returns (uint8) {\n        return DECIMALS;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/Address.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!Address.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n     * initialization step. This is essential to configure modules that are added through upgrades and that require\n     * initialization.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be\n * reused. This mechanism prevents re-execution of each \"step\" but allows the creation of new initialization steps in\n * case an upgrade adds a module that needs to be initialized.\n *\n * For example:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),\n            \"Initializable: contract is already initialized\"\n        );\n        _initialized = 1;\n        if (isTopLevelCall) {\n            _initializing = true;\n        }\n        _;\n        if (isTopLevelCall) {\n            _initializing = false;\n            emit Initialized(1);\n        }\n    }\n\n    /**\n     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the\n     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be\n     * used to initialize parent contracts.\n     *\n     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original\n     * initialization step. This is essential to configure modules that are added through upgrades and that require\n     * initialization.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _initialized < version, \"Initializable: contract is already initialized\");\n        _initialized = version;\n        _initializing = true;\n        _;\n        _initializing = false;\n        emit Initialized(version);\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} and {reinitializer} modifiers, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    /**\n     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.\n     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized\n     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called\n     * through proxies.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized < type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n}\n"
      },
      "src/libraries/Hashing.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Types } from \"src/libraries/Types.sol\";\nimport { Encoding } from \"src/libraries/Encoding.sol\";\n\n/// @title Hashing\n/// @notice Hashing handles Optimism's various different hashing schemes.\nlibrary Hashing {\n    /// @notice Computes the hash of the RLP encoded L2 transaction that would be generated when a\n    ///         given deposit is sent to the L2 system. Useful for searching for a deposit in the L2\n    ///         system.\n    /// @param _tx User deposit transaction to hash.\n    /// @return Hash of the RLP encoded L2 deposit transaction.\n    function hashDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes32) {\n        return keccak256(Encoding.encodeDepositTransaction(_tx));\n    }\n\n    /// @notice Computes the deposit transaction's \"source hash\", a value that guarantees the hash\n    ///         of the L2 transaction that corresponds to a deposit is unique and is\n    ///         deterministically generated from L1 transaction data.\n    /// @param _l1BlockHash Hash of the L1 block where the deposit was included.\n    /// @param _logIndex    The index of the log that created the deposit transaction.\n    /// @return Hash of the deposit transaction's \"source hash\".\n    function hashDepositSource(bytes32 _l1BlockHash, uint256 _logIndex) internal pure returns (bytes32) {\n        bytes32 depositId = keccak256(abi.encode(_l1BlockHash, _logIndex));\n        return keccak256(abi.encode(bytes32(0), depositId));\n    }\n\n    /// @notice Hashes the cross domain message based on the version that is encoded into the\n    ///         message nonce.\n    /// @param _nonce    Message nonce with version encoded into the first two bytes.\n    /// @param _sender   Address of the sender of the message.\n    /// @param _target   Address of the target of the message.\n    /// @param _value    ETH value to send to the target.\n    /// @param _gasLimit Gas limit to use for the message.\n    /// @param _data     Data to send with the message.\n    /// @return Hashed cross domain message.\n    function hashCrossDomainMessage(\n        uint256 _nonce,\n        address _sender,\n        address _target,\n        uint256 _value,\n        uint256 _gasLimit,\n        bytes memory _data\n    )\n        internal\n        pure\n        returns (bytes32)\n    {\n        (, uint16 version) = Encoding.decodeVersionedNonce(_nonce);\n        if (version == 0) {\n            return hashCrossDomainMessageV0(_target, _sender, _data, _nonce);\n        } else if (version == 1) {\n            return hashCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data);\n        } else {\n            revert(\"Hashing: unknown cross domain message version\");\n        }\n    }\n\n    /// @notice Hashes a cross domain message based on the V0 (legacy) encoding.\n    /// @param _target Address of the target of the message.\n    /// @param _sender Address of the sender of the message.\n    /// @param _data   Data to send with the message.\n    /// @param _nonce  Message nonce.\n    /// @return Hashed cross domain message.\n    function hashCrossDomainMessageV0(\n        address _target,\n        address _sender,\n        bytes memory _data,\n        uint256 _nonce\n    )\n        internal\n        pure\n        returns (bytes32)\n    {\n        return keccak256(Encoding.encodeCrossDomainMessageV0(_target, _sender, _data, _nonce));\n    }\n\n    /// @notice Hashes a cross domain message based on the V1 (current) encoding.\n    /// @param _nonce    Message nonce.\n    /// @param _sender   Address of the sender of the message.\n    /// @param _target   Address of the target of the message.\n    /// @param _value    ETH value to send to the target.\n    /// @param _gasLimit Gas limit to use for the message.\n    /// @param _data     Data to send with the message.\n    /// @return Hashed cross domain message.\n    function hashCrossDomainMessageV1(\n        uint256 _nonce,\n        address _sender,\n        address _target,\n        uint256 _value,\n        uint256 _gasLimit,\n        bytes memory _data\n    )\n        internal\n        pure\n        returns (bytes32)\n    {\n        return keccak256(Encoding.encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data));\n    }\n\n    /// @notice Derives the withdrawal hash according to the encoding in the L2 Withdrawer contract\n    /// @param _tx Withdrawal transaction to hash.\n    /// @return Hashed withdrawal transaction.\n    function hashWithdrawal(Types.WithdrawalTransaction memory _tx) internal pure returns (bytes32) {\n        return keccak256(abi.encode(_tx.nonce, _tx.sender, _tx.target, _tx.value, _tx.gasLimit, _tx.data));\n    }\n\n    /// @notice Hashes the various elements of an output root proof into an output root hash which\n    ///         can be used to check if the proof is valid.\n    /// @param _outputRootProof Output root proof which should hash to an output root.\n    /// @return Hashed output root proof.\n    function hashOutputRootProof(Types.OutputRootProof memory _outputRootProof) internal pure returns (bytes32) {\n        return keccak256(\n            abi.encode(\n                _outputRootProof.version,\n                _outputRootProof.stateRoot,\n                _outputRootProof.messagePasserStorageRoot,\n                _outputRootProof.latestBlockhash\n            )\n        );\n    }\n}\n"
      },
      "src/libraries/Encoding.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Types } from \"src/libraries/Types.sol\";\nimport { Hashing } from \"src/libraries/Hashing.sol\";\nimport { RLPWriter } from \"src/libraries/rlp/RLPWriter.sol\";\n\n/// @title Encoding\n/// @notice Encoding handles Optimism's various different encoding schemes.\nlibrary Encoding {\n    /// @notice RLP encodes the L2 transaction that would be generated when a given deposit is sent\n    ///         to the L2 system. Useful for searching for a deposit in the L2 system. The\n    ///         transaction is prefixed with 0x7e to identify its EIP-2718 type.\n    /// @param _tx User deposit transaction to encode.\n    /// @return RLP encoded L2 deposit transaction.\n    function encodeDepositTransaction(Types.UserDepositTransaction memory _tx) internal pure returns (bytes memory) {\n        bytes32 source = Hashing.hashDepositSource(_tx.l1BlockHash, _tx.logIndex);\n        bytes[] memory raw = new bytes[](8);\n        raw[0] = RLPWriter.writeBytes(abi.encodePacked(source));\n        raw[1] = RLPWriter.writeAddress(_tx.from);\n        raw[2] = _tx.isCreation ? RLPWriter.writeBytes(\"\") : RLPWriter.writeAddress(_tx.to);\n        raw[3] = RLPWriter.writeUint(_tx.mint);\n        raw[4] = RLPWriter.writeUint(_tx.value);\n        raw[5] = RLPWriter.writeUint(uint256(_tx.gasLimit));\n        raw[6] = RLPWriter.writeBool(false);\n        raw[7] = RLPWriter.writeBytes(_tx.data);\n        return abi.encodePacked(uint8(0x7e), RLPWriter.writeList(raw));\n    }\n\n    /// @notice Encodes the cross domain message based on the version that is encoded into the\n    ///         message nonce.\n    /// @param _nonce    Message nonce with version encoded into the first two bytes.\n    /// @param _sender   Address of the sender of the message.\n    /// @param _target   Address of the target of the message.\n    /// @param _value    ETH value to send to the target.\n    /// @param _gasLimit Gas limit to use for the message.\n    /// @param _data     Data to send with the message.\n    /// @return Encoded cross domain message.\n    function encodeCrossDomainMessage(\n        uint256 _nonce,\n        address _sender,\n        address _target,\n        uint256 _value,\n        uint256 _gasLimit,\n        bytes memory _data\n    )\n        internal\n        pure\n        returns (bytes memory)\n    {\n        (, uint16 version) = decodeVersionedNonce(_nonce);\n        if (version == 0) {\n            return encodeCrossDomainMessageV0(_target, _sender, _data, _nonce);\n        } else if (version == 1) {\n            return encodeCrossDomainMessageV1(_nonce, _sender, _target, _value, _gasLimit, _data);\n        } else {\n            revert(\"Encoding: unknown cross domain message version\");\n        }\n    }\n\n    /// @notice Encodes a cross domain message based on the V0 (legacy) encoding.\n    /// @param _target Address of the target of the message.\n    /// @param _sender Address of the sender of the message.\n    /// @param _data   Data to send with the message.\n    /// @param _nonce  Message nonce.\n    /// @return Encoded cross domain message.\n    function encodeCrossDomainMessageV0(\n        address _target,\n        address _sender,\n        bytes memory _data,\n        uint256 _nonce\n    )\n        internal\n        pure\n        returns (bytes memory)\n    {\n        return abi.encodeWithSignature(\"relayMessage(address,address,bytes,uint256)\", _target, _sender, _data, _nonce);\n    }\n\n    /// @notice Encodes a cross domain message based on the V1 (current) encoding.\n    /// @param _nonce    Message nonce.\n    /// @param _sender   Address of the sender of the message.\n    /// @param _target   Address of the target of the message.\n    /// @param _value    ETH value to send to the target.\n    /// @param _gasLimit Gas limit to use for the message.\n    /// @param _data     Data to send with the message.\n    /// @return Encoded cross domain message.\n    function encodeCrossDomainMessageV1(\n        uint256 _nonce,\n        address _sender,\n        address _target,\n        uint256 _value,\n        uint256 _gasLimit,\n        bytes memory _data\n    )\n        internal\n        pure\n        returns (bytes memory)\n    {\n        return abi.encodeWithSignature(\n            \"relayMessage(uint256,address,address,uint256,uint256,bytes)\",\n            _nonce,\n            _sender,\n            _target,\n            _value,\n            _gasLimit,\n            _data\n        );\n    }\n\n    /// @notice Adds a version number into the first two bytes of a message nonce.\n    /// @param _nonce   Message nonce to encode into.\n    /// @param _version Version number to encode into the message nonce.\n    /// @return Message nonce with version encoded into the first two bytes.\n    function encodeVersionedNonce(uint240 _nonce, uint16 _version) internal pure returns (uint256) {\n        uint256 nonce;\n        assembly {\n            nonce := or(shl(240, _version), _nonce)\n        }\n        return nonce;\n    }\n\n    /// @notice Pulls the version out of a version-encoded nonce.\n    /// @param _nonce Message nonce with version encoded into the first two bytes.\n    /// @return Nonce without encoded version.\n    /// @return Version of the message.\n    function decodeVersionedNonce(uint256 _nonce) internal pure returns (uint240, uint16) {\n        uint240 nonce;\n        uint16 version;\n        assembly {\n            nonce := and(_nonce, 0x0000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)\n            version := shr(240, _nonce)\n        }\n        return (nonce, version);\n    }\n\n    /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesEcotone\n    /// @param baseFeeScalar       L1 base fee Scalar\n    /// @param blobBaseFeeScalar   L1 blob base fee Scalar\n    /// @param sequenceNumber      Number of L2 blocks since epoch start.\n    /// @param timestamp           L1 timestamp.\n    /// @param number              L1 blocknumber.\n    /// @param baseFee             L1 base fee.\n    /// @param blobBaseFee         L1 blob base fee.\n    /// @param hash                L1 blockhash.\n    /// @param batcherHash         Versioned hash to authenticate batcher by.\n    function encodeSetL1BlockValuesEcotone(\n        uint32 baseFeeScalar,\n        uint32 blobBaseFeeScalar,\n        uint64 sequenceNumber,\n        uint64 timestamp,\n        uint64 number,\n        uint256 baseFee,\n        uint256 blobBaseFee,\n        bytes32 hash,\n        bytes32 batcherHash\n    )\n        internal\n        pure\n        returns (bytes memory)\n    {\n        bytes4 functionSignature = bytes4(keccak256(\"setL1BlockValuesEcotone()\"));\n        return abi.encodePacked(\n            functionSignature,\n            baseFeeScalar,\n            blobBaseFeeScalar,\n            sequenceNumber,\n            timestamp,\n            number,\n            baseFee,\n            blobBaseFee,\n            hash,\n            batcherHash\n        );\n    }\n}\n"
      },
      "src/libraries/Storage.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title Storage\n/// @notice Storage handles reading and writing to arbitary storage locations\nlibrary Storage {\n    /// @notice Returns an address stored in an arbitrary storage slot.\n    ///         These storage slots decouple the storage layout from\n    ///         solc's automation.\n    /// @param _slot The storage slot to retrieve the address from.\n    function getAddress(bytes32 _slot) internal view returns (address addr_) {\n        assembly {\n            addr_ := sload(_slot)\n        }\n    }\n\n    /// @notice Stores an address in an arbitrary storage slot, `_slot`.\n    /// @param _slot The storage slot to store the address in.\n    /// @param _address The protocol version to store\n    /// @dev WARNING! This function must be used cautiously, as it allows for overwriting addresses\n    ///      in arbitrary storage slots.\n    function setAddress(bytes32 _slot, address _address) internal {\n        assembly {\n            sstore(_slot, _address)\n        }\n    }\n\n    /// @notice Returns a uint256 stored in an arbitrary storage slot.\n    ///         These storage slots decouple the storage layout from\n    ///         solc's automation.\n    /// @param _slot The storage slot to retrieve the address from.\n    function getUint(bytes32 _slot) internal view returns (uint256 value_) {\n        assembly {\n            value_ := sload(_slot)\n        }\n    }\n\n    /// @notice Stores a value in an arbitrary storage slot, `_slot`.\n    /// @param _slot The storage slot to store the address in.\n    /// @param _value The protocol version to store\n    /// @dev WARNING! This function must be used cautiously, as it allows for overwriting values\n    ///      in arbitrary storage slots.\n    function setUint(bytes32 _slot, uint256 _value) internal {\n        assembly {\n            sstore(_slot, _value)\n        }\n    }\n\n    /// @notice Returns a bytes32 stored in an arbitrary storage slot.\n    ///         These storage slots decouple the storage layout from\n    ///         solc's automation.\n    /// @param _slot The storage slot to retrieve the address from.\n    function getBytes32(bytes32 _slot) internal view returns (bytes32 value_) {\n        assembly {\n            value_ := sload(_slot)\n        }\n    }\n\n    /// @notice Stores a bytes32 value in an arbitrary storage slot, `_slot`.\n    /// @param _slot The storage slot to store the address in.\n    /// @param _value The bytes32 value to store.\n    /// @dev WARNING! This function must be used cautiously, as it allows for overwriting values\n    ///      in arbitrary storage slots.\n    function setBytes32(bytes32 _slot, bytes32 _value) internal {\n        assembly {\n            sstore(_slot, _value)\n        }\n    }\n\n    /// @notice Stores a bool value in an arbitrary storage slot, `_slot`.\n    /// @param _slot The storage slot to store the bool in.\n    /// @param _value The bool value to store\n    /// @dev WARNING! This function must be used cautiously, as it allows for overwriting values\n    ///      in arbitrary storage slots.\n    function setBool(bytes32 _slot, bool _value) internal {\n        assembly {\n            sstore(_slot, _value)\n        }\n    }\n\n    /// @notice Returns a bool stored in an arbitrary storage slot.\n    /// @param _slot The storage slot to retrieve the bool from.\n    function getBool(bytes32 _slot) internal view returns (bool value_) {\n        assembly {\n            value_ := sload(_slot)\n        }\n    }\n}\n"
      },
      "src/L1/ResourceMetering.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { Initializable } from \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport { Math } from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport { Burn } from \"src/libraries/Burn.sol\";\nimport { Arithmetic } from \"src/libraries/Arithmetic.sol\";\n\n/// @custom:upgradeable\n/// @title ResourceMetering\n/// @notice ResourceMetering implements an EIP-1559 style resource metering system where pricing\n///         updates automatically based on current demand.\nabstract contract ResourceMetering is Initializable {\n    /// @notice Represents the various parameters that control the way in which resources are\n    ///         metered. Corresponds to the EIP-1559 resource metering system.\n    /// @custom:field prevBaseFee   Base fee from the previous block(s).\n    /// @custom:field prevBoughtGas Amount of gas bought so far in the current block.\n    /// @custom:field prevBlockNum  Last block number that the base fee was updated.\n    struct ResourceParams {\n        uint128 prevBaseFee;\n        uint64 prevBoughtGas;\n        uint64 prevBlockNum;\n    }\n\n    /// @notice Represents the configuration for the EIP-1559 based curve for the deposit gas\n    ///         market. These values should be set with care as it is possible to set them in\n    ///         a way that breaks the deposit gas market. The target resource limit is defined as\n    ///         maxResourceLimit / elasticityMultiplier. This struct was designed to fit within a\n    ///         single word. There is additional space for additions in the future.\n    /// @custom:field maxResourceLimit             Represents the maximum amount of deposit gas that\n    ///                                            can be purchased per block.\n    /// @custom:field elasticityMultiplier         Determines the target resource limit along with\n    ///                                            the resource limit.\n    /// @custom:field baseFeeMaxChangeDenominator  Determines max change on fee per block.\n    /// @custom:field minimumBaseFee               The min deposit base fee, it is clamped to this\n    ///                                            value.\n    /// @custom:field systemTxMaxGas               The amount of gas supplied to the system\n    ///                                            transaction. This should be set to the same\n    ///                                            number that the op-node sets as the gas limit\n    ///                                            for the system transaction.\n    /// @custom:field maximumBaseFee               The max deposit base fee, it is clamped to this\n    ///                                            value.\n    struct ResourceConfig {\n        uint32 maxResourceLimit;\n        uint8 elasticityMultiplier;\n        uint8 baseFeeMaxChangeDenominator;\n        uint32 minimumBaseFee;\n        uint32 systemTxMaxGas;\n        uint128 maximumBaseFee;\n    }\n\n    /// @notice EIP-1559 style gas parameters.\n    ResourceParams public params;\n\n    /// @notice Reserve extra slots (to a total of 50) in the storage layout for future upgrades.\n    uint256[48] private __gap;\n\n    /// @notice Meters access to a function based an amount of a requested resource.\n    /// @param _amount Amount of the resource requested.\n    modifier metered(uint64 _amount) {\n        // Record initial gas amount so we can refund for it later.\n        uint256 initialGas = gasleft();\n\n        // Run the underlying function.\n        _;\n\n        // Run the metering function.\n        _metered(_amount, initialGas);\n    }\n\n    /// @notice An internal function that holds all of the logic for metering a resource.\n    /// @param _amount     Amount of the resource requested.\n    /// @param _initialGas The amount of gas before any modifier execution.\n    function _metered(uint64 _amount, uint256 _initialGas) internal {\n        // Update block number and base fee if necessary.\n        uint256 blockDiff = block.number - params.prevBlockNum;\n\n        ResourceConfig memory config = _resourceConfig();\n        int256 targetResourceLimit =\n            int256(uint256(config.maxResourceLimit)) / int256(uint256(config.elasticityMultiplier));\n\n        if (blockDiff > 0) {\n            // Handle updating EIP-1559 style gas parameters. We use EIP-1559 to restrict the rate\n            // at which deposits can be created and therefore limit the potential for deposits to\n            // spam the L2 system. Fee scheme is very similar to EIP-1559 with minor changes.\n            int256 gasUsedDelta = int256(uint256(params.prevBoughtGas)) - targetResourceLimit;\n            int256 baseFeeDelta = (int256(uint256(params.prevBaseFee)) * gasUsedDelta)\n                / (targetResourceLimit * int256(uint256(config.baseFeeMaxChangeDenominator)));\n\n            // Update base fee by adding the base fee delta and clamp the resulting value between\n            // min and max.\n            int256 newBaseFee = Arithmetic.clamp({\n                _value: int256(uint256(params.prevBaseFee)) + baseFeeDelta,\n                _min: int256(uint256(config.minimumBaseFee)),\n                _max: int256(uint256(config.maximumBaseFee))\n            });\n\n            // If we skipped more than one block, we also need to account for every empty block.\n            // Empty block means there was no demand for deposits in that block, so we should\n            // reflect this lack of demand in the fee.\n            if (blockDiff > 1) {\n                // Update the base fee by repeatedly applying the exponent 1-(1/change_denominator)\n                // blockDiff - 1 times. Simulates multiple empty blocks. Clamp the resulting value\n                // between min and max.\n                newBaseFee = Arithmetic.clamp({\n                    _value: Arithmetic.cdexp({\n                        _coefficient: newBaseFee,\n                        _denominator: int256(uint256(config.baseFeeMaxChangeDenominator)),\n                        _exponent: int256(blockDiff - 1)\n                    }),\n                    _min: int256(uint256(config.minimumBaseFee)),\n                    _max: int256(uint256(config.maximumBaseFee))\n                });\n            }\n\n            // Update new base fee, reset bought gas, and update block number.\n            params.prevBaseFee = uint128(uint256(newBaseFee));\n            params.prevBoughtGas = 0;\n            params.prevBlockNum = uint64(block.number);\n        }\n\n        // Make sure we can actually buy the resource amount requested by the user.\n        params.prevBoughtGas += _amount;\n        require(\n            int256(uint256(params.prevBoughtGas)) <= int256(uint256(config.maxResourceLimit)),\n            \"ResourceMetering: cannot buy more gas than available gas limit\"\n        );\n\n        // Determine the amount of ETH to be paid.\n        uint256 resourceCost = uint256(_amount) * uint256(params.prevBaseFee);\n\n        // We currently charge for this ETH amount as an L1 gas burn, so we convert the ETH amount\n        // into gas by dividing by the L1 base fee. We assume a minimum base fee of 1 gwei to avoid\n        // division by zero for L1s that don't support 1559 or to avoid excessive gas burns during\n        // periods of extremely low L1 demand. One-day average gas fee hasn't dipped below 1 gwei\n        // during any 1 day period in the last 5 years, so should be fine.\n        uint256 gasCost = resourceCost / Math.max(block.basefee, 1 gwei);\n\n        // Give the user a refund based on the amount of gas they used to do all of the work up to\n        // this point. Since we're at the end of the modifier, this should be pretty accurate. Acts\n        // effectively like a dynamic stipend (with a minimum value).\n        uint256 usedGas = _initialGas - gasleft();\n        if (gasCost > usedGas) {\n            Burn.gas(gasCost - usedGas);\n        }\n    }\n\n    /// @notice Virtual function that returns the resource config.\n    ///         Contracts that inherit this contract must implement this function.\n    /// @return ResourceConfig\n    function _resourceConfig() internal virtual returns (ResourceConfig memory);\n\n    /// @notice Sets initial resource parameter values.\n    ///         This function must either be called by the initializer function of an upgradeable\n    ///         child contract.\n    // solhint-disable-next-line func-name-mixedcase\n    function __ResourceMetering_init() internal onlyInitializing {\n        if (params.prevBlockNum == 0) {\n            params = ResourceParams({ prevBaseFee: 1 gwei, prevBoughtGas: 0, prevBlockNum: uint64(block.number) });\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/draft-IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/draft-IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/ERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20.sol\";\nimport \"./extensions/IERC20Metadata.sol\";\nimport \"../../utils/Context.sol\";\n\n/**\n * @dev Implementation of the {IERC20} interface.\n *\n * This implementation is agnostic to the way tokens are created. This means\n * that a supply mechanism has to be added in a derived contract using {_mint}.\n * For a generic mechanism see {ERC20PresetMinterPauser}.\n *\n * TIP: For a detailed writeup see our guide\n * https://forum.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * We have followed general OpenZeppelin Contracts guidelines: functions revert\n * instead returning `false` on failure. This behavior is nonetheless\n * conventional and does not conflict with the expectations of ERC20\n * applications.\n *\n * Additionally, an {Approval} event is emitted on calls to {transferFrom}.\n * This allows applications to reconstruct the allowance for all accounts just\n * by listening to said events. Other implementations of the EIP may not emit\n * these events, as it isn't required by the specification.\n *\n * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}\n * functions have been added to mitigate the well-known issues around setting\n * allowances. See {IERC20-approve}.\n */\ncontract ERC20 is Context, IERC20, IERC20Metadata {\n    mapping(address => uint256) private _balances;\n\n    mapping(address => mapping(address => uint256)) private _allowances;\n\n    uint256 private _totalSupply;\n\n    string private _name;\n    string private _symbol;\n\n    /**\n     * @dev Sets the values for {name} and {symbol}.\n     *\n     * The default value of {decimals} is 18. To select a different value for\n     * {decimals} you should overload it.\n     *\n     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev Returns the symbol of the token, usually a shorter version of the\n     * name.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev Returns the number of decimals used to get its user representation.\n     * For example, if `decimals` equals `2`, a balance of `505` tokens should\n     * be displayed to a user as `5.05` (`505 / 10 ** 2`).\n     *\n     * Tokens usually opt for a value of 18, imitating the relationship between\n     * Ether and Wei. This is the value {ERC20} uses, unless this function is\n     * overridden;\n     *\n     * NOTE: This information is only used for _display_ purposes: it in\n     * no way affects any of the arithmetic of the contract, including\n     * {IERC20-balanceOf} and {IERC20-transfer}.\n     */\n    function decimals() public view virtual override returns (uint8) {\n        return 18;\n    }\n\n    /**\n     * @dev See {IERC20-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _totalSupply;\n    }\n\n    /**\n     * @dev See {IERC20-balanceOf}.\n     */\n    function balanceOf(address account) public view virtual override returns (uint256) {\n        return _balances[account];\n    }\n\n    /**\n     * @dev See {IERC20-transfer}.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - the caller must have a balance of at least `amount`.\n     */\n    function transfer(address to, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _transfer(owner, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-allowance}.\n     */\n    function allowance(address owner, address spender) public view virtual override returns (uint256) {\n        return _allowances[owner][spender];\n    }\n\n    /**\n     * @dev See {IERC20-approve}.\n     *\n     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on\n     * `transferFrom`. This is semantically equivalent to an infinite approval.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function approve(address spender, uint256 amount) public virtual override returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, amount);\n        return true;\n    }\n\n    /**\n     * @dev See {IERC20-transferFrom}.\n     *\n     * Emits an {Approval} event indicating the updated allowance. This is not\n     * required by the EIP. See the note at the beginning of {ERC20}.\n     *\n     * NOTE: Does not update the allowance if the current allowance\n     * is the maximum `uint256`.\n     *\n     * Requirements:\n     *\n     * - `from` and `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     * - the caller must have allowance for ``from``'s tokens of at least\n     * `amount`.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) public virtual override returns (bool) {\n        address spender = _msgSender();\n        _spendAllowance(from, spender, amount);\n        _transfer(from, to, amount);\n        return true;\n    }\n\n    /**\n     * @dev Atomically increases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     */\n    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        _approve(owner, spender, allowance(owner, spender) + addedValue);\n        return true;\n    }\n\n    /**\n     * @dev Atomically decreases the allowance granted to `spender` by the caller.\n     *\n     * This is an alternative to {approve} that can be used as a mitigation for\n     * problems described in {IERC20-approve}.\n     *\n     * Emits an {Approval} event indicating the updated allowance.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `spender` must have allowance for the caller of at least\n     * `subtractedValue`.\n     */\n    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {\n        address owner = _msgSender();\n        uint256 currentAllowance = allowance(owner, spender);\n        require(currentAllowance >= subtractedValue, \"ERC20: decreased allowance below zero\");\n        unchecked {\n            _approve(owner, spender, currentAllowance - subtractedValue);\n        }\n\n        return true;\n    }\n\n    /**\n     * @dev Moves `amount` of tokens from `from` to `to`.\n     *\n     * This internal function is equivalent to {transfer}, and can be used to\n     * e.g. implement automatic token fees, slashing mechanisms, etc.\n     *\n     * Emits a {Transfer} event.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `from` must have a balance of at least `amount`.\n     */\n    function _transfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {\n        require(from != address(0), \"ERC20: transfer from the zero address\");\n        require(to != address(0), \"ERC20: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, amount);\n\n        uint256 fromBalance = _balances[from];\n        require(fromBalance >= amount, \"ERC20: transfer amount exceeds balance\");\n        unchecked {\n            _balances[from] = fromBalance - amount;\n        }\n        _balances[to] += amount;\n\n        emit Transfer(from, to, amount);\n\n        _afterTokenTransfer(from, to, amount);\n    }\n\n    /** @dev Creates `amount` tokens and assigns them to `account`, increasing\n     * the total supply.\n     *\n     * Emits a {Transfer} event with `from` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function _mint(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: mint to the zero address\");\n\n        _beforeTokenTransfer(address(0), account, amount);\n\n        _totalSupply += amount;\n        _balances[account] += amount;\n        emit Transfer(address(0), account, amount);\n\n        _afterTokenTransfer(address(0), account, amount);\n    }\n\n    /**\n     * @dev Destroys `amount` tokens from `account`, reducing the\n     * total supply.\n     *\n     * Emits a {Transfer} event with `to` set to the zero address.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     * - `account` must have at least `amount` tokens.\n     */\n    function _burn(address account, uint256 amount) internal virtual {\n        require(account != address(0), \"ERC20: burn from the zero address\");\n\n        _beforeTokenTransfer(account, address(0), amount);\n\n        uint256 accountBalance = _balances[account];\n        require(accountBalance >= amount, \"ERC20: burn amount exceeds balance\");\n        unchecked {\n            _balances[account] = accountBalance - amount;\n        }\n        _totalSupply -= amount;\n\n        emit Transfer(account, address(0), amount);\n\n        _afterTokenTransfer(account, address(0), amount);\n    }\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.\n     *\n     * This internal function is equivalent to `approve`, and can be used to\n     * e.g. set automatic allowances for certain subsystems, etc.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `owner` cannot be the zero address.\n     * - `spender` cannot be the zero address.\n     */\n    function _approve(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        require(owner != address(0), \"ERC20: approve from the zero address\");\n        require(spender != address(0), \"ERC20: approve to the zero address\");\n\n        _allowances[owner][spender] = amount;\n        emit Approval(owner, spender, amount);\n    }\n\n    /**\n     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.\n     *\n     * Does not update the allowance amount in case of infinite allowance.\n     * Revert if not enough allowance is available.\n     *\n     * Might emit an {Approval} event.\n     */\n    function _spendAllowance(\n        address owner,\n        address spender,\n        uint256 amount\n    ) internal virtual {\n        uint256 currentAllowance = allowance(owner, spender);\n        if (currentAllowance != type(uint256).max) {\n            require(currentAllowance >= amount, \"ERC20: insufficient allowance\");\n            unchecked {\n                _approve(owner, spender, currentAllowance - amount);\n            }\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * will be transferred to `to`.\n     * - when `from` is zero, `amount` tokens will be minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any transfer of tokens. This includes\n     * minting and burning.\n     *\n     * Calling conditions:\n     *\n     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens\n     * has been transferred to `to`.\n     * - when `from` is zero, `amount` tokens have been minted for `to`.\n     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.\n     * - `from` and `to` are never both zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(\n        address from,\n        address to,\n        uint256 amount\n    ) internal virtual {}\n}\n"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n                /// @solidity memory-safe-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      },
      "src/libraries/Types.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title Types\n/// @notice Contains various types used throughout the Optimism contract system.\nlibrary Types {\n    /// @notice OutputProposal represents a commitment to the L2 state. The timestamp is the L1\n    ///         timestamp that the output root is posted. This timestamp is used to verify that the\n    ///         finalization period has passed since the output root was submitted.\n    /// @custom:field outputRoot    Hash of the L2 output.\n    /// @custom:field timestamp     Timestamp of the L1 block that the output root was submitted in.\n    /// @custom:field l2BlockNumber L2 block number that the output corresponds to.\n    struct OutputProposal {\n        bytes32 outputRoot;\n        uint128 timestamp;\n        uint128 l2BlockNumber;\n    }\n\n    /// @notice Struct representing the elements that are hashed together to generate an output root\n    ///         which itself represents a snapshot of the L2 state.\n    /// @custom:field version                  Version of the output root.\n    /// @custom:field stateRoot                Root of the state trie at the block of this output.\n    /// @custom:field messagePasserStorageRoot Root of the message passer storage trie.\n    /// @custom:field latestBlockhash          Hash of the block this output was generated from.\n    struct OutputRootProof {\n        bytes32 version;\n        bytes32 stateRoot;\n        bytes32 messagePasserStorageRoot;\n        bytes32 latestBlockhash;\n    }\n\n    /// @notice Struct representing a deposit transaction (L1 => L2 transaction) created by an end\n    ///         user (as opposed to a system deposit transaction generated by the system).\n    /// @custom:field from        Address of the sender of the transaction.\n    /// @custom:field to          Address of the recipient of the transaction.\n    /// @custom:field isCreation  True if the transaction is a contract creation.\n    /// @custom:field value       Value to send to the recipient.\n    /// @custom:field mint        Amount of ETH to mint.\n    /// @custom:field gasLimit    Gas limit of the transaction.\n    /// @custom:field data        Data of the transaction.\n    /// @custom:field l1BlockHash Hash of the block the transaction was submitted in.\n    /// @custom:field logIndex    Index of the log in the block the transaction was submitted in.\n    struct UserDepositTransaction {\n        address from;\n        address to;\n        bool isCreation;\n        uint256 value;\n        uint256 mint;\n        uint64 gasLimit;\n        bytes data;\n        bytes32 l1BlockHash;\n        uint256 logIndex;\n    }\n\n    /// @notice Struct representing a withdrawal transaction.\n    /// @custom:field nonce    Nonce of the withdrawal transaction\n    /// @custom:field sender   Address of the sender of the transaction.\n    /// @custom:field target   Address of the recipient of the transaction.\n    /// @custom:field value    Value to send to the recipient.\n    /// @custom:field gasLimit Gas limit of the transaction.\n    /// @custom:field data     Data of the transaction.\n    struct WithdrawalTransaction {\n        uint256 nonce;\n        address sender;\n        address target;\n        uint256 value;\n        uint256 gasLimit;\n        bytes data;\n    }\n}\n"
      },
      "src/libraries/rlp/RLPWriter.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @custom:attribution https://github.com/bakaoh/solidity-rlp-encode\n/// @title RLPWriter\n/// @author RLPWriter is a library for encoding Solidity types to RLP bytes. Adapted from Bakaoh's\n///         RLPEncode library (https://github.com/bakaoh/solidity-rlp-encode) with minor\n///         modifications to improve legibility.\nlibrary RLPWriter {\n    /// @notice RLP encodes a byte string.\n    /// @param _in The byte string to encode.\n    /// @return out_ The RLP encoded string in bytes.\n    function writeBytes(bytes memory _in) internal pure returns (bytes memory out_) {\n        if (_in.length == 1 && uint8(_in[0]) < 128) {\n            out_ = _in;\n        } else {\n            out_ = abi.encodePacked(_writeLength(_in.length, 128), _in);\n        }\n    }\n\n    /// @notice RLP encodes a list of RLP encoded byte byte strings.\n    /// @param _in The list of RLP encoded byte strings.\n    /// @return list_ The RLP encoded list of items in bytes.\n    function writeList(bytes[] memory _in) internal pure returns (bytes memory list_) {\n        list_ = _flatten(_in);\n        list_ = abi.encodePacked(_writeLength(list_.length, 192), list_);\n    }\n\n    /// @notice RLP encodes a string.\n    /// @param _in The string to encode.\n    /// @return out_ The RLP encoded string in bytes.\n    function writeString(string memory _in) internal pure returns (bytes memory out_) {\n        out_ = writeBytes(bytes(_in));\n    }\n\n    /// @notice RLP encodes an address.\n    /// @param _in The address to encode.\n    /// @return out_ The RLP encoded address in bytes.\n    function writeAddress(address _in) internal pure returns (bytes memory out_) {\n        out_ = writeBytes(abi.encodePacked(_in));\n    }\n\n    /// @notice RLP encodes a uint.\n    /// @param _in The uint256 to encode.\n    /// @return out_ The RLP encoded uint256 in bytes.\n    function writeUint(uint256 _in) internal pure returns (bytes memory out_) {\n        out_ = writeBytes(_toBinary(_in));\n    }\n\n    /// @notice RLP encodes a bool.\n    /// @param _in The bool to encode.\n    /// @return out_ The RLP encoded bool in bytes.\n    function writeBool(bool _in) internal pure returns (bytes memory out_) {\n        out_ = new bytes(1);\n        out_[0] = (_in ? bytes1(0x01) : bytes1(0x80));\n    }\n\n    /// @notice Encode the first byte and then the `len` in binary form if `length` is more than 55.\n    /// @param _len    The length of the string or the payload.\n    /// @param _offset 128 if item is string, 192 if item is list.\n    /// @return out_ RLP encoded bytes.\n    function _writeLength(uint256 _len, uint256 _offset) private pure returns (bytes memory out_) {\n        if (_len < 56) {\n            out_ = new bytes(1);\n            out_[0] = bytes1(uint8(_len) + uint8(_offset));\n        } else {\n            uint256 lenLen;\n            uint256 i = 1;\n            while (_len / i != 0) {\n                lenLen++;\n                i *= 256;\n            }\n\n            out_ = new bytes(lenLen + 1);\n            out_[0] = bytes1(uint8(lenLen) + uint8(_offset) + 55);\n            for (i = 1; i <= lenLen; i++) {\n                out_[i] = bytes1(uint8((_len / (256 ** (lenLen - i))) % 256));\n            }\n        }\n    }\n\n    /// @notice Encode integer in big endian binary form with no leading zeroes.\n    /// @param _x The integer to encode.\n    /// @return out_ RLP encoded bytes.\n    function _toBinary(uint256 _x) private pure returns (bytes memory out_) {\n        bytes memory b = abi.encodePacked(_x);\n\n        uint256 i = 0;\n        for (; i < 32; i++) {\n            if (b[i] != 0) {\n                break;\n            }\n        }\n\n        out_ = new bytes(32 - i);\n        for (uint256 j = 0; j < out_.length; j++) {\n            out_[j] = b[i++];\n        }\n    }\n\n    /// @custom:attribution https://github.com/Arachnid/solidity-stringutils\n    /// @notice Copies a piece of memory to another location.\n    /// @param _dest Destination location.\n    /// @param _src  Source location.\n    /// @param _len  Length of memory to copy.\n    function _memcpy(uint256 _dest, uint256 _src, uint256 _len) private pure {\n        uint256 dest = _dest;\n        uint256 src = _src;\n        uint256 len = _len;\n\n        for (; len >= 32; len -= 32) {\n            assembly {\n                mstore(dest, mload(src))\n            }\n            dest += 32;\n            src += 32;\n        }\n\n        uint256 mask;\n        unchecked {\n            mask = 256 ** (32 - len) - 1;\n        }\n        assembly {\n            let srcpart := and(mload(src), not(mask))\n            let destpart := and(mload(dest), mask)\n            mstore(dest, or(destpart, srcpart))\n        }\n    }\n\n    /// @custom:attribution https://github.com/sammayo/solidity-rlp-encoder\n    /// @notice Flattens a list of byte strings into one byte string.\n    /// @param _list List of byte strings to flatten.\n    /// @return out_ The flattened byte string.\n    function _flatten(bytes[] memory _list) private pure returns (bytes memory out_) {\n        if (_list.length == 0) {\n            return new bytes(0);\n        }\n\n        uint256 len;\n        uint256 i = 0;\n        for (; i < _list.length; i++) {\n            len += _list[i].length;\n        }\n\n        out_ = new bytes(len);\n        uint256 flattenedPtr;\n        assembly {\n            flattenedPtr := add(out_, 0x20)\n        }\n\n        for (i = 0; i < _list.length; i++) {\n            bytes memory item = _list[i];\n\n            uint256 listPtr;\n            assembly {\n                listPtr := add(item, 0x20)\n            }\n\n            _memcpy(flattenedPtr, listPtr, item.length);\n            flattenedPtr += _list[i].length;\n        }\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1);\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(\n        uint256 x,\n        uint256 y,\n        uint256 denominator,\n        Rounding rounding\n    ) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. It the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`.\n        // We also know that `k`, the position of the most significant bit, is such that `msb(a) = 2**k`.\n        // This gives `2**k < a <= 2**(k+1)` → `2**(k/2) <= sqrt(a) < 2 ** (k/2+1)`.\n        // Using an algorithm similar to the msb conmputation, we are able to compute `result = 2**(k/2)` which is a\n        // good first aproximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1;\n        uint256 x = a;\n        if (x >> 128 > 0) {\n            x >>= 128;\n            result <<= 64;\n        }\n        if (x >> 64 > 0) {\n            x >>= 64;\n            result <<= 32;\n        }\n        if (x >> 32 > 0) {\n            x >>= 32;\n            result <<= 16;\n        }\n        if (x >> 16 > 0) {\n            x >>= 16;\n            result <<= 8;\n        }\n        if (x >> 8 > 0) {\n            x >>= 8;\n            result <<= 4;\n        }\n        if (x >> 4 > 0) {\n            x >>= 4;\n            result <<= 2;\n        }\n        if (x >> 2 > 0) {\n            result <<= 1;\n        }\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = sqrt(a);\n        if (rounding == Rounding.Up && result * result < a) {\n            result += 1;\n        }\n        return result;\n    }\n}\n"
      },
      "src/libraries/Burn.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\n/// @title Burn\n/// @notice Utilities for burning stuff.\nlibrary Burn {\n    /// @notice Burns a given amount of ETH.\n    /// @param _amount Amount of ETH to burn.\n    function eth(uint256 _amount) internal {\n        new Burner{ value: _amount }();\n    }\n\n    /// @notice Burns a given amount of gas.\n    /// @param _amount Amount of gas to burn.\n    function gas(uint256 _amount) internal view {\n        uint256 i = 0;\n        uint256 initialGas = gasleft();\n        while (initialGas - gasleft() < _amount) {\n            ++i;\n        }\n    }\n}\n\n/// @title Burner\n/// @notice Burner self-destructs on creation and sends all ETH to itself, removing all ETH given to\n///         the contract from the circulating supply. Self-destructing is the only way to remove ETH\n///         from the circulating supply.\ncontract Burner {\n    constructor() payable {\n        selfdestruct(payable(address(this)));\n    }\n}\n"
      },
      "src/libraries/Arithmetic.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { SignedMath } from \"@openzeppelin/contracts/utils/math/SignedMath.sol\";\nimport { FixedPointMathLib } from \"@rari-capital/solmate/src/utils/FixedPointMathLib.sol\";\n\n/// @title Arithmetic\n/// @notice Even more math than before.\nlibrary Arithmetic {\n    /// @notice Clamps a value between a minimum and maximum.\n    /// @param _value The value to clamp.\n    /// @param _min   The minimum value.\n    /// @param _max   The maximum value.\n    /// @return The clamped value.\n    function clamp(int256 _value, int256 _min, int256 _max) internal pure returns (int256) {\n        return SignedMath.min(SignedMath.max(_value, _min), _max);\n    }\n\n    /// @notice (c)oefficient (d)enominator (exp)onentiation function.\n    ///         Returns the result of: c * (1 - 1/d)^exp.\n    /// @param _coefficient Coefficient of the function.\n    /// @param _denominator Fractional denominator.\n    /// @param _exponent    Power function exponent.\n    /// @return Result of c * (1 - 1/d)^exp.\n    function cdexp(int256 _coefficient, int256 _denominator, int256 _exponent) internal pure returns (int256) {\n        return (_coefficient * (FixedPointMathLib.powWad(1e18 - (1e18 / _denominator), _exponent * 1e18))) / 1e18;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/token/ERC20/extensions/IERC20Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20Metadata is IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the decimals places of the token.\n     */\n    function decimals() external view returns (uint8);\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
      },
      "lib/openzeppelin-contracts/contracts/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/SignedMath.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard signed math utilities missing in the Solidity language.\n */\nlibrary SignedMath {\n    /**\n     * @dev Returns the largest of two signed numbers.\n     */\n    function max(int256 a, int256 b) internal pure returns (int256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two signed numbers.\n     */\n    function min(int256 a, int256 b) internal pure returns (int256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two signed numbers without overflow.\n     * The result is rounded towards zero.\n     */\n    function average(int256 a, int256 b) internal pure returns (int256) {\n        // Formula from the book \"Hacker's Delight\"\n        int256 x = (a & b) + ((a ^ b) >> 1);\n        return x + (int256(uint256(x) >> 255) & (a ^ b));\n    }\n\n    /**\n     * @dev Returns the absolute unsigned value of a signed value.\n     */\n    function abs(int256 n) internal pure returns (uint256) {\n        unchecked {\n            // must be unchecked in order to support `n = type(int256).min`\n            return uint256(n >= 0 ? n : -n);\n        }\n    }\n}\n"
      },
      "lib/solmate/src/utils/FixedPointMathLib.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/// @notice Arithmetic library with operations for fixed-point numbers.\n/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/utils/FixedPointMathLib.sol)\nlibrary FixedPointMathLib {\n    /*//////////////////////////////////////////////////////////////\n                    SIMPLIFIED FIXED POINT OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    uint256 internal constant WAD = 1e18; // The scalar of ETH and most ERC20s.\n\n    function mulWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n        return mulDivDown(x, y, WAD); // Equivalent to (x * y) / WAD rounded down.\n    }\n\n    function mulWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n        return mulDivUp(x, y, WAD); // Equivalent to (x * y) / WAD rounded up.\n    }\n\n    function divWadDown(uint256 x, uint256 y) internal pure returns (uint256) {\n        return mulDivDown(x, WAD, y); // Equivalent to (x * WAD) / y rounded down.\n    }\n\n    function divWadUp(uint256 x, uint256 y) internal pure returns (uint256) {\n        return mulDivUp(x, WAD, y); // Equivalent to (x * WAD) / y rounded up.\n    }\n\n    function powWad(int256 x, int256 y) internal pure returns (int256) {\n        // Equivalent to x to the power of y because x ** y = (e ** ln(x)) ** y = e ** (ln(x) * y)\n        return expWad((lnWad(x) * y) / int256(WAD)); // Using ln(x) means x must be greater than 0.\n    }\n\n    function expWad(int256 x) internal pure returns (int256 r) {\n        unchecked {\n            // When the result is < 0.5 we return zero. This happens when\n            // x <= floor(log(0.5e18) * 1e18) ~ -42e18\n            if (x <= -42139678854452767551) return 0;\n\n            // When the result is > (2**255 - 1) / 1e18 we can not represent it as an\n            // int. This happens when x >= floor(log((2**255 - 1) / 1e18) * 1e18) ~ 135.\n            if (x >= 135305999368893231589) revert(\"EXP_OVERFLOW\");\n\n            // x is now in the range (-42, 136) * 1e18. Convert to (-42, 136) * 2**96\n            // for more intermediate precision and a binary basis. This base conversion\n            // is a multiplication by 1e18 / 2**96 = 5**18 / 2**78.\n            x = (x << 78) / 5**18;\n\n            // Reduce range of x to (-½ ln 2, ½ ln 2) * 2**96 by factoring out powers\n            // of two such that exp(x) = exp(x') * 2**k, where k is an integer.\n            // Solving this gives k = round(x / log(2)) and x' = x - k * log(2).\n            int256 k = ((x << 96) / 54916777467707473351141471128 + 2**95) >> 96;\n            x = x - k * 54916777467707473351141471128;\n\n            // k is in the range [-61, 195].\n\n            // Evaluate using a (6, 7)-term rational approximation.\n            // p is made monic, we'll multiply by a scale factor later.\n            int256 y = x + 1346386616545796478920950773328;\n            y = ((y * x) >> 96) + 57155421227552351082224309758442;\n            int256 p = y + x - 94201549194550492254356042504812;\n            p = ((p * y) >> 96) + 28719021644029726153956944680412240;\n            p = p * x + (4385272521454847904659076985693276 << 96);\n\n            // We leave p in 2**192 basis so we don't need to scale it back up for the division.\n            int256 q = x - 2855989394907223263936484059900;\n            q = ((q * x) >> 96) + 50020603652535783019961831881945;\n            q = ((q * x) >> 96) - 533845033583426703283633433725380;\n            q = ((q * x) >> 96) + 3604857256930695427073651918091429;\n            q = ((q * x) >> 96) - 14423608567350463180887372962807573;\n            q = ((q * x) >> 96) + 26449188498355588339934803723976023;\n\n            assembly {\n                // Div in assembly because solidity adds a zero check despite the unchecked.\n                // The q polynomial won't have zeros in the domain as all its roots are complex.\n                // No scaling is necessary because p is already 2**96 too large.\n                r := sdiv(p, q)\n            }\n\n            // r should be in the range (0.09, 0.25) * 2**96.\n\n            // We now need to multiply r by:\n            // * the scale factor s = ~6.031367120.\n            // * the 2**k factor from the range reduction.\n            // * the 1e18 / 2**96 factor for base conversion.\n            // We do this all at once, with an intermediate result in 2**213\n            // basis, so the final right shift is always by a positive amount.\n            r = int256((uint256(r) * 3822833074963236453042738258902158003155416615667) >> uint256(195 - k));\n        }\n    }\n\n    function lnWad(int256 x) internal pure returns (int256 r) {\n        unchecked {\n            require(x > 0, \"UNDEFINED\");\n\n            // We want to convert x from 10**18 fixed point to 2**96 fixed point.\n            // We do this by multiplying by 2**96 / 10**18. But since\n            // ln(x * C) = ln(x) + ln(C), we can simply do nothing here\n            // and add ln(2**96 / 10**18) at the end.\n\n            // Reduce range of x to (1, 2) * 2**96\n            // ln(2^k * x) = k * ln(2) + ln(x)\n            int256 k = int256(log2(uint256(x))) - 96;\n            x <<= uint256(159 - k);\n            x = int256(uint256(x) >> 159);\n\n            // Evaluate using a (8, 8)-term rational approximation.\n            // p is made monic, we will multiply by a scale factor later.\n            int256 p = x + 3273285459638523848632254066296;\n            p = ((p * x) >> 96) + 24828157081833163892658089445524;\n            p = ((p * x) >> 96) + 43456485725739037958740375743393;\n            p = ((p * x) >> 96) - 11111509109440967052023855526967;\n            p = ((p * x) >> 96) - 45023709667254063763336534515857;\n            p = ((p * x) >> 96) - 14706773417378608786704636184526;\n            p = p * x - (795164235651350426258249787498 << 96);\n\n            // We leave p in 2**192 basis so we don't need to scale it back up for the division.\n            // q is monic by convention.\n            int256 q = x + 5573035233440673466300451813936;\n            q = ((q * x) >> 96) + 71694874799317883764090561454958;\n            q = ((q * x) >> 96) + 283447036172924575727196451306956;\n            q = ((q * x) >> 96) + 401686690394027663651624208769553;\n            q = ((q * x) >> 96) + 204048457590392012362485061816622;\n            q = ((q * x) >> 96) + 31853899698501571402653359427138;\n            q = ((q * x) >> 96) + 909429971244387300277376558375;\n            assembly {\n                // Div in assembly because solidity adds a zero check despite the unchecked.\n                // The q polynomial is known not to have zeros in the domain.\n                // No scaling required because p is already 2**96 too large.\n                r := sdiv(p, q)\n            }\n\n            // r is in the range (0, 0.125) * 2**96\n\n            // Finalization, we need to:\n            // * multiply by the scale factor s = 5.549…\n            // * add ln(2**96 / 10**18)\n            // * add k * ln(2)\n            // * multiply by 10**18 / 2**96 = 5**18 >> 78\n\n            // mul s * 5e18 * 2**96, base is now 5**18 * 2**192\n            r *= 1677202110996718588342820967067443963516166;\n            // add ln(2) * k * 5e18 * 2**192\n            r += 16597577552685614221487285958193947469193820559219878177908093499208371 * k;\n            // add ln(2**96 / 10**18) * 5e18 * 2**192\n            r += 600920179829731861736702779321621459595472258049074101567377883020018308;\n            // base conversion: mul 2**18 / 2**192\n            r >>= 174;\n        }\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                    LOW LEVEL FIXED POINT OPERATIONS\n    //////////////////////////////////////////////////////////////*/\n\n    function mulDivDown(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) internal pure returns (uint256 z) {\n        assembly {\n            // Store x * y in z for now.\n            z := mul(x, y)\n\n            // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n            if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n                revert(0, 0)\n            }\n\n            // Divide z by the denominator.\n            z := div(z, denominator)\n        }\n    }\n\n    function mulDivUp(\n        uint256 x,\n        uint256 y,\n        uint256 denominator\n    ) internal pure returns (uint256 z) {\n        assembly {\n            // Store x * y in z for now.\n            z := mul(x, y)\n\n            // Equivalent to require(denominator != 0 && (x == 0 || (x * y) / x == y))\n            if iszero(and(iszero(iszero(denominator)), or(iszero(x), eq(div(z, x), y)))) {\n                revert(0, 0)\n            }\n\n            // First, divide z - 1 by the denominator and add 1.\n            // We allow z - 1 to underflow if z is 0, because we multiply the\n            // end result by 0 if z is zero, ensuring we return 0 if z is zero.\n            z := mul(iszero(iszero(z)), add(div(sub(z, 1), denominator), 1))\n        }\n    }\n\n    function rpow(\n        uint256 x,\n        uint256 n,\n        uint256 scalar\n    ) internal pure returns (uint256 z) {\n        assembly {\n            switch x\n            case 0 {\n                switch n\n                case 0 {\n                    // 0 ** 0 = 1\n                    z := scalar\n                }\n                default {\n                    // 0 ** n = 0\n                    z := 0\n                }\n            }\n            default {\n                switch mod(n, 2)\n                case 0 {\n                    // If n is even, store scalar in z for now.\n                    z := scalar\n                }\n                default {\n                    // If n is odd, store x in z for now.\n                    z := x\n                }\n\n                // Shifting right by 1 is like dividing by 2.\n                let half := shr(1, scalar)\n\n                for {\n                    // Shift n right by 1 before looping to halve it.\n                    n := shr(1, n)\n                } n {\n                    // Shift n right by 1 each iteration to halve it.\n                    n := shr(1, n)\n                } {\n                    // Revert immediately if x ** 2 would overflow.\n                    // Equivalent to iszero(eq(div(xx, x), x)) here.\n                    if shr(128, x) {\n                        revert(0, 0)\n                    }\n\n                    // Store x squared.\n                    let xx := mul(x, x)\n\n                    // Round to the nearest number.\n                    let xxRound := add(xx, half)\n\n                    // Revert if xx + half overflowed.\n                    if lt(xxRound, xx) {\n                        revert(0, 0)\n                    }\n\n                    // Set x to scaled xxRound.\n                    x := div(xxRound, scalar)\n\n                    // If n is even:\n                    if mod(n, 2) {\n                        // Compute z * x.\n                        let zx := mul(z, x)\n\n                        // If z * x overflowed:\n                        if iszero(eq(div(zx, x), z)) {\n                            // Revert if x is non-zero.\n                            if iszero(iszero(x)) {\n                                revert(0, 0)\n                            }\n                        }\n\n                        // Round to the nearest number.\n                        let zxRound := add(zx, half)\n\n                        // Revert if zx + half overflowed.\n                        if lt(zxRound, zx) {\n                            revert(0, 0)\n                        }\n\n                        // Return properly scaled zxRound.\n                        z := div(zxRound, scalar)\n                    }\n                }\n            }\n        }\n    }\n\n    /*//////////////////////////////////////////////////////////////\n                        GENERAL NUMBER UTILITIES\n    //////////////////////////////////////////////////////////////*/\n\n    function sqrt(uint256 x) internal pure returns (uint256 z) {\n        assembly {\n            let y := x // We start y at x, which will help us make our initial estimate.\n\n            z := 181 // The \"correct\" value is 1, but this saves a multiplication later.\n\n            // This segment is to get a reasonable initial estimate for the Babylonian method. With a bad\n            // start, the correct # of bits increases ~linearly each iteration instead of ~quadratically.\n\n            // We check y >= 2^(k + 8) but shift right by k bits\n            // each branch to ensure that if x >= 256, then y >= 256.\n            if iszero(lt(y, 0x10000000000000000000000000000000000)) {\n                y := shr(128, y)\n                z := shl(64, z)\n            }\n            if iszero(lt(y, 0x1000000000000000000)) {\n                y := shr(64, y)\n                z := shl(32, z)\n            }\n            if iszero(lt(y, 0x10000000000)) {\n                y := shr(32, y)\n                z := shl(16, z)\n            }\n            if iszero(lt(y, 0x1000000)) {\n                y := shr(16, y)\n                z := shl(8, z)\n            }\n\n            // Goal was to get z*z*y within a small factor of x. More iterations could\n            // get y in a tighter range. Currently, we will have y in [256, 256*2^16).\n            // We ensured y >= 256 so that the relative difference between y and y+1 is small.\n            // That's not possible if x < 256 but we can just verify those cases exhaustively.\n\n            // Now, z*z*y <= x < z*z*(y+1), and y <= 2^(16+8), and either y >= 256, or x < 256.\n            // Correctness can be checked exhaustively for x < 256, so we assume y >= 256.\n            // Then z*sqrt(y) is within sqrt(257)/sqrt(256) of sqrt(x), or about 20bps.\n\n            // For s in the range [1/256, 256], the estimate f(s) = (181/1024) * (s+1) is in the range\n            // (1/2.84 * sqrt(s), 2.84 * sqrt(s)), with largest error when s = 1 and when s = 256 or 1/256.\n\n            // Since y is in [256, 256*2^16), let a = y/65536, so that a is in [1/256, 256). Then we can estimate\n            // sqrt(y) using sqrt(65536) * 181/1024 * (a + 1) = 181/4 * (y + 65536)/65536 = 181 * (y + 65536)/2^18.\n\n            // There is no overflow risk here since y < 2^136 after the first branch above.\n            z := shr(18, mul(z, add(y, 65536))) // A mul() is saved from starting z at 181.\n\n            // Given the worst case multiplicative error of 2.84 above, 7 iterations should be enough.\n            z := shr(1, add(z, div(x, z)))\n            z := shr(1, add(z, div(x, z)))\n            z := shr(1, add(z, div(x, z)))\n            z := shr(1, add(z, div(x, z)))\n            z := shr(1, add(z, div(x, z)))\n            z := shr(1, add(z, div(x, z)))\n            z := shr(1, add(z, div(x, z)))\n\n            // If x+1 is a perfect square, the Babylonian method cycles between\n            // floor(sqrt(x)) and ceil(sqrt(x)). This statement ensures we return floor.\n            // See: https://en.wikipedia.org/wiki/Integer_square_root#Using_only_integer_division\n            // Since the ceil is rare, we save gas on the assignment and repeat division in the rare case.\n            // If you don't care whether the floor or ceil square root is returned, you can remove this statement.\n            z := sub(z, lt(div(x, z), z))\n        }\n    }\n\n    function log2(uint256 x) internal pure returns (uint256 r) {\n        require(x > 0, \"UNDEFINED\");\n\n        assembly {\n            r := shl(7, lt(0xffffffffffffffffffffffffffffffff, x))\n            r := or(r, shl(6, lt(0xffffffffffffffff, shr(r, x))))\n            r := or(r, shl(5, lt(0xffffffff, shr(r, x))))\n            r := or(r, shl(4, lt(0xffff, shr(r, x))))\n            r := or(r, shl(3, lt(0xff, shr(r, x))))\n            r := or(r, shl(2, lt(0xf, shr(r, x))))\n            r := or(r, shl(1, lt(0x3, shr(r, x))))\n            r := or(r, lt(0x1, shr(r, x)))\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "@rari-capital/solmate/=lib/solmate/",
        "@cwia/=lib/clones-with-immutable-args/src/",
        "@lib-keccak/=lib/lib-keccak/contracts/lib/",
        "forge-std/=lib/forge-std/src/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "safe-contracts/=lib/safe-contracts/contracts/",
        "kontrol-cheatcodes/=lib/kontrol-cheatcodes/src/",
        "solady/=lib/solady/src/",
        "clones-with-immutable-args/=lib/clones-with-immutable-args/src/",
        "lib-keccak/=lib/lib-keccak/contracts/",
        "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/",
        "solmate/=lib/solmate/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 999999
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "none"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "libraries": {}
    }
  }}