creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/L1/L1CrossDomainMessenger.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { Predeploys } from \"src/libraries/Predeploys.sol\";\nimport { OptimismPortal } from \"src/L1/OptimismPortal.sol\";\nimport { CrossDomainMessenger } from \"src/universal/CrossDomainMessenger.sol\";\nimport { ISemver } from \"src/universal/ISemver.sol\";\nimport { SuperchainConfig } from \"src/L1/SuperchainConfig.sol\";\nimport { SystemConfig } from \"src/L1/SystemConfig.sol\";\n\n/// @custom:proxied\n/// @title L1CrossDomainMessenger\n/// @notice The L1CrossDomainMessenger is a message passing interface between L1 and L2 responsible\n///         for sending and receiving data on the L1 side. Users are encouraged to use this\n///         interface instead of interacting with lower-level contracts directly.\ncontract L1CrossDomainMessenger is CrossDomainMessenger, ISemver {\n    /// @notice Contract of the SuperchainConfig.\n    SuperchainConfig public superchainConfig;\n\n    /// @notice Contract of the OptimismPortal.\n    /// @custom:network-specific\n    OptimismPortal public portal;\n\n    /// @notice Address of the SystemConfig contract.\n    SystemConfig public systemConfig;\n\n    /// @notice Semantic version.\n    /// @custom:semver 2.4.0\n    string public constant version = \"2.4.0\";\n\n    /// @notice Constructs the L1CrossDomainMessenger contract.\n    constructor() CrossDomainMessenger() {\n        initialize({\n            _superchainConfig: SuperchainConfig(address(0)),\n            _portal: OptimismPortal(payable(address(0))),\n            _systemConfig: SystemConfig(address(0))\n        });\n    }\n\n    /// @notice Initializes the contract.\n    /// @param _superchainConfig Contract of the SuperchainConfig contract on this network.\n    /// @param _portal Contract of the OptimismPortal contract on this network.\n    /// @param _systemConfig Contract of the SystemConfig contract on this network.\n    function initialize(\n        SuperchainConfig _superchainConfig,\n        OptimismPortal _portal,\n        SystemConfig _systemConfig\n    )\n        public\n        initializer\n    {\n        superchainConfig = _superchainConfig;\n        portal = _portal;\n        systemConfig = _systemConfig;\n        __CrossDomainMessenger_init({ _otherMessenger: CrossDomainMessenger(Predeploys.L2_CROSS_DOMAIN_MESSENGER) });\n    }\n\n    /// @inheritdoc CrossDomainMessenger\n    function gasPayingToken() internal view override returns (address _addr, uint8 _decimals) {\n        (_addr, _decimals) = systemConfig.gasPayingToken();\n    }\n\n    /// @notice Getter function for the OptimismPortal contract on this chain.\n    ///         Public getter is legacy and will be removed in the future. Use `portal()` instead.\n    /// @return Contract of the OptimismPortal on this chain.\n    /// @custom:legacy\n    function PORTAL() external view returns (OptimismPortal) {\n        return portal;\n    }\n\n    /// @inheritdoc CrossDomainMessenger\n    function _sendMessage(address _to, uint64 _gasLimit, uint256 _value, bytes memory _data) internal override {\n        portal.depositTransaction{ value: _value }({\n            _to: _to,\n            _value: _value,\n            _gasLimit: _gasLimit,\n            _isCreation: false,\n            _data: _data\n        });\n    }\n\n    /// @inheritdoc CrossDomainMessenger\n    function _isOtherMessenger() internal view override returns (bool) {\n        return msg.sender == address(portal) && portal.l2Sender() == address(otherMessenger);\n    }\n\n    /// @inheritdoc CrossDomainMessenger\n    function _isUnsafeTarget(address _target) internal view override returns (bool) {\n        return _target == address(this) || _target == address(portal);\n    }\n\n    /// @inheritdoc CrossDomainMessenger\n    function paused() public view override returns (bool) {\n        return superchainConfig.paused();\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 protocol contracts that are pre-deployed to the L2 system.\n//          This excludes the preinstalls (non-protocol contracts).\nlibrary Predeploys {\n    /// @notice Number of predeploy-namespace addresses reserved for protocol usage.\n    uint256 internal constant PREDEPLOY_COUNT = 2048;\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    /// @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    ///         Not embedded into new OP-Stack chains.\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 WETH contract.\n    address internal constant WETH = 0x4200000000000000000000000000000000000006;\n\n    /// @notice Address of the L2CrossDomainMessenger predeploy.\n    address internal constant L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000007;\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    /// @notice Address of the L2StandardBridge predeploy.\n    address internal constant L2_STANDARD_BRIDGE = 0x4200000000000000000000000000000000000010;\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    /// @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    /// @notice Address of the L2ERC721Bridge predeploy.\n    address internal constant L2_ERC721_BRIDGE = 0x4200000000000000000000000000000000000014;\n\n    /// @notice Address of the L1Block predeploy.\n    address internal constant L1_BLOCK_ATTRIBUTES = 0x4200000000000000000000000000000000000015;\n\n    /// @notice Address of the L2ToL1MessagePasser predeploy.\n    address internal constant L2_TO_L1_MESSAGE_PASSER = 0x4200000000000000000000000000000000000016;\n\n    /// @notice Address of the OptimismMintableERC721Factory predeploy.\n    address internal constant OPTIMISM_MINTABLE_ERC721_FACTORY = 0x4200000000000000000000000000000000000017;\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 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 GovernanceToken predeploy.\n    address internal constant GOVERNANCE_TOKEN = 0x4200000000000000000000000000000000000042;\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    /// @notice Address of the CrossL2Inbox predeploy.\n    address internal constant CROSS_L2_INBOX = 0x4200000000000000000000000000000000000022;\n\n    /// @notice Address of the L2ToL2CrossDomainMessenger predeploy.\n    address internal constant L2_TO_L2_CROSS_DOMAIN_MESSENGER = 0x4200000000000000000000000000000000000023;\n\n    /// @notice Returns the name of the predeploy at the given address.\n    function getName(address _addr) internal pure returns (string memory out_) {\n        require(isPredeployNamespace(_addr), \"Predeploys: address must be a predeploy\");\n        if (_addr == LEGACY_MESSAGE_PASSER) return \"LegacyMessagePasser\";\n        if (_addr == L1_MESSAGE_SENDER) return \"L1MessageSender\";\n        if (_addr == DEPLOYER_WHITELIST) return \"DeployerWhitelist\";\n        if (_addr == WETH) return \"WETH\";\n        if (_addr == L2_CROSS_DOMAIN_MESSENGER) return \"L2CrossDomainMessenger\";\n        if (_addr == GAS_PRICE_ORACLE) return \"GasPriceOracle\";\n        if (_addr == L2_STANDARD_BRIDGE) return \"L2StandardBridge\";\n        if (_addr == SEQUENCER_FEE_WALLET) return \"SequencerFeeVault\";\n        if (_addr == OPTIMISM_MINTABLE_ERC20_FACTORY) return \"OptimismMintableERC20Factory\";\n        if (_addr == L1_BLOCK_NUMBER) return \"L1BlockNumber\";\n        if (_addr == L2_ERC721_BRIDGE) return \"L2ERC721Bridge\";\n        if (_addr == L1_BLOCK_ATTRIBUTES) return \"L1Block\";\n        if (_addr == L2_TO_L1_MESSAGE_PASSER) return \"L2ToL1MessagePasser\";\n        if (_addr == OPTIMISM_MINTABLE_ERC721_FACTORY) return \"OptimismMintableERC721Factory\";\n        if (_addr == PROXY_ADMIN) return \"ProxyAdmin\";\n        if (_addr == BASE_FEE_VAULT) return \"BaseFeeVault\";\n        if (_addr == L1_FEE_VAULT) return \"L1FeeVault\";\n        if (_addr == SCHEMA_REGISTRY) return \"SchemaRegistry\";\n        if (_addr == EAS) return \"EAS\";\n        if (_addr == GOVERNANCE_TOKEN) return \"GovernanceToken\";\n        if (_addr == LEGACY_ERC20_ETH) return \"LegacyERC20ETH\";\n        if (_addr == CROSS_L2_INBOX) return \"CrossL2Inbox\";\n        if (_addr == L2_TO_L2_CROSS_DOMAIN_MESSENGER) return \"L2ToL2CrossDomainMessenger\";\n        revert(\"Predeploys: unnamed predeploy\");\n    }\n\n    /// @notice Returns true if the predeploy is not proxied.\n    function notProxied(address _addr) internal pure returns (bool) {\n        return _addr == GOVERNANCE_TOKEN || _addr == WETH;\n    }\n\n    /// @notice Returns true if the address is a defined predeploy that is embedded into new OP-Stack chains.\n    function isSupportedPredeploy(address _addr, bool _useInterop) internal pure returns (bool) {\n        return _addr == LEGACY_MESSAGE_PASSER || _addr == DEPLOYER_WHITELIST || _addr == WETH\n            || _addr == L2_CROSS_DOMAIN_MESSENGER || _addr == GAS_PRICE_ORACLE || _addr == L2_STANDARD_BRIDGE\n            || _addr == SEQUENCER_FEE_WALLET || _addr == OPTIMISM_MINTABLE_ERC20_FACTORY || _addr == L1_BLOCK_NUMBER\n            || _addr == L2_ERC721_BRIDGE || _addr == L1_BLOCK_ATTRIBUTES || _addr == L2_TO_L1_MESSAGE_PASSER\n            || _addr == OPTIMISM_MINTABLE_ERC721_FACTORY || _addr == PROXY_ADMIN || _addr == BASE_FEE_VAULT\n            || _addr == L1_FEE_VAULT || _addr == SCHEMA_REGISTRY || _addr == EAS || _addr == GOVERNANCE_TOKEN\n            || (_useInterop && _addr == CROSS_L2_INBOX) || (_useInterop && _addr == L2_TO_L2_CROSS_DOMAIN_MESSENGER);\n    }\n\n    function isPredeployNamespace(address _addr) internal pure returns (bool) {\n        return uint160(_addr) >> 11 == uint160(0x4200000000000000000000000000000000000000) >> 11;\n    }\n\n    /// @notice Function to compute the expected address of the predeploy implementation\n    ///         in the genesis state.\n    function predeployToCodeNamespace(address _addr) internal pure returns (address) {\n        require(\n            isPredeployNamespace(_addr), \"Predeploys: can only derive code-namespace address for predeploy addresses\"\n        );\n        return address(\n            uint160(uint256(uint160(_addr)) & 0xffff | uint256(uint160(0xc0D3C0d3C0d3C0D3c0d3C0d3c0D3C0d3c0d30000)))\n        );\n    }\n}\n"
      },
      "src/L1/OptimismPortal.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { Initializable } from \"@openzeppelin/contracts/proxy/utils/Initializable.sol\";\nimport { SafeCall } from \"src/libraries/SafeCall.sol\";\nimport { L2OutputOracle } from \"src/L1/L2OutputOracle.sol\";\nimport { SystemConfig } from \"src/L1/SystemConfig.sol\";\nimport { SuperchainConfig } from \"src/L1/SuperchainConfig.sol\";\nimport { Constants } from \"src/libraries/Constants.sol\";\nimport { Types } from \"src/libraries/Types.sol\";\nimport { Hashing } from \"src/libraries/Hashing.sol\";\nimport { SecureMerkleTrie } from \"src/libraries/trie/SecureMerkleTrie.sol\";\nimport { AddressAliasHelper } from \"src/vendor/AddressAliasHelper.sol\";\nimport { ResourceMetering } from \"src/L1/ResourceMetering.sol\";\nimport { ISemver } from \"src/universal/ISemver.sol\";\nimport { SafeERC20 } from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport { IERC20 } from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport { L1Block } from \"src/L2/L1Block.sol\";\nimport { Predeploys } from \"src/libraries/Predeploys.sol\";\nimport \"src/libraries/PortalErrors.sol\";\n\n/// @custom:proxied\n/// @title OptimismPortal\n/// @notice The OptimismPortal is a low-level contract responsible for passing messages between L1\n///         and L2. Messages sent directly to the OptimismPortal have no form of replayability.\n///         Users are encouraged to use the L1CrossDomainMessenger for a higher-level interface.\ncontract OptimismPortal is Initializable, ResourceMetering, ISemver {\n    /// @notice Allows for interactions with non standard ERC20 tokens.\n    using SafeERC20 for IERC20;\n\n    /// @notice Represents a proven withdrawal.\n    /// @custom:field outputRoot    Root of the L2 output this was proven against.\n    /// @custom:field timestamp     Timestamp at whcih the withdrawal was proven.\n    /// @custom:field l2OutputIndex Index of the output this was proven against.\n    struct ProvenWithdrawal {\n        bytes32 outputRoot;\n        uint128 timestamp;\n        uint128 l2OutputIndex;\n    }\n\n    /// @notice Version of the deposit event.\n    uint256 internal constant DEPOSIT_VERSION = 0;\n\n    /// @notice The L2 gas limit set when eth is deposited using the receive() function.\n    uint64 internal constant RECEIVE_DEFAULT_GAS_LIMIT = 100_000;\n\n    /// @notice The L2 gas limit for system deposit transactions that are initiated from L1.\n    uint32 internal constant SYSTEM_DEPOSIT_GAS_LIMIT = 200_000;\n\n    /// @notice Address of the L2 account which initiated a withdrawal in this transaction.\n    ///         If the of this variable is the default L2 sender address, then we are NOT inside of\n    ///         a call to finalizeWithdrawalTransaction.\n    address public l2Sender;\n\n    /// @notice A list of withdrawal hashes which have been successfully finalized.\n    mapping(bytes32 => bool) public finalizedWithdrawals;\n\n    /// @notice A mapping of withdrawal hashes to `ProvenWithdrawal` data.\n    mapping(bytes32 => ProvenWithdrawal) public provenWithdrawals;\n\n    /// @custom:legacy\n    /// @custom:spacer paused\n    /// @notice Spacer for backwards compatibility.\n    bool private spacer_53_0_1;\n\n    /// @notice Contract of the Superchain Config.\n    SuperchainConfig public superchainConfig;\n\n    /// @notice Contract of the L2OutputOracle.\n    /// @custom:network-specific\n    L2OutputOracle public l2Oracle;\n\n    /// @notice Contract of the SystemConfig.\n    /// @custom:network-specific\n    SystemConfig public systemConfig;\n\n    /// @custom:spacer disputeGameFactory\n    /// @notice Spacer for backwards compatibility.\n    address private spacer_56_0_20;\n\n    /// @custom:spacer provenWithdrawals\n    /// @notice Spacer for backwards compatibility.\n    bytes32 private spacer_57_0_32;\n\n    /// @custom:spacer disputeGameBlacklist\n    /// @notice Spacer for backwards compatibility.\n    bytes32 private spacer_58_0_32;\n\n    /// @custom:spacer respectedGameType + respectedGameTypeUpdatedAt\n    /// @notice Spacer for backwards compatibility.\n    bytes32 private spacer_59_0_32;\n\n    /// @custom:spacer proofSubmitters\n    /// @notice Spacer for backwards compatibility.\n    bytes32 private spacer_60_0_32;\n\n    /// @notice Represents the amount of native asset minted in L2. This may not\n    ///         be 100% accurate due to the ability to send ether to the contract\n    ///         without triggering a deposit transaction. It also is used to prevent\n    ///         overflows for L2 account balances when custom gas tokens are used.\n    ///         It is not safe to trust `ERC20.balanceOf` as it may lie.\n    uint256 internal _balance;\n\n    /// @notice Emitted when a transaction is deposited from L1 to L2.\n    ///         The parameters of this event are read by the rollup node and used to derive deposit\n    ///         transactions on L2.\n    /// @param from       Address that triggered the deposit transaction.\n    /// @param to         Address that the deposit transaction is directed to.\n    /// @param version    Version of this deposit transaction event.\n    /// @param opaqueData ABI encoded deposit data to be parsed off-chain.\n    event TransactionDeposited(address indexed from, address indexed to, uint256 indexed version, bytes opaqueData);\n\n    /// @notice Emitted when a withdrawal transaction is proven.\n    /// @param withdrawalHash Hash of the withdrawal transaction.\n    /// @param from           Address that triggered the withdrawal transaction.\n    /// @param to             Address that the withdrawal transaction is directed to.\n    event WithdrawalProven(bytes32 indexed withdrawalHash, address indexed from, address indexed to);\n\n    /// @notice Emitted when a withdrawal transaction is finalized.\n    /// @param withdrawalHash Hash of the withdrawal transaction.\n    /// @param success        Whether the withdrawal transaction was successful.\n    event WithdrawalFinalized(bytes32 indexed withdrawalHash, bool success);\n\n    /// @notice Reverts when paused.\n    modifier whenNotPaused() {\n        if (paused()) revert CallPaused();\n        _;\n    }\n\n    /// @notice Semantic version.\n    /// @custom:semver 2.8.1-beta.1\n    function version() public pure virtual returns (string memory) {\n        return \"2.8.1-beta.1\";\n    }\n\n    /// @notice Constructs the OptimismPortal contract.\n    constructor() {\n        initialize({\n            _l2Oracle: L2OutputOracle(address(0)),\n            _systemConfig: SystemConfig(address(0)),\n            _superchainConfig: SuperchainConfig(address(0))\n        });\n    }\n\n    /// @notice Initializer.\n    /// @param _l2Oracle Contract of the L2OutputOracle.\n    /// @param _systemConfig Contract of the SystemConfig.\n    /// @param _superchainConfig Contract of the SuperchainConfig.\n    function initialize(\n        L2OutputOracle _l2Oracle,\n        SystemConfig _systemConfig,\n        SuperchainConfig _superchainConfig\n    )\n        public\n        initializer\n    {\n        l2Oracle = _l2Oracle;\n        systemConfig = _systemConfig;\n        superchainConfig = _superchainConfig;\n        if (l2Sender == address(0)) {\n            l2Sender = Constants.DEFAULT_L2_SENDER;\n        }\n        __ResourceMetering_init();\n    }\n\n    /// @notice Getter for the balance of the contract.\n    function balance() public view returns (uint256) {\n        (address token,) = gasPayingToken();\n        if (token == Constants.ETHER) {\n            return address(this).balance;\n        } else {\n            return _balance;\n        }\n    }\n\n    /// @notice Getter function for the address of the guardian.\n    ///         Public getter is legacy and will be removed in the future. Use `SuperchainConfig.guardian()` instead.\n    /// @return Address of the guardian.\n    /// @custom:legacy\n    function guardian() public view returns (address) {\n        return superchainConfig.guardian();\n    }\n\n    /// @notice Getter for the current paused status.\n    /// @return paused_ Whether or not the contract is paused.\n    function paused() public view returns (bool paused_) {\n        paused_ = superchainConfig.paused();\n    }\n\n    /// @notice Computes the minimum gas limit for a deposit.\n    ///         The minimum gas limit linearly increases based on the size of the calldata.\n    ///         This is to prevent users from creating L2 resource usage without paying for it.\n    ///         This function can be used when interacting with the portal to ensure forwards\n    ///         compatibility.\n    /// @param _byteCount Number of bytes in the calldata.\n    /// @return The minimum gas limit for a deposit.\n    function minimumGasLimit(uint64 _byteCount) public pure returns (uint64) {\n        return _byteCount * 16 + 21000;\n    }\n\n    /// @notice Accepts value so that users can send ETH directly to this contract and have the\n    ///         funds be deposited to their address on L2. This is intended as a convenience\n    ///         function for EOAs. Contracts should call the depositTransaction() function directly\n    ///         otherwise any deposited funds will be lost due to address aliasing.\n    receive() external payable {\n        depositTransaction(msg.sender, msg.value, RECEIVE_DEFAULT_GAS_LIMIT, false, bytes(\"\"));\n    }\n\n    /// @notice Accepts ETH value without triggering a deposit to L2.\n    ///         This function mainly exists for the sake of the migration between the legacy\n    ///         Optimism system and Bedrock.\n    function donateETH() external payable {\n        // Intentionally empty.\n    }\n\n    /// @notice Returns the gas paying token and its decimals.\n    function gasPayingToken() internal view returns (address addr_, uint8 decimals_) {\n        (addr_, decimals_) = systemConfig.gasPayingToken();\n    }\n\n    /// @notice Getter for the resource config.\n    ///         Used internally by the ResourceMetering contract.\n    ///         The SystemConfig is the source of truth for the resource config.\n    /// @return ResourceMetering ResourceConfig\n    function _resourceConfig() internal view override returns (ResourceMetering.ResourceConfig memory) {\n        return systemConfig.resourceConfig();\n    }\n\n    /// @notice Proves a withdrawal transaction.\n    /// @param _tx              Withdrawal transaction to finalize.\n    /// @param _l2OutputIndex   L2 output index to prove against.\n    /// @param _outputRootProof Inclusion proof of the L2ToL1MessagePasser contract's storage root.\n    /// @param _withdrawalProof Inclusion proof of the withdrawal in L2ToL1MessagePasser contract.\n    function proveWithdrawalTransaction(\n        Types.WithdrawalTransaction memory _tx,\n        uint256 _l2OutputIndex,\n        Types.OutputRootProof calldata _outputRootProof,\n        bytes[] calldata _withdrawalProof\n    )\n        external\n        whenNotPaused\n    {\n        // Prevent users from creating a deposit transaction where this address is the message\n        // sender on L2. Because this is checked here, we do not need to check again in\n        // `finalizeWithdrawalTransaction`.\n        if (_tx.target == address(this)) revert BadTarget();\n\n        // Get the output root and load onto the stack to prevent multiple mloads. This will\n        // revert if there is no output root for the given block number.\n        bytes32 outputRoot = l2Oracle.getL2Output(_l2OutputIndex).outputRoot;\n\n        // Verify that the output root can be generated with the elements in the proof.\n        require(\n            outputRoot == Hashing.hashOutputRootProof(_outputRootProof), \"OptimismPortal: invalid output root proof\"\n        );\n\n        // Load the ProvenWithdrawal into memory, using the withdrawal hash as a unique identifier.\n        bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);\n        ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash];\n\n        // We generally want to prevent users from proving the same withdrawal multiple times\n        // because each successive proof will update the timestamp. A malicious user can take\n        // advantage of this to prevent other users from finalizing their withdrawal. However,\n        // since withdrawals are proven before an output root is finalized, we need to allow users\n        // to re-prove their withdrawal only in the case that the output root for their specified\n        // output index has been updated.\n        require(\n            provenWithdrawal.timestamp == 0\n                || l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex).outputRoot != provenWithdrawal.outputRoot,\n            \"OptimismPortal: withdrawal hash has already been proven\"\n        );\n\n        // Compute the storage slot of the withdrawal hash in the L2ToL1MessagePasser contract.\n        // Refer to the Solidity documentation for more information on how storage layouts are\n        // computed for mappings.\n        bytes32 storageKey = keccak256(\n            abi.encode(\n                withdrawalHash,\n                uint256(0) // The withdrawals mapping is at the first slot in the layout.\n            )\n        );\n\n        // Verify that the hash of this withdrawal was stored in the L2toL1MessagePasser contract\n        // on L2. If this is true, under the assumption that the SecureMerkleTrie does not have\n        // bugs, then we know that this withdrawal was actually triggered on L2 and can therefore\n        // be relayed on L1.\n        require(\n            SecureMerkleTrie.verifyInclusionProof({\n                _key: abi.encode(storageKey),\n                _value: hex\"01\",\n                _proof: _withdrawalProof,\n                _root: _outputRootProof.messagePasserStorageRoot\n            }),\n            \"OptimismPortal: invalid withdrawal inclusion proof\"\n        );\n\n        // Designate the withdrawalHash as proven by storing the `outputRoot`, `timestamp`, and\n        // `l2BlockNumber` in the `provenWithdrawals` mapping. A `withdrawalHash` can only be\n        // proven once unless it is submitted again with a different outputRoot.\n        provenWithdrawals[withdrawalHash] = ProvenWithdrawal({\n            outputRoot: outputRoot,\n            timestamp: uint128(block.timestamp),\n            l2OutputIndex: uint128(_l2OutputIndex)\n        });\n\n        // Emit a `WithdrawalProven` event.\n        emit WithdrawalProven(withdrawalHash, _tx.sender, _tx.target);\n    }\n\n    /// @notice Finalizes a withdrawal transaction.\n    /// @param _tx Withdrawal transaction to finalize.\n    function finalizeWithdrawalTransaction(Types.WithdrawalTransaction memory _tx) external whenNotPaused {\n        // Make sure that the l2Sender has not yet been set. The l2Sender is set to a value other\n        // than the default value when a withdrawal transaction is being finalized. This check is\n        // a defacto reentrancy guard.\n        if (l2Sender != Constants.DEFAULT_L2_SENDER) revert NonReentrant();\n\n        // Grab the proven withdrawal from the `provenWithdrawals` map.\n        bytes32 withdrawalHash = Hashing.hashWithdrawal(_tx);\n        ProvenWithdrawal memory provenWithdrawal = provenWithdrawals[withdrawalHash];\n\n        // A withdrawal can only be finalized if it has been proven. We know that a withdrawal has\n        // been proven at least once when its timestamp is non-zero. Unproven withdrawals will have\n        // a timestamp of zero.\n        require(provenWithdrawal.timestamp != 0, \"OptimismPortal: withdrawal has not been proven yet\");\n\n        // As a sanity check, we make sure that the proven withdrawal's timestamp is greater than\n        // starting timestamp inside the L2OutputOracle. Not strictly necessary but extra layer of\n        // safety against weird bugs in the proving step.\n        require(\n            provenWithdrawal.timestamp >= l2Oracle.startingTimestamp(),\n            \"OptimismPortal: withdrawal timestamp less than L2 Oracle starting timestamp\"\n        );\n\n        // A proven withdrawal must wait at least the finalization period before it can be\n        // finalized. This waiting period can elapse in parallel with the waiting period for the\n        // output the withdrawal was proven against. In effect, this means that the minimum\n        // withdrawal time is proposal submission time + finalization period.\n        require(\n            _isFinalizationPeriodElapsed(provenWithdrawal.timestamp),\n            \"OptimismPortal: proven withdrawal finalization period has not elapsed\"\n        );\n\n        // Grab the OutputProposal from the L2OutputOracle, will revert if the output that\n        // corresponds to the given index has not been proposed yet.\n        Types.OutputProposal memory proposal = l2Oracle.getL2Output(provenWithdrawal.l2OutputIndex);\n\n        // Check that the output root that was used to prove the withdrawal is the same as the\n        // current output root for the given output index. An output root may change if it is\n        // deleted by the challenger address and then re-proposed.\n        require(\n            proposal.outputRoot == provenWithdrawal.outputRoot,\n            \"OptimismPortal: output root proven is not the same as current output root\"\n        );\n\n        // Check that the output proposal has also been finalized.\n        require(\n            _isFinalizationPeriodElapsed(proposal.timestamp),\n            \"OptimismPortal: output proposal finalization period has not elapsed\"\n        );\n\n        // Check that this withdrawal has not already been finalized, this is replay protection.\n        require(finalizedWithdrawals[withdrawalHash] == false, \"OptimismPortal: withdrawal has already been finalized\");\n\n        // Mark the withdrawal as finalized so it can't be replayed.\n        finalizedWithdrawals[withdrawalHash] = true;\n\n        // Set the l2Sender so contracts know who triggered this withdrawal on L2.\n        // This acts as a reentrancy guard.\n        l2Sender = _tx.sender;\n\n        bool success;\n        (address token,) = gasPayingToken();\n        if (token == Constants.ETHER) {\n            // Trigger the call to the target contract. We use a custom low level method\n            // SafeCall.callWithMinGas to ensure two key properties\n            //   1. Target contracts cannot force this call to run out of gas by returning a very large\n            //      amount of data (and this is OK because we don't care about the returndata here).\n            //   2. The amount of gas provided to the execution context of the target is at least the\n            //      gas limit specified by the user. If there is not enough gas in the current context\n            //      to accomplish this, `callWithMinGas` will revert.\n            success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, _tx.value, _tx.data);\n        } else {\n            // Cannot call the token contract directly from the portal. This would allow an attacker\n            // to call approve from a withdrawal and drain the balance of the portal.\n            if (_tx.target == token) revert BadTarget();\n\n            // Only transfer value when a non zero value is specified. This saves gas in the case of\n            // using the standard bridge or arbitrary message passing.\n            if (_tx.value != 0) {\n                // Update the contracts internal accounting of the amount of native asset in L2.\n                _balance -= _tx.value;\n\n                // Read the balance of the target contract before the transfer so the consistency\n                // of the transfer can be checked afterwards.\n                uint256 startBalance = IERC20(token).balanceOf(address(this));\n\n                // Transfer the ERC20 balance to the target, accounting for non standard ERC20\n                // implementations that may not return a boolean. This reverts if the low level\n                // call is not successful.\n                IERC20(token).safeTransfer({ to: _tx.target, value: _tx.value });\n\n                // The balance must be transferred exactly.\n                if (IERC20(token).balanceOf(address(this)) != startBalance - _tx.value) {\n                    revert TransferFailed();\n                }\n            }\n\n            // Make a call to the target contract only if there is calldata.\n            if (_tx.data.length != 0) {\n                success = SafeCall.callWithMinGas(_tx.target, _tx.gasLimit, 0, _tx.data);\n            } else {\n                success = true;\n            }\n        }\n\n        // Reset the l2Sender back to the default value.\n        l2Sender = Constants.DEFAULT_L2_SENDER;\n\n        // All withdrawals are immediately finalized. Replayability can\n        // be achieved through contracts built on top of this contract\n        emit WithdrawalFinalized(withdrawalHash, success);\n\n        // Reverting here is useful for determining the exact gas cost to successfully execute the\n        // sub call to the target contract if the minimum gas limit specified by the user would not\n        // be sufficient to execute the sub call.\n        if (success == false && tx.origin == Constants.ESTIMATION_ADDRESS) {\n            revert GasEstimation();\n        }\n    }\n\n    /// @notice Entrypoint to depositing an ERC20 token as a custom gas token.\n    ///         This function depends on a well formed ERC20 token. There are only\n    ///         so many checks that can be done on chain for this so it is assumed\n    ///         that chain operators will deploy chains with well formed ERC20 tokens.\n    /// @param _to         Target address on L2.\n    /// @param _mint       Units of ERC20 token to deposit into L2.\n    /// @param _value      Units of ERC20 token to send on L2 to the recipient.\n    /// @param _gasLimit   Amount of L2 gas to purchase by burning gas on L1.\n    /// @param _isCreation Whether or not the transaction is a contract creation.\n    /// @param _data       Data to trigger the recipient with.\n    function depositERC20Transaction(\n        address _to,\n        uint256 _mint,\n        uint256 _value,\n        uint64 _gasLimit,\n        bool _isCreation,\n        bytes memory _data\n    )\n        public\n        metered(_gasLimit)\n    {\n        // Can only be called if an ERC20 token is used for gas paying on L2\n        (address token,) = gasPayingToken();\n        if (token == Constants.ETHER) revert OnlyCustomGasToken();\n\n        // Gives overflow protection for L2 account balances.\n        _balance += _mint;\n\n        // Get the balance of the portal before the transfer.\n        uint256 startBalance = IERC20(token).balanceOf(address(this));\n\n        // Take ownership of the token. It is assumed that the user has given the portal an approval.\n        IERC20(token).safeTransferFrom({ from: msg.sender, to: address(this), value: _mint });\n\n        // Double check that the portal now has the exact amount of token.\n        if (IERC20(token).balanceOf(address(this)) != startBalance + _mint) {\n            revert TransferFailed();\n        }\n\n        _depositTransaction({\n            _to: _to,\n            _mint: _mint,\n            _value: _value,\n            _gasLimit: _gasLimit,\n            _isCreation: _isCreation,\n            _data: _data\n        });\n    }\n\n    /// @notice Accepts deposits of ETH and data, and emits a TransactionDeposited event for use in\n    ///         deriving deposit transactions. Note that if a deposit is made by a contract, its\n    ///         address will be aliased when retrieved using `tx.origin` or `msg.sender`. Consider\n    ///         using the CrossDomainMessenger contracts for a simpler developer experience.\n    /// @param _to         Target address on L2.\n    /// @param _value      ETH value to send to the recipient.\n    /// @param _gasLimit   Amount of L2 gas to purchase by burning gas on L1.\n    /// @param _isCreation Whether or not the transaction is a contract creation.\n    /// @param _data       Data to trigger the recipient with.\n    function depositTransaction(\n        address _to,\n        uint256 _value,\n        uint64 _gasLimit,\n        bool _isCreation,\n        bytes memory _data\n    )\n        public\n        payable\n        metered(_gasLimit)\n    {\n        (address token,) = gasPayingToken();\n        if (token != Constants.ETHER && msg.value != 0) revert NoValue();\n\n        _depositTransaction({\n            _to: _to,\n            _mint: msg.value,\n            _value: _value,\n            _gasLimit: _gasLimit,\n            _isCreation: _isCreation,\n            _data: _data\n        });\n    }\n\n    /// @notice Common logic for creating deposit transactions.\n    /// @param _to         Target address on L2.\n    /// @param _mint       Units of asset to deposit into L2.\n    /// @param _value      Units of asset to send on L2 to the recipient.\n    /// @param _gasLimit   Amount of L2 gas to purchase by burning gas on L1.\n    /// @param _isCreation Whether or not the transaction is a contract creation.\n    /// @param _data       Data to trigger the recipient with.\n    function _depositTransaction(\n        address _to,\n        uint256 _mint,\n        uint256 _value,\n        uint64 _gasLimit,\n        bool _isCreation,\n        bytes memory _data\n    )\n        internal\n    {\n        // Just to be safe, make sure that people specify address(0) as the target when doing\n        // contract creations.\n        if (_isCreation && _to != address(0)) revert BadTarget();\n\n        // Prevent depositing transactions that have too small of a gas limit. Users should pay\n        // more for more resource usage.\n        if (_gasLimit < minimumGasLimit(uint64(_data.length))) revert SmallGasLimit();\n\n        // Prevent the creation of deposit transactions that have too much calldata. This gives an\n        // upper limit on the size of unsafe blocks over the p2p network. 120kb is chosen to ensure\n        // that the transaction can fit into the p2p network policy of 128kb even though deposit\n        // transactions are not gossipped over the p2p network.\n        if (_data.length > 120_000) revert LargeCalldata();\n\n        // Transform the from-address to its alias if the caller is a contract.\n        address from = msg.sender;\n        if (msg.sender != tx.origin) {\n            from = AddressAliasHelper.applyL1ToL2Alias(msg.sender);\n        }\n\n        // Compute the opaque data that will be emitted as part of the TransactionDeposited event.\n        // We use opaque data so that we can update the TransactionDeposited event in the future\n        // without breaking the current interface.\n        bytes memory opaqueData = abi.encodePacked(_mint, _value, _gasLimit, _isCreation, _data);\n\n        // Emit a TransactionDeposited event so that the rollup node can derive a deposit\n        // transaction for this deposit.\n        emit TransactionDeposited(from, _to, DEPOSIT_VERSION, opaqueData);\n    }\n\n    /// @notice Sets the gas paying token for the L2 system. This token is used as the\n    ///         L2 native asset. Only the SystemConfig contract can call this function.\n    function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external {\n        if (msg.sender != address(systemConfig)) revert Unauthorized();\n\n        // Set L2 deposit gas as used without paying burning gas. Ensures that deposits cannot use too much L2 gas.\n        // This value must be large enough to cover the cost of calling `L1Block.setGasPayingToken`.\n        useGas(SYSTEM_DEPOSIT_GAS_LIMIT);\n\n        // Emit the special deposit transaction directly that sets the gas paying\n        // token in the L1Block predeploy contract.\n        emit TransactionDeposited(\n            Constants.DEPOSITOR_ACCOUNT,\n            Predeploys.L1_BLOCK_ATTRIBUTES,\n            DEPOSIT_VERSION,\n            abi.encodePacked(\n                uint256(0), // mint\n                uint256(0), // value\n                uint64(SYSTEM_DEPOSIT_GAS_LIMIT), // gasLimit\n                false, // isCreation,\n                abi.encodeCall(L1Block.setGasPayingToken, (_token, _decimals, _name, _symbol))\n            )\n        );\n    }\n\n    /// @notice Determine if a given output is finalized.\n    ///         Reverts if the call to l2Oracle.getL2Output reverts.\n    ///         Returns a boolean otherwise.\n    /// @param _l2OutputIndex Index of the L2 output to check.\n    /// @return Whether or not the output is finalized.\n    function isOutputFinalized(uint256 _l2OutputIndex) external view returns (bool) {\n        return _isFinalizationPeriodElapsed(l2Oracle.getL2Output(_l2OutputIndex).timestamp);\n    }\n\n    /// @notice Determines whether the finalization period has elapsed with respect to\n    ///         the provided block timestamp.\n    /// @param _timestamp Timestamp to check.\n    /// @return Whether or not the finalization period has elapsed.\n    function _isFinalizationPeriodElapsed(uint256 _timestamp) internal view returns (bool) {\n        return block.timestamp > _timestamp + l2Oracle.FINALIZATION_PERIOD_SECONDS();\n    }\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        if (isCustomGasToken()) {\n            require(msg.value == 0, \"CrossDomainMessenger: cannot send value with custom gas token\");\n        }\n\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 Returns the address of the gas token and the token's decimals.\n    function gasPayingToken() internal view virtual returns (address, uint8);\n\n    /// @notice Returns whether the chain uses a custom gas token or not.\n    function isCustomGasToken() internal view returns (bool) {\n        (address token,) = gasPayingToken();\n        return token != Constants.ETHER;\n    }\n\n    /// @notice Initializer.\n    /// @param _otherMessenger CrossDomainMessenger contract on the other chain.\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/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/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/L1/SystemConfig.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { OwnableUpgradeable } from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport { ISemver } from \"src/universal/ISemver.sol\";\nimport { ResourceMetering } from \"src/L1/ResourceMetering.sol\";\nimport { Storage } from \"src/libraries/Storage.sol\";\nimport { Constants } from \"src/libraries/Constants.sol\";\nimport { OptimismPortal } from \"src/L1/OptimismPortal.sol\";\nimport { GasPayingToken, IGasToken } from \"src/libraries/GasPayingToken.sol\";\nimport { ERC20 } from \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\n/// @title SystemConfig\n/// @notice The SystemConfig contract is used to manage configuration of an Optimism network.\n///         All configuration is stored on L1 and picked up by L2 as part of the derviation of\n///         the L2 chain.\ncontract SystemConfig is OwnableUpgradeable, ISemver, IGasToken {\n    /// @notice Enum representing different types of updates.\n    /// @custom:value BATCHER              Represents an update to the batcher hash.\n    /// @custom:value GAS_CONFIG           Represents an update to txn fee config on L2.\n    /// @custom:value GAS_LIMIT            Represents an update to gas limit on L2.\n    /// @custom:value UNSAFE_BLOCK_SIGNER  Represents an update to the signer key for unsafe\n    ///                                    block distrubution.\n    enum UpdateType {\n        BATCHER,\n        GAS_CONFIG,\n        GAS_LIMIT,\n        UNSAFE_BLOCK_SIGNER\n    }\n\n    /// @notice Struct representing the addresses of L1 system contracts. These should be the\n    ///         contracts that users interact with (not implementations for proxied contracts)\n    ///         and are network specific.\n    struct Addresses {\n        address l1CrossDomainMessenger;\n        address l1ERC721Bridge;\n        address l1StandardBridge;\n        address disputeGameFactory;\n        address optimismPortal;\n        address optimismMintableERC20Factory;\n        address gasPayingToken;\n    }\n\n    /// @notice Version identifier, used for upgrades.\n    uint256 public constant VERSION = 0;\n\n    /// @notice Storage slot that the unsafe block signer is stored at.\n    ///         Storing it at this deterministic storage slot allows for decoupling the storage\n    ///         layout from the way that `solc` lays out storage. The `op-node` uses a storage\n    ///         proof to fetch this value.\n    /// @dev    NOTE: this value will be migrated to another storage slot in a future version.\n    ///         User input should not be placed in storage in this contract until this migration\n    ///         happens. It is unlikely that keccak second preimage resistance will be broken,\n    ///         but it is better to be safe than sorry.\n    bytes32 public constant UNSAFE_BLOCK_SIGNER_SLOT = keccak256(\"systemconfig.unsafeblocksigner\");\n\n    /// @notice Storage slot that the L1CrossDomainMessenger address is stored at.\n    bytes32 public constant L1_CROSS_DOMAIN_MESSENGER_SLOT =\n        bytes32(uint256(keccak256(\"systemconfig.l1crossdomainmessenger\")) - 1);\n\n    /// @notice Storage slot that the L1ERC721Bridge address is stored at.\n    bytes32 public constant L1_ERC_721_BRIDGE_SLOT = bytes32(uint256(keccak256(\"systemconfig.l1erc721bridge\")) - 1);\n\n    /// @notice Storage slot that the L1StandardBridge address is stored at.\n    bytes32 public constant L1_STANDARD_BRIDGE_SLOT = bytes32(uint256(keccak256(\"systemconfig.l1standardbridge\")) - 1);\n\n    /// @notice Storage slot that the OptimismPortal address is stored at.\n    bytes32 public constant OPTIMISM_PORTAL_SLOT = bytes32(uint256(keccak256(\"systemconfig.optimismportal\")) - 1);\n\n    /// @notice Storage slot that the OptimismMintableERC20Factory address is stored at.\n    bytes32 public constant OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT =\n        bytes32(uint256(keccak256(\"systemconfig.optimismmintableerc20factory\")) - 1);\n\n    /// @notice Storage slot that the batch inbox address is stored at.\n    bytes32 public constant BATCH_INBOX_SLOT = bytes32(uint256(keccak256(\"systemconfig.batchinbox\")) - 1);\n\n    /// @notice Storage slot for block at which the op-node can start searching for logs from.\n    bytes32 public constant START_BLOCK_SLOT = bytes32(uint256(keccak256(\"systemconfig.startBlock\")) - 1);\n\n    /// @notice Storage slot for the DisputeGameFactory address.\n    bytes32 public constant DISPUTE_GAME_FACTORY_SLOT =\n        bytes32(uint256(keccak256(\"systemconfig.disputegamefactory\")) - 1);\n\n    /// @notice The number of decimals that the gas paying token has.\n    uint8 internal constant GAS_PAYING_TOKEN_DECIMALS = 18;\n\n    /// @notice The maximum gas limit that can be set for L2 blocks. This limit is used to enforce that the blocks\n    ///         on L2 are not too large to process and prove. Over time, this value can be increased as various\n    ///         optimizations and improvements are made to the system at large.\n    uint64 internal constant MAX_GAS_LIMIT = 200_000_000;\n\n    /// @notice Fixed L2 gas overhead. Used as part of the L2 fee calculation.\n    ///         Deprecated since the Ecotone network upgrade\n    uint256 public overhead;\n\n    /// @notice Dynamic L2 gas overhead. Used as part of the L2 fee calculation.\n    ///         The most significant byte is used to determine the version since the\n    ///         Ecotone network upgrade.\n    uint256 public scalar;\n\n    /// @notice Identifier for the batcher.\n    ///         For version 1 of this configuration, this is represented as an address left-padded\n    ///         with zeros to 32 bytes.\n    bytes32 public batcherHash;\n\n    /// @notice L2 block gas limit.\n    uint64 public gasLimit;\n\n    /// @notice Basefee scalar value. Part of the L2 fee calculation since the Ecotone network upgrade.\n    uint32 public basefeeScalar;\n\n    /// @notice Blobbasefee scalar value. Part of the L2 fee calculation since the Ecotone network upgrade.\n    uint32 public blobbasefeeScalar;\n\n    /// @notice The configuration for the deposit fee market.\n    ///         Used by the OptimismPortal to meter the cost of buying L2 gas on L1.\n    ///         Set as internal with a getter so that the struct is returned instead of a tuple.\n    ResourceMetering.ResourceConfig internal _resourceConfig;\n\n    /// @notice Emitted when configuration is updated.\n    /// @param version    SystemConfig version.\n    /// @param updateType Type of update.\n    /// @param data       Encoded update data.\n    event ConfigUpdate(uint256 indexed version, UpdateType indexed updateType, bytes data);\n\n    /// @notice Semantic version.\n    /// @custom:semver 2.3.0-beta.2\n    function version() public pure virtual returns (string memory) {\n        return \"2.3.0-beta.2\";\n    }\n\n    /// @notice Constructs the SystemConfig contract. Cannot set\n    ///         the owner to `address(0)` due to the Ownable contract's\n    ///         implementation, so set it to `address(0xdEaD)`\n    /// @dev    START_BLOCK_SLOT is set to type(uint256).max here so that it will be a dead value\n    ///         in the singleton and is skipped by initialize when setting the start block.\n    constructor() {\n        Storage.setUint(START_BLOCK_SLOT, type(uint256).max);\n        initialize({\n            _owner: address(0xdEaD),\n            _basefeeScalar: 0,\n            _blobbasefeeScalar: 0,\n            _batcherHash: bytes32(0),\n            _gasLimit: 1,\n            _unsafeBlockSigner: address(0),\n            _config: ResourceMetering.ResourceConfig({\n                maxResourceLimit: 1,\n                elasticityMultiplier: 1,\n                baseFeeMaxChangeDenominator: 2,\n                minimumBaseFee: 0,\n                systemTxMaxGas: 0,\n                maximumBaseFee: 0\n            }),\n            _batchInbox: address(0),\n            _addresses: SystemConfig.Addresses({\n                l1CrossDomainMessenger: address(0),\n                l1ERC721Bridge: address(0),\n                l1StandardBridge: address(0),\n                disputeGameFactory: address(0),\n                optimismPortal: address(0),\n                optimismMintableERC20Factory: address(0),\n                gasPayingToken: address(0)\n            })\n        });\n    }\n\n    /// @notice Initializer.\n    ///         The resource config must be set before the require check.\n    /// @param _owner             Initial owner of the contract.\n    /// @param _basefeeScalar     Initial basefee scalar value.\n    /// @param _blobbasefeeScalar Initial blobbasefee scalar value.\n    /// @param _batcherHash       Initial batcher hash.\n    /// @param _gasLimit          Initial gas limit.\n    /// @param _unsafeBlockSigner Initial unsafe block signer address.\n    /// @param _config            Initial ResourceConfig.\n    /// @param _batchInbox        Batch inbox address. An identifier for the op-node to find\n    ///                           canonical data.\n    /// @param _addresses         Set of L1 contract addresses. These should be the proxies.\n    function initialize(\n        address _owner,\n        uint32 _basefeeScalar,\n        uint32 _blobbasefeeScalar,\n        bytes32 _batcherHash,\n        uint64 _gasLimit,\n        address _unsafeBlockSigner,\n        ResourceMetering.ResourceConfig memory _config,\n        address _batchInbox,\n        SystemConfig.Addresses memory _addresses\n    )\n        public\n        initializer\n    {\n        __Ownable_init();\n        transferOwnership(_owner);\n\n        // These are set in ascending order of their UpdateTypes.\n        _setBatcherHash(_batcherHash);\n        _setGasConfigEcotone({ _basefeeScalar: _basefeeScalar, _blobbasefeeScalar: _blobbasefeeScalar });\n        _setGasLimit(_gasLimit);\n\n        Storage.setAddress(UNSAFE_BLOCK_SIGNER_SLOT, _unsafeBlockSigner);\n        Storage.setAddress(BATCH_INBOX_SLOT, _batchInbox);\n        Storage.setAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT, _addresses.l1CrossDomainMessenger);\n        Storage.setAddress(L1_ERC_721_BRIDGE_SLOT, _addresses.l1ERC721Bridge);\n        Storage.setAddress(L1_STANDARD_BRIDGE_SLOT, _addresses.l1StandardBridge);\n        Storage.setAddress(DISPUTE_GAME_FACTORY_SLOT, _addresses.disputeGameFactory);\n        Storage.setAddress(OPTIMISM_PORTAL_SLOT, _addresses.optimismPortal);\n        Storage.setAddress(OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT, _addresses.optimismMintableERC20Factory);\n\n        _setStartBlock();\n        _setGasPayingToken(_addresses.gasPayingToken);\n\n        _setResourceConfig(_config);\n        require(_gasLimit >= minimumGasLimit(), \"SystemConfig: gas limit too low\");\n    }\n\n    /// @notice Returns the minimum L2 gas limit that can be safely set for the system to\n    ///         operate. The L2 gas limit must be larger than or equal to the amount of\n    ///         gas that is allocated for deposits per block plus the amount of gas that\n    ///         is allocated for the system transaction.\n    ///         This function is used to determine if changes to parameters are safe.\n    /// @return uint64 Minimum gas limit.\n    function minimumGasLimit() public view returns (uint64) {\n        return uint64(_resourceConfig.maxResourceLimit) + uint64(_resourceConfig.systemTxMaxGas);\n    }\n\n    /// @notice Returns the maximum L2 gas limit that can be safely set for the system to\n    ///         operate. This bound is used to prevent the gas limit from being set too high\n    ///         and causing the system to be unable to process and/or prove L2 blocks.\n    /// @return uint64 Maximum gas limit.\n    function maximumGasLimit() public pure returns (uint64) {\n        return MAX_GAS_LIMIT;\n    }\n\n    /// @notice High level getter for the unsafe block signer address.\n    ///         Unsafe blocks can be propagated across the p2p network if they are signed by the\n    ///         key corresponding to this address.\n    /// @return addr_ Address of the unsafe block signer.\n    function unsafeBlockSigner() public view returns (address addr_) {\n        addr_ = Storage.getAddress(UNSAFE_BLOCK_SIGNER_SLOT);\n    }\n\n    /// @notice Getter for the L1CrossDomainMessenger address.\n    function l1CrossDomainMessenger() external view returns (address addr_) {\n        addr_ = Storage.getAddress(L1_CROSS_DOMAIN_MESSENGER_SLOT);\n    }\n\n    /// @notice Getter for the L1ERC721Bridge address.\n    function l1ERC721Bridge() external view returns (address addr_) {\n        addr_ = Storage.getAddress(L1_ERC_721_BRIDGE_SLOT);\n    }\n\n    /// @notice Getter for the L1StandardBridge address.\n    function l1StandardBridge() external view returns (address addr_) {\n        addr_ = Storage.getAddress(L1_STANDARD_BRIDGE_SLOT);\n    }\n\n    /// @notice Getter for the DisputeGameFactory address.\n    function disputeGameFactory() external view returns (address addr_) {\n        addr_ = Storage.getAddress(DISPUTE_GAME_FACTORY_SLOT);\n    }\n\n    /// @notice Getter for the OptimismPortal address.\n    function optimismPortal() public view returns (address addr_) {\n        addr_ = Storage.getAddress(OPTIMISM_PORTAL_SLOT);\n    }\n\n    /// @notice Getter for the OptimismMintableERC20Factory address.\n    function optimismMintableERC20Factory() external view returns (address addr_) {\n        addr_ = Storage.getAddress(OPTIMISM_MINTABLE_ERC20_FACTORY_SLOT);\n    }\n\n    /// @notice Getter for the BatchInbox address.\n    function batchInbox() external view returns (address addr_) {\n        addr_ = Storage.getAddress(BATCH_INBOX_SLOT);\n    }\n\n    /// @notice Getter for the StartBlock number.\n    function startBlock() external view returns (uint256 startBlock_) {\n        startBlock_ = Storage.getUint(START_BLOCK_SLOT);\n    }\n\n    /// @notice Getter for the gas paying asset address.\n    function gasPayingToken() public view returns (address addr_, uint8 decimals_) {\n        (addr_, decimals_) = GasPayingToken.getToken();\n    }\n\n    /// @notice Getter for custom gas token paying networks. Returns true if the\n    ///         network uses a custom gas token.\n    function isCustomGasToken() public view returns (bool) {\n        (address token,) = gasPayingToken();\n        return token != Constants.ETHER;\n    }\n\n    /// @notice Getter for the gas paying token name.\n    function gasPayingTokenName() external view returns (string memory name_) {\n        name_ = GasPayingToken.getName();\n    }\n\n    /// @notice Getter for the gas paying token symbol.\n    function gasPayingTokenSymbol() external view returns (string memory symbol_) {\n        symbol_ = GasPayingToken.getSymbol();\n    }\n\n    /// @notice Internal setter for the gas paying token address, includes validation.\n    ///         The token must not already be set and must be non zero and not the ether address\n    ///         to set the token address. This prevents the token address from being changed\n    ///         and makes it explicitly opt-in to use custom gas token.\n    /// @param _token Address of the gas paying token.\n    function _setGasPayingToken(address _token) internal virtual {\n        if (_token != address(0) && _token != Constants.ETHER && !isCustomGasToken()) {\n            require(\n                ERC20(_token).decimals() == GAS_PAYING_TOKEN_DECIMALS, \"SystemConfig: bad decimals of gas paying token\"\n            );\n            bytes32 name = GasPayingToken.sanitize(ERC20(_token).name());\n            bytes32 symbol = GasPayingToken.sanitize(ERC20(_token).symbol());\n\n            // Set the gas paying token in storage and in the OptimismPortal.\n            GasPayingToken.set({ _token: _token, _decimals: GAS_PAYING_TOKEN_DECIMALS, _name: name, _symbol: symbol });\n            OptimismPortal(payable(optimismPortal())).setGasPayingToken({\n                _token: _token,\n                _decimals: GAS_PAYING_TOKEN_DECIMALS,\n                _name: name,\n                _symbol: symbol\n            });\n        }\n    }\n\n    /// @notice Updates the unsafe block signer address. Can only be called by the owner.\n    /// @param _unsafeBlockSigner New unsafe block signer address.\n    function setUnsafeBlockSigner(address _unsafeBlockSigner) external onlyOwner {\n        _setUnsafeBlockSigner(_unsafeBlockSigner);\n    }\n\n    /// @notice Updates the unsafe block signer address.\n    /// @param _unsafeBlockSigner New unsafe block signer address.\n    function _setUnsafeBlockSigner(address _unsafeBlockSigner) internal {\n        Storage.setAddress(UNSAFE_BLOCK_SIGNER_SLOT, _unsafeBlockSigner);\n\n        bytes memory data = abi.encode(_unsafeBlockSigner);\n        emit ConfigUpdate(VERSION, UpdateType.UNSAFE_BLOCK_SIGNER, data);\n    }\n\n    /// @notice Updates the batcher hash. Can only be called by the owner.\n    /// @param _batcherHash New batcher hash.\n    function setBatcherHash(bytes32 _batcherHash) external onlyOwner {\n        _setBatcherHash(_batcherHash);\n    }\n\n    /// @notice Internal function for updating the batcher hash.\n    /// @param _batcherHash New batcher hash.\n    function _setBatcherHash(bytes32 _batcherHash) internal {\n        batcherHash = _batcherHash;\n\n        bytes memory data = abi.encode(_batcherHash);\n        emit ConfigUpdate(VERSION, UpdateType.BATCHER, data);\n    }\n\n    /// @notice Updates gas config. Can only be called by the owner.\n    ///         Deprecated in favor of setGasConfigEcotone since the Ecotone upgrade.\n    /// @param _overhead New overhead value.\n    /// @param _scalar   New scalar value.\n    function setGasConfig(uint256 _overhead, uint256 _scalar) external onlyOwner {\n        _setGasConfig(_overhead, _scalar);\n    }\n\n    /// @notice Internal function for updating the gas config.\n    /// @param _overhead New overhead value.\n    /// @param _scalar   New scalar value.\n    function _setGasConfig(uint256 _overhead, uint256 _scalar) internal {\n        require((uint256(0xff) << 248) & _scalar == 0, \"SystemConfig: scalar exceeds max.\");\n\n        overhead = _overhead;\n        scalar = _scalar;\n\n        bytes memory data = abi.encode(_overhead, _scalar);\n        emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data);\n    }\n\n    /// @notice Updates gas config as of the Ecotone upgrade. Can only be called by the owner.\n    /// @param _basefeeScalar     New basefeeScalar value.\n    /// @param _blobbasefeeScalar New blobbasefeeScalar value.\n    function setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) external onlyOwner {\n        _setGasConfigEcotone(_basefeeScalar, _blobbasefeeScalar);\n    }\n\n    /// @notice Internal function for updating the fee scalars as of the Ecotone upgrade.\n    /// @param _basefeeScalar     New basefeeScalar value.\n    /// @param _blobbasefeeScalar New blobbasefeeScalar value.\n    function _setGasConfigEcotone(uint32 _basefeeScalar, uint32 _blobbasefeeScalar) internal {\n        basefeeScalar = _basefeeScalar;\n        blobbasefeeScalar = _blobbasefeeScalar;\n\n        scalar = (uint256(0x01) << 248) | (uint256(_blobbasefeeScalar) << 32) | _basefeeScalar;\n\n        bytes memory data = abi.encode(overhead, scalar);\n        emit ConfigUpdate(VERSION, UpdateType.GAS_CONFIG, data);\n    }\n\n    /// @notice Updates the L2 gas limit. Can only be called by the owner.\n    /// @param _gasLimit New gas limit.\n    function setGasLimit(uint64 _gasLimit) external onlyOwner {\n        _setGasLimit(_gasLimit);\n    }\n\n    /// @notice Internal function for updating the L2 gas limit.\n    /// @param _gasLimit New gas limit.\n    function _setGasLimit(uint64 _gasLimit) internal {\n        require(_gasLimit >= minimumGasLimit(), \"SystemConfig: gas limit too low\");\n        require(_gasLimit <= maximumGasLimit(), \"SystemConfig: gas limit too high\");\n        gasLimit = _gasLimit;\n\n        bytes memory data = abi.encode(_gasLimit);\n        emit ConfigUpdate(VERSION, UpdateType.GAS_LIMIT, data);\n    }\n\n    /// @notice Sets the start block in a backwards compatible way. Proxies\n    ///         that were initialized before the startBlock existed in storage\n    ///         can have their start block set by a user provided override.\n    ///         A start block of 0 indicates that there is no override and the\n    ///         start block will be set by `block.number`.\n    /// @dev    This logic is used to patch legacy deployments with new storage values.\n    ///         Use the override if it is provided as a non zero value and the value\n    ///         has not already been set in storage. Use `block.number` if the value\n    ///         has already been set in storage\n    function _setStartBlock() internal {\n        if (Storage.getUint(START_BLOCK_SLOT) == 0) {\n            Storage.setUint(START_BLOCK_SLOT, block.number);\n        }\n    }\n\n    /// @notice A getter for the resource config.\n    ///         Ensures that the struct is returned instead of a tuple.\n    /// @return ResourceConfig\n    function resourceConfig() external view returns (ResourceMetering.ResourceConfig memory) {\n        return _resourceConfig;\n    }\n\n    /// @notice An internal setter for the resource config.\n    ///         Ensures that the config is sane before storing it by checking for invariants.\n    ///         In the future, this method may emit an event that the `op-node` picks up\n    ///         for when the resource config is changed.\n    /// @param _config The new resource config.\n    function _setResourceConfig(ResourceMetering.ResourceConfig memory _config) internal {\n        // Min base fee must be less than or equal to max base fee.\n        require(\n            _config.minimumBaseFee <= _config.maximumBaseFee, \"SystemConfig: min base fee must be less than max base\"\n        );\n        // Base fee change denominator must be greater than 1.\n        require(_config.baseFeeMaxChangeDenominator > 1, \"SystemConfig: denominator must be larger than 1\");\n        // Max resource limit plus system tx gas must be less than or equal to the L2 gas limit.\n        // The gas limit must be increased before these values can be increased.\n        require(_config.maxResourceLimit + _config.systemTxMaxGas <= gasLimit, \"SystemConfig: gas limit too low\");\n        // Elasticity multiplier must be greater than 0.\n        require(_config.elasticityMultiplier > 0, \"SystemConfig: elasticity multiplier cannot be 0\");\n        // No precision loss when computing target resource limit.\n        require(\n            ((_config.maxResourceLimit / _config.elasticityMultiplier) * _config.elasticityMultiplier)\n                == _config.maxResourceLimit,\n            \"SystemConfig: precision loss with target resource limit\"\n        );\n\n        _resourceConfig = _config;\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"
      },
      "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 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    }\n\n    /// @notice Perform a low level call with all gas without copying any returndata\n    /// @param _target   Address to call\n    /// @param _value    Amount of value to pass to the call\n    function send(address _target, uint256 _value) internal returns (bool success_) {\n        success_ = send(_target, gasleft(), _value);\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(\n        address _target,\n        uint256 _gas,\n        uint256 _value,\n        bytes memory _calldata\n    )\n        internal\n        returns (bool success_)\n    {\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    }\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/L1/L2OutputOracle.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 { Types } from \"src/libraries/Types.sol\";\nimport { Constants } from \"src/libraries/Constants.sol\";\n\n/// @custom:proxied\n/// @title L2OutputOracle\n/// @notice The L2OutputOracle contains an array of L2 state outputs, where each output is a\n///         commitment to the state of the L2 chain. Other contracts like the OptimismPortal use\n///         these outputs to verify information about the state of L2.\ncontract L2OutputOracle is Initializable, ISemver {\n    /// @notice The number of the first L2 block recorded in this contract.\n    uint256 public startingBlockNumber;\n\n    /// @notice The timestamp of the first L2 block recorded in this contract.\n    uint256 public startingTimestamp;\n\n    /// @notice An array of L2 output proposals.\n    Types.OutputProposal[] internal l2Outputs;\n\n    /// @notice The interval in L2 blocks at which checkpoints must be submitted.\n    /// @custom:network-specific\n    uint256 public submissionInterval;\n\n    /// @notice The time between L2 blocks in seconds. Once set, this value MUST NOT be modified.\n    /// @custom:network-specific\n    uint256 public l2BlockTime;\n\n    /// @notice The address of the challenger. Can be updated via upgrade.\n    /// @custom:network-specific\n    address public challenger;\n\n    /// @notice The address of the proposer. Can be updated via upgrade.\n    /// @custom:network-specific\n    address public proposer;\n\n    /// @notice The minimum time (in seconds) that must elapse before a withdrawal can be finalized.\n    /// @custom:network-specific\n    uint256 public finalizationPeriodSeconds;\n\n    /// @notice Emitted when an output is proposed.\n    /// @param outputRoot    The output root.\n    /// @param l2OutputIndex The index of the output in the l2Outputs array.\n    /// @param l2BlockNumber The L2 block number of the output root.\n    /// @param l1Timestamp   The L1 timestamp when proposed.\n    event OutputProposed(\n        bytes32 indexed outputRoot, uint256 indexed l2OutputIndex, uint256 indexed l2BlockNumber, uint256 l1Timestamp\n    );\n\n    /// @notice Emitted when outputs are deleted.\n    /// @param prevNextOutputIndex Next L2 output index before the deletion.\n    /// @param newNextOutputIndex  Next L2 output index after the deletion.\n    event OutputsDeleted(uint256 indexed prevNextOutputIndex, uint256 indexed newNextOutputIndex);\n\n    /// @notice Semantic version.\n    /// @custom:semver 1.8.0\n    string public constant version = \"1.8.0\";\n\n    /// @notice Constructs the L2OutputOracle contract. Initializes variables to the same values as\n    ///         in the getting-started config.\n    constructor() {\n        initialize({\n            _submissionInterval: 1,\n            _l2BlockTime: 1,\n            _startingBlockNumber: 0,\n            _startingTimestamp: 0,\n            _proposer: address(0),\n            _challenger: address(0),\n            _finalizationPeriodSeconds: 0\n        });\n    }\n\n    /// @notice Initializer.\n    /// @param _submissionInterval  Interval in blocks at which checkpoints must be submitted.\n    /// @param _l2BlockTime         The time per L2 block, in seconds.\n    /// @param _startingBlockNumber The number of the first L2 block.\n    /// @param _startingTimestamp   The timestamp of the first L2 block.\n    /// @param _proposer            The address of the proposer.\n    /// @param _challenger          The address of the challenger.\n    /// @param _finalizationPeriodSeconds The minimum time (in seconds) that must elapse before a withdrawal\n    ///                                   can be finalized.\n    function initialize(\n        uint256 _submissionInterval,\n        uint256 _l2BlockTime,\n        uint256 _startingBlockNumber,\n        uint256 _startingTimestamp,\n        address _proposer,\n        address _challenger,\n        uint256 _finalizationPeriodSeconds\n    )\n        public\n        initializer\n    {\n        require(_submissionInterval > 0, \"L2OutputOracle: submission interval must be greater than 0\");\n        require(_l2BlockTime > 0, \"L2OutputOracle: L2 block time must be greater than 0\");\n        require(\n            _startingTimestamp <= block.timestamp,\n            \"L2OutputOracle: starting L2 timestamp must be less than current time\"\n        );\n\n        submissionInterval = _submissionInterval;\n        l2BlockTime = _l2BlockTime;\n        startingBlockNumber = _startingBlockNumber;\n        startingTimestamp = _startingTimestamp;\n        proposer = _proposer;\n        challenger = _challenger;\n        finalizationPeriodSeconds = _finalizationPeriodSeconds;\n    }\n\n    /// @notice Getter for the submissionInterval.\n    ///         Public getter is legacy and will be removed in the future. Use `submissionInterval` instead.\n    /// @return Submission interval.\n    /// @custom:legacy\n    function SUBMISSION_INTERVAL() external view returns (uint256) {\n        return submissionInterval;\n    }\n\n    /// @notice Getter for the l2BlockTime.\n    ///         Public getter is legacy and will be removed in the future. Use `l2BlockTime` instead.\n    /// @return L2 block time.\n    /// @custom:legacy\n    function L2_BLOCK_TIME() external view returns (uint256) {\n        return l2BlockTime;\n    }\n\n    /// @notice Getter for the challenger address.\n    ///         Public getter is legacy and will be removed in the future. Use `challenger` instead.\n    /// @return Address of the challenger.\n    /// @custom:legacy\n    function CHALLENGER() external view returns (address) {\n        return challenger;\n    }\n\n    /// @notice Getter for the proposer address.\n    ///         Public getter is legacy and will be removed in the future. Use `proposer` instead.\n    /// @return Address of the proposer.\n    /// @custom:legacy\n    function PROPOSER() external view returns (address) {\n        return proposer;\n    }\n\n    /// @notice Getter for the finalizationPeriodSeconds.\n    ///         Public getter is legacy and will be removed in the future. Use `finalizationPeriodSeconds` instead.\n    /// @return Finalization period in seconds.\n    /// @custom:legacy\n    function FINALIZATION_PERIOD_SECONDS() external view returns (uint256) {\n        return finalizationPeriodSeconds;\n    }\n\n    /// @notice Deletes all output proposals after and including the proposal that corresponds to\n    ///         the given output index. Only the challenger address can delete outputs.\n    /// @param _l2OutputIndex Index of the first L2 output to be deleted.\n    ///                       All outputs after this output will also be deleted.\n    function deleteL2Outputs(uint256 _l2OutputIndex) external {\n        require(msg.sender == challenger, \"L2OutputOracle: only the challenger address can delete outputs\");\n\n        // Make sure we're not *increasing* the length of the array.\n        require(\n            _l2OutputIndex < l2Outputs.length, \"L2OutputOracle: cannot delete outputs after the latest output index\"\n        );\n\n        // Do not allow deleting any outputs that have already been finalized.\n        require(\n            block.timestamp - l2Outputs[_l2OutputIndex].timestamp < finalizationPeriodSeconds,\n            \"L2OutputOracle: cannot delete outputs that have already been finalized\"\n        );\n\n        uint256 prevNextL2OutputIndex = nextOutputIndex();\n\n        // Use assembly to delete the array elements because Solidity doesn't allow it.\n        assembly {\n            sstore(l2Outputs.slot, _l2OutputIndex)\n        }\n\n        emit OutputsDeleted(prevNextL2OutputIndex, _l2OutputIndex);\n    }\n\n    /// @notice Accepts an outputRoot and the timestamp of the corresponding L2 block.\n    ///         The timestamp must be equal to the current value returned by `nextTimestamp()` in\n    ///         order to be accepted. This function may only be called by the Proposer.\n    /// @param _outputRoot    The L2 output of the checkpoint block.\n    /// @param _l2BlockNumber The L2 block number that resulted in _outputRoot.\n    /// @param _l1BlockHash   A block hash which must be included in the current chain.\n    /// @param _l1BlockNumber The block number with the specified block hash.\n    function proposeL2Output(\n        bytes32 _outputRoot,\n        uint256 _l2BlockNumber,\n        bytes32 _l1BlockHash,\n        uint256 _l1BlockNumber\n    )\n        external\n        payable\n    {\n        require(msg.sender == proposer, \"L2OutputOracle: only the proposer address can propose new outputs\");\n\n        require(\n            _l2BlockNumber == nextBlockNumber(),\n            \"L2OutputOracle: block number must be equal to next expected block number\"\n        );\n\n        require(\n            computeL2Timestamp(_l2BlockNumber) < block.timestamp,\n            \"L2OutputOracle: cannot propose L2 output in the future\"\n        );\n\n        require(_outputRoot != bytes32(0), \"L2OutputOracle: L2 output proposal cannot be the zero hash\");\n\n        if (_l1BlockHash != bytes32(0)) {\n            // This check allows the proposer to propose an output based on a given L1 block,\n            // without fear that it will be reorged out.\n            // It will also revert if the blockheight provided is more than 256 blocks behind the\n            // chain tip (as the hash will return as zero). This does open the door to a griefing\n            // attack in which the proposer's submission is censored until the block is no longer\n            // retrievable, if the proposer is experiencing this attack it can simply leave out the\n            // blockhash value, and delay submission until it is confident that the L1 block is\n            // finalized.\n            require(\n                blockhash(_l1BlockNumber) == _l1BlockHash,\n                \"L2OutputOracle: block hash does not match the hash at the expected height\"\n            );\n        }\n\n        emit OutputProposed(_outputRoot, nextOutputIndex(), _l2BlockNumber, block.timestamp);\n\n        l2Outputs.push(\n            Types.OutputProposal({\n                outputRoot: _outputRoot,\n                timestamp: uint128(block.timestamp),\n                l2BlockNumber: uint128(_l2BlockNumber)\n            })\n        );\n    }\n\n    /// @notice Returns an output by index. Needed to return a struct instead of a tuple.\n    /// @param _l2OutputIndex Index of the output to return.\n    /// @return The output at the given index.\n    function getL2Output(uint256 _l2OutputIndex) external view returns (Types.OutputProposal memory) {\n        return l2Outputs[_l2OutputIndex];\n    }\n\n    /// @notice Returns the index of the L2 output that checkpoints a given L2 block number.\n    ///         Uses a binary search to find the first output greater than or equal to the given\n    ///         block.\n    /// @param _l2BlockNumber L2 block number to find a checkpoint for.\n    /// @return Index of the first checkpoint that commits to the given L2 block number.\n    function getL2OutputIndexAfter(uint256 _l2BlockNumber) public view returns (uint256) {\n        // Make sure an output for this block number has actually been proposed.\n        require(\n            _l2BlockNumber <= latestBlockNumber(),\n            \"L2OutputOracle: cannot get output for a block that has not been proposed\"\n        );\n\n        // Make sure there's at least one output proposed.\n        require(l2Outputs.length > 0, \"L2OutputOracle: cannot get output as no outputs have been proposed yet\");\n\n        // Find the output via binary search, guaranteed to exist.\n        uint256 lo = 0;\n        uint256 hi = l2Outputs.length;\n        while (lo < hi) {\n            uint256 mid = (lo + hi) / 2;\n            if (l2Outputs[mid].l2BlockNumber < _l2BlockNumber) {\n                lo = mid + 1;\n            } else {\n                hi = mid;\n            }\n        }\n\n        return lo;\n    }\n\n    /// @notice Returns the L2 output proposal that checkpoints a given L2 block number.\n    ///         Uses a binary search to find the first output greater than or equal to the given\n    ///         block.\n    /// @param _l2BlockNumber L2 block number to find a checkpoint for.\n    /// @return First checkpoint that commits to the given L2 block number.\n    function getL2OutputAfter(uint256 _l2BlockNumber) external view returns (Types.OutputProposal memory) {\n        return l2Outputs[getL2OutputIndexAfter(_l2BlockNumber)];\n    }\n\n    /// @notice Returns the number of outputs that have been proposed.\n    ///         Will revert if no outputs have been proposed yet.\n    /// @return The number of outputs that have been proposed.\n    function latestOutputIndex() external view returns (uint256) {\n        return l2Outputs.length - 1;\n    }\n\n    /// @notice Returns the index of the next output to be proposed.\n    /// @return The index of the next output to be proposed.\n    function nextOutputIndex() public view returns (uint256) {\n        return l2Outputs.length;\n    }\n\n    /// @notice Returns the block number of the latest submitted L2 output proposal.\n    ///         If no proposals been submitted yet then this function will return the starting\n    ///         block number.\n    /// @return Latest submitted L2 block number.\n    function latestBlockNumber() public view returns (uint256) {\n        return l2Outputs.length == 0 ? startingBlockNumber : l2Outputs[l2Outputs.length - 1].l2BlockNumber;\n    }\n\n    /// @notice Computes the block number of the next L2 block that needs to be checkpointed.\n    /// @return Next L2 block number.\n    function nextBlockNumber() public view returns (uint256) {\n        return latestBlockNumber() + submissionInterval;\n    }\n\n    /// @notice Returns the L2 timestamp corresponding to a given L2 block number.\n    /// @param _l2BlockNumber The L2 block number of the target block.\n    /// @return L2 timestamp of the given block.\n    function computeL2Timestamp(uint256 _l2BlockNumber) public view returns (uint256) {\n        return startingTimestamp + ((_l2BlockNumber - startingBlockNumber) * l2BlockTime);\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 The address that represents ether when dealing with ERC20 token addresses.\n    address internal constant ETHER = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n    /// @notice The address that represents the system caller responsible for L1 attributes\n    ///         transactions.\n    address internal constant DEPOSITOR_ACCOUNT = 0xDeaDDEaDDeAdDeAdDEAdDEaddeAddEAdDEAd0001;\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"
      },
      "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/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/trie/SecureMerkleTrie.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { MerkleTrie } from \"./MerkleTrie.sol\";\n\n/// @title SecureMerkleTrie\n/// @notice SecureMerkleTrie is a thin wrapper around the MerkleTrie library that hashes the input\n///         keys. Ethereum's state trie hashes input keys before storing them.\nlibrary SecureMerkleTrie {\n    /// @notice Verifies a proof that a given key/value pair is present in the Merkle trie.\n    /// @param _key   Key of the node to search for, as a hex string.\n    /// @param _value Value of the node to search for, as a hex string.\n    /// @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle\n    ///               trees, this proof is executed top-down and consists of a list of RLP-encoded\n    ///               nodes that make a path down to the target node.\n    /// @param _root  Known root of the Merkle trie. Used to verify that the included proof is\n    ///               correctly constructed.\n    /// @return valid_ Whether or not the proof is valid.\n    function verifyInclusionProof(\n        bytes memory _key,\n        bytes memory _value,\n        bytes[] memory _proof,\n        bytes32 _root\n    )\n        internal\n        pure\n        returns (bool valid_)\n    {\n        bytes memory key = _getSecureKey(_key);\n        valid_ = MerkleTrie.verifyInclusionProof(key, _value, _proof, _root);\n    }\n\n    /// @notice Retrieves the value associated with a given key.\n    /// @param _key   Key to search for, as hex bytes.\n    /// @param _proof Merkle trie inclusion proof for the key.\n    /// @param _root  Known root of the Merkle trie.\n    /// @return value_ Value of the key if it exists.\n    function get(bytes memory _key, bytes[] memory _proof, bytes32 _root) internal pure returns (bytes memory value_) {\n        bytes memory key = _getSecureKey(_key);\n        value_ = MerkleTrie.get(key, _proof, _root);\n    }\n\n    /// @notice Computes the hashed version of the input key.\n    /// @param _key Key to hash.\n    /// @return hash_ Hashed version of the key.\n    function _getSecureKey(bytes memory _key) private pure returns (bytes memory hash_) {\n        hash_ = abi.encodePacked(keccak256(_key));\n    }\n}\n"
      },
      "src/vendor/AddressAliasHelper.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\n\n/*\n * Copyright 2019-2021, Offchain Labs, Inc.\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *    http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n\npragma solidity ^0.8.0;\n\nlibrary AddressAliasHelper {\n    uint160 constant offset = uint160(0x1111000000000000000000000000000000001111);\n\n    /// @notice Utility function that converts the address in the L1 that submitted a tx to\n    /// the inbox to the msg.sender viewed in the L2\n    /// @param l1Address the address in the L1 that triggered the tx to L2\n    /// @return l2Address L2 address as viewed in msg.sender\n    function applyL1ToL2Alias(address l1Address) internal pure returns (address l2Address) {\n        unchecked {\n            l2Address = address(uint160(l1Address) + offset);\n        }\n    }\n\n    /// @notice Utility function that converts the msg.sender viewed in the L2 to the\n    /// address in the L1 that submitted a tx to the inbox\n    /// @param l2Address L2 address as viewed in msg.sender\n    /// @return l1Address the address in the L1 that triggered the tx to L2\n    function undoL1ToL2Alias(address l2Address) internal pure returns (address l1Address) {\n        unchecked {\n            l1Address = address(uint160(l2Address) - offset);\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 Error returned when too much gas resource is consumed.\n    error OutOfGas();\n\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        if (int256(uint256(params.prevBoughtGas)) > int256(uint256(config.maxResourceLimit))) {\n            revert OutOfGas();\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 Adds an amount of L2 gas consumed to the prev bought gas params. This is meant to be used\n    ///         when L2 system transactions are generated from L1.\n    /// @param _amount Amount of the L2 gas resource requested.\n    function useGas(uint32 _amount) internal {\n        params.prevBoughtGas += uint64(_amount);\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    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/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"
      },
      "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"
      },
      "src/L2/L1Block.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\nimport { ISemver } from \"src/universal/ISemver.sol\";\nimport { Constants } from \"src/libraries/Constants.sol\";\nimport { GasPayingToken, IGasToken } from \"src/libraries/GasPayingToken.sol\";\nimport \"src/libraries/L1BlockErrors.sol\";\n\n/// @custom:proxied\n/// @custom:predeploy 0x4200000000000000000000000000000000000015\n/// @title L1Block\n/// @notice The L1Block predeploy gives users access to information about the last known L1 block.\n///         Values within this contract are updated once per epoch (every L1 block) and can only be\n///         set by the \"depositor\" account, a special system address. Depositor account transactions\n///         are created by the protocol whenever we move to a new epoch.\ncontract L1Block is ISemver, IGasToken {\n    /// @notice Event emitted when the gas paying token is set.\n    event GasPayingTokenSet(address indexed token, uint8 indexed decimals, bytes32 name, bytes32 symbol);\n\n    /// @notice Address of the special depositor account.\n    function DEPOSITOR_ACCOUNT() public pure returns (address addr_) {\n        addr_ = Constants.DEPOSITOR_ACCOUNT;\n    }\n\n    /// @notice The latest L1 block number known by the L2 system.\n    uint64 public number;\n\n    /// @notice The latest L1 timestamp known by the L2 system.\n    uint64 public timestamp;\n\n    /// @notice The latest L1 base fee.\n    uint256 public basefee;\n\n    /// @notice The latest L1 blockhash.\n    bytes32 public hash;\n\n    /// @notice The number of L2 blocks in the same epoch.\n    uint64 public sequenceNumber;\n\n    /// @notice The scalar value applied to the L1 blob base fee portion of the blob-capable L1 cost func.\n    uint32 public blobBaseFeeScalar;\n\n    /// @notice The scalar value applied to the L1 base fee portion of the blob-capable L1 cost func.\n    uint32 public baseFeeScalar;\n\n    /// @notice The versioned hash to authenticate the batcher by.\n    bytes32 public batcherHash;\n\n    /// @notice The overhead value applied to the L1 portion of the transaction fee.\n    /// @custom:legacy\n    uint256 public l1FeeOverhead;\n\n    /// @notice The scalar value applied to the L1 portion of the transaction fee.\n    /// @custom:legacy\n    uint256 public l1FeeScalar;\n\n    /// @notice The latest L1 blob base fee.\n    uint256 public blobBaseFee;\n\n    /// @custom:semver 1.4.1-beta.1\n    function version() public pure virtual returns (string memory) {\n        return \"1.4.1-beta.1\";\n    }\n\n    /// @notice Returns the gas paying token, its decimals, name and symbol.\n    ///         If nothing is set in state, then it means ether is used.\n    function gasPayingToken() public view returns (address addr_, uint8 decimals_) {\n        (addr_, decimals_) = GasPayingToken.getToken();\n    }\n\n    /// @notice Returns the gas paying token name.\n    ///         If nothing is set in state, then it means ether is used.\n    function gasPayingTokenName() public view returns (string memory name_) {\n        name_ = GasPayingToken.getName();\n    }\n\n    /// @notice Returns the gas paying token symbol.\n    ///         If nothing is set in state, then it means ether is used.\n    function gasPayingTokenSymbol() public view returns (string memory symbol_) {\n        symbol_ = GasPayingToken.getSymbol();\n    }\n\n    /// @notice Getter for custom gas token paying networks. Returns true if the\n    ///         network uses a custom gas token.\n    function isCustomGasToken() public view returns (bool) {\n        (address token,) = gasPayingToken();\n        return token != Constants.ETHER;\n    }\n\n    /// @custom:legacy\n    /// @notice Updates the L1 block values.\n    /// @param _number         L1 blocknumber.\n    /// @param _timestamp      L1 timestamp.\n    /// @param _basefee        L1 basefee.\n    /// @param _hash           L1 blockhash.\n    /// @param _sequenceNumber Number of L2 blocks since epoch start.\n    /// @param _batcherHash    Versioned hash to authenticate batcher by.\n    /// @param _l1FeeOverhead  L1 fee overhead.\n    /// @param _l1FeeScalar    L1 fee scalar.\n    function setL1BlockValues(\n        uint64 _number,\n        uint64 _timestamp,\n        uint256 _basefee,\n        bytes32 _hash,\n        uint64 _sequenceNumber,\n        bytes32 _batcherHash,\n        uint256 _l1FeeOverhead,\n        uint256 _l1FeeScalar\n    )\n        external\n    {\n        require(msg.sender == DEPOSITOR_ACCOUNT(), \"L1Block: only the depositor account can set L1 block values\");\n\n        number = _number;\n        timestamp = _timestamp;\n        basefee = _basefee;\n        hash = _hash;\n        sequenceNumber = _sequenceNumber;\n        batcherHash = _batcherHash;\n        l1FeeOverhead = _l1FeeOverhead;\n        l1FeeScalar = _l1FeeScalar;\n    }\n\n    /// @notice Updates the L1 block values for an Ecotone upgraded chain.\n    /// Params are packed and passed in as raw msg.data instead of ABI to reduce calldata size.\n    /// Params are expected to be in the following order:\n    ///   1. _baseFeeScalar      L1 base fee scalar\n    ///   2. _blobBaseFeeScalar  L1 blob base fee scalar\n    ///   3. _sequenceNumber     Number of L2 blocks since epoch start.\n    ///   4. _timestamp          L1 timestamp.\n    ///   5. _number             L1 blocknumber.\n    ///   6. _basefee            L1 base fee.\n    ///   7. _blobBaseFee        L1 blob base fee.\n    ///   8. _hash               L1 blockhash.\n    ///   9. _batcherHash        Versioned hash to authenticate batcher by.\n    function setL1BlockValuesEcotone() external {\n        address depositor = DEPOSITOR_ACCOUNT();\n        assembly {\n            // Revert if the caller is not the depositor account.\n            if xor(caller(), depositor) {\n                mstore(0x00, 0x3cc50b45) // 0x3cc50b45 is the 4-byte selector of \"NotDepositor()\"\n                revert(0x1C, 0x04) // returns the stored 4-byte selector from above\n            }\n            // sequencenum (uint64), blobBaseFeeScalar (uint32), baseFeeScalar (uint32)\n            sstore(sequenceNumber.slot, shr(128, calldataload(4)))\n            // number (uint64) and timestamp (uint64)\n            sstore(number.slot, shr(128, calldataload(20)))\n            sstore(basefee.slot, calldataload(36)) // uint256\n            sstore(blobBaseFee.slot, calldataload(68)) // uint256\n            sstore(hash.slot, calldataload(100)) // bytes32\n            sstore(batcherHash.slot, calldataload(132)) // bytes32\n        }\n    }\n\n    /// @notice Sets the gas paying token for the L2 system. Can only be called by the special\n    ///         depositor account. This function is not called on every L2 block but instead\n    ///         only called by specially crafted L1 deposit transactions.\n    function setGasPayingToken(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) external {\n        if (msg.sender != DEPOSITOR_ACCOUNT()) revert NotDepositor();\n\n        GasPayingToken.set({ _token: _token, _decimals: _decimals, _name: _name, _symbol: _symbol });\n\n        emit GasPayingTokenSet({ token: _token, decimals: _decimals, name: _name, symbol: _symbol });\n    }\n}\n"
      },
      "src/libraries/PortalErrors.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @notice Error for when a deposit or withdrawal is to a bad target.\nerror BadTarget();\n/// @notice Error for when a deposit has too much calldata.\nerror LargeCalldata();\n/// @notice Error for when a deposit has too small of a gas limit.\nerror SmallGasLimit();\n/// @notice Error for when a withdrawal transfer fails.\nerror TransferFailed();\n/// @notice Error for when a method is called that only works when using a custom gas token.\nerror OnlyCustomGasToken();\n/// @notice Error for when a method cannot be called with non zero CALLVALUE.\nerror NoValue();\n/// @notice Error for an unauthorized CALLER.\nerror Unauthorized();\n/// @notice Error for when a method cannot be called when paused. This could be renamed\n///         to `Paused` in the future, but it collides with the `Paused` event.\nerror CallPaused();\n/// @notice Error for special gas estimation.\nerror GasEstimation();\n/// @notice Error for when a method is being reentered.\nerror NonReentrant();\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/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    /// @notice Returns an appropriately encoded call to L1Block.setL1BlockValuesInterop\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    /// @param _dependencySet       Array of the chain IDs in the interop dependency set.\n    function encodeSetL1BlockValuesInterop(\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        uint256[] memory _dependencySet\n    )\n        internal\n        pure\n        returns (bytes memory)\n    {\n        require(_dependencySet.length <= type(uint8).max, \"Encoding: dependency set length is too large\");\n        // Check that the batcher hash is just the address with 0 padding to the left for version 0.\n        require(uint160(uint256(_batcherHash)) == uint256(_batcherHash), \"Encoding: invalid batcher hash\");\n\n        bytes4 functionSignature = bytes4(keccak256(\"setL1BlockValuesInterop()\"));\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            uint8(_dependencySet.length),\n            _dependencySet\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"
      },
      "lib/openzeppelin-contracts-upgradeable/contracts/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    function __Ownable_init() internal onlyInitializing {\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal onlyInitializing {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "src/libraries/GasPayingToken.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Storage } from \"src/libraries/Storage.sol\";\nimport { Constants } from \"src/libraries/Constants.sol\";\nimport { LibString } from \"@solady/utils/LibString.sol\";\n\n/// @title IGasToken\n/// @notice Implemented by contracts that are aware of the custom gas token used\n///         by the L2 network.\ninterface IGasToken {\n    /// @notice Getter for the ERC20 token address that is used to pay for gas and its decimals.\n    function gasPayingToken() external view returns (address, uint8);\n    /// @notice Returns the gas token name.\n    function gasPayingTokenName() external view returns (string memory);\n    /// @notice Returns the gas token symbol.\n    function gasPayingTokenSymbol() external view returns (string memory);\n    /// @notice Returns true if the network uses a custom gas token.\n    function isCustomGasToken() external view returns (bool);\n}\n\n/// @title GasPayingToken\n/// @notice Handles reading and writing the custom gas token to storage.\n///         To be used in any place where gas token information is read or\n///         written to state. If multiple contracts use this library, the\n///         values in storage should be kept in sync between them.\nlibrary GasPayingToken {\n    /// @notice The storage slot that contains the address and decimals of the gas paying token\n    bytes32 internal constant GAS_PAYING_TOKEN_SLOT = bytes32(uint256(keccak256(\"opstack.gaspayingtoken\")) - 1);\n\n    /// @notice The storage slot that contains the ERC20 `name()` of the gas paying token\n    bytes32 internal constant GAS_PAYING_TOKEN_NAME_SLOT = bytes32(uint256(keccak256(\"opstack.gaspayingtokenname\")) - 1);\n\n    /// @notice the storage slot that contains the ERC20 `symbol()` of the gas paying token\n    bytes32 internal constant GAS_PAYING_TOKEN_SYMBOL_SLOT =\n        bytes32(uint256(keccak256(\"opstack.gaspayingtokensymbol\")) - 1);\n\n    /// @notice Reads the gas paying token and its decimals from the magic\n    ///         storage slot. If nothing is set in storage, then the ether\n    ///         address is returned instead.\n    function getToken() internal view returns (address addr_, uint8 decimals_) {\n        bytes32 slot = Storage.getBytes32(GAS_PAYING_TOKEN_SLOT);\n        addr_ = address(uint160(uint256(slot) & uint256(type(uint160).max)));\n        if (addr_ == address(0)) {\n            addr_ = Constants.ETHER;\n            decimals_ = 18;\n        } else {\n            decimals_ = uint8(uint256(slot) >> 160);\n        }\n    }\n\n    /// @notice Reads the gas paying token's name from the magic storage slot.\n    ///         If nothing is set in storage, then the ether name, 'Ether', is returned instead.\n    function getName() internal view returns (string memory name_) {\n        (address addr,) = getToken();\n        if (addr == Constants.ETHER) {\n            name_ = \"Ether\";\n        } else {\n            name_ = LibString.fromSmallString(Storage.getBytes32(GAS_PAYING_TOKEN_NAME_SLOT));\n        }\n    }\n\n    /// @notice Reads the gas paying token's symbol from the magic storage slot.\n    ///         If nothing is set in storage, then the ether symbol, 'ETH', is returned instead.\n    function getSymbol() internal view returns (string memory symbol_) {\n        (address addr,) = getToken();\n        if (addr == Constants.ETHER) {\n            symbol_ = \"ETH\";\n        } else {\n            symbol_ = LibString.fromSmallString(Storage.getBytes32(GAS_PAYING_TOKEN_SYMBOL_SLOT));\n        }\n    }\n\n    /// @notice Writes the gas paying token, its decimals, name and symbol to the magic storage slot.\n    function set(address _token, uint8 _decimals, bytes32 _name, bytes32 _symbol) internal {\n        Storage.setBytes32(GAS_PAYING_TOKEN_SLOT, bytes32(uint256(_decimals) << 160 | uint256(uint160(_token))));\n        Storage.setBytes32(GAS_PAYING_TOKEN_NAME_SLOT, _name);\n        Storage.setBytes32(GAS_PAYING_TOKEN_SYMBOL_SLOT, _symbol);\n    }\n\n    /// @notice Maps a string to a normalized null-terminated small string.\n    function sanitize(string memory _str) internal pure returns (bytes32) {\n        require(bytes(_str).length <= 32, \"GasPayingToken: string cannot be greater than 32 bytes\");\n\n        return LibString.toSmallString(_str);\n    }\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/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"
      },
      "src/libraries/trie/MerkleTrie.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport { Bytes } from \"../Bytes.sol\";\nimport { RLPReader } from \"../rlp/RLPReader.sol\";\n\n/// @title MerkleTrie\n/// @notice MerkleTrie is a small library for verifying standard Ethereum Merkle-Patricia trie\n///         inclusion proofs. By default, this library assumes a hexary trie. One can change the\n///         trie radix constant to support other trie radixes.\nlibrary MerkleTrie {\n    /// @notice Struct representing a node in the trie.\n    /// @custom:field encoded The RLP-encoded node.\n    /// @custom:field decoded The RLP-decoded node.\n    struct TrieNode {\n        bytes encoded;\n        RLPReader.RLPItem[] decoded;\n    }\n\n    /// @notice Determines the number of elements per branch node.\n    uint256 internal constant TREE_RADIX = 16;\n\n    /// @notice Branch nodes have TREE_RADIX elements and one value element.\n    uint256 internal constant BRANCH_NODE_LENGTH = TREE_RADIX + 1;\n\n    /// @notice Leaf nodes and extension nodes have two elements, a `path` and a `value`.\n    uint256 internal constant LEAF_OR_EXTENSION_NODE_LENGTH = 2;\n\n    /// @notice Prefix for even-nibbled extension node paths.\n    uint8 internal constant PREFIX_EXTENSION_EVEN = 0;\n\n    /// @notice Prefix for odd-nibbled extension node paths.\n    uint8 internal constant PREFIX_EXTENSION_ODD = 1;\n\n    /// @notice Prefix for even-nibbled leaf node paths.\n    uint8 internal constant PREFIX_LEAF_EVEN = 2;\n\n    /// @notice Prefix for odd-nibbled leaf node paths.\n    uint8 internal constant PREFIX_LEAF_ODD = 3;\n\n    /// @notice Verifies a proof that a given key/value pair is present in the trie.\n    /// @param _key   Key of the node to search for, as a hex string.\n    /// @param _value Value of the node to search for, as a hex string.\n    /// @param _proof Merkle trie inclusion proof for the desired node. Unlike traditional Merkle\n    ///               trees, this proof is executed top-down and consists of a list of RLP-encoded\n    ///               nodes that make a path down to the target node.\n    /// @param _root  Known root of the Merkle trie. Used to verify that the included proof is\n    ///               correctly constructed.\n    /// @return valid_ Whether or not the proof is valid.\n    function verifyInclusionProof(\n        bytes memory _key,\n        bytes memory _value,\n        bytes[] memory _proof,\n        bytes32 _root\n    )\n        internal\n        pure\n        returns (bool valid_)\n    {\n        valid_ = Bytes.equal(_value, get(_key, _proof, _root));\n    }\n\n    /// @notice Retrieves the value associated with a given key.\n    /// @param _key   Key to search for, as hex bytes.\n    /// @param _proof Merkle trie inclusion proof for the key.\n    /// @param _root  Known root of the Merkle trie.\n    /// @return value_ Value of the key if it exists.\n    function get(bytes memory _key, bytes[] memory _proof, bytes32 _root) internal pure returns (bytes memory value_) {\n        require(_key.length > 0, \"MerkleTrie: empty key\");\n\n        TrieNode[] memory proof = _parseProof(_proof);\n        bytes memory key = Bytes.toNibbles(_key);\n        bytes memory currentNodeID = abi.encodePacked(_root);\n        uint256 currentKeyIndex = 0;\n\n        // Proof is top-down, so we start at the first element (root).\n        for (uint256 i = 0; i < proof.length; i++) {\n            TrieNode memory currentNode = proof[i];\n\n            // Key index should never exceed total key length or we'll be out of bounds.\n            require(currentKeyIndex <= key.length, \"MerkleTrie: key index exceeds total key length\");\n\n            if (currentKeyIndex == 0) {\n                // First proof element is always the root node.\n                require(\n                    Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID),\n                    \"MerkleTrie: invalid root hash\"\n                );\n            } else if (currentNode.encoded.length >= 32) {\n                // Nodes 32 bytes or larger are hashed inside branch nodes.\n                require(\n                    Bytes.equal(abi.encodePacked(keccak256(currentNode.encoded)), currentNodeID),\n                    \"MerkleTrie: invalid large internal hash\"\n                );\n            } else {\n                // Nodes smaller than 32 bytes aren't hashed.\n                require(Bytes.equal(currentNode.encoded, currentNodeID), \"MerkleTrie: invalid internal node hash\");\n            }\n\n            if (currentNode.decoded.length == BRANCH_NODE_LENGTH) {\n                if (currentKeyIndex == key.length) {\n                    // Value is the last element of the decoded list (for branch nodes). There's\n                    // some ambiguity in the Merkle trie specification because bytes(0) is a\n                    // valid value to place into the trie, but for branch nodes bytes(0) can exist\n                    // even when the value wasn't explicitly placed there. Geth treats a value of\n                    // bytes(0) as \"key does not exist\" and so we do the same.\n                    value_ = RLPReader.readBytes(currentNode.decoded[TREE_RADIX]);\n                    require(value_.length > 0, \"MerkleTrie: value length must be greater than zero (branch)\");\n\n                    // Extra proof elements are not allowed.\n                    require(i == proof.length - 1, \"MerkleTrie: value node must be last node in proof (branch)\");\n\n                    return value_;\n                } else {\n                    // We're not at the end of the key yet.\n                    // Figure out what the next node ID should be and continue.\n                    uint8 branchKey = uint8(key[currentKeyIndex]);\n                    RLPReader.RLPItem memory nextNode = currentNode.decoded[branchKey];\n                    currentNodeID = _getNodeID(nextNode);\n                    currentKeyIndex += 1;\n                }\n            } else if (currentNode.decoded.length == LEAF_OR_EXTENSION_NODE_LENGTH) {\n                bytes memory path = _getNodePath(currentNode);\n                uint8 prefix = uint8(path[0]);\n                uint8 offset = 2 - (prefix % 2);\n                bytes memory pathRemainder = Bytes.slice(path, offset);\n                bytes memory keyRemainder = Bytes.slice(key, currentKeyIndex);\n                uint256 sharedNibbleLength = _getSharedNibbleLength(pathRemainder, keyRemainder);\n\n                // Whether this is a leaf node or an extension node, the path remainder MUST be a\n                // prefix of the key remainder (or be equal to the key remainder) or the proof is\n                // considered invalid.\n                require(\n                    pathRemainder.length == sharedNibbleLength,\n                    \"MerkleTrie: path remainder must share all nibbles with key\"\n                );\n\n                if (prefix == PREFIX_LEAF_EVEN || prefix == PREFIX_LEAF_ODD) {\n                    // Prefix of 2 or 3 means this is a leaf node. For the leaf node to be valid,\n                    // the key remainder must be exactly equal to the path remainder. We already\n                    // did the necessary byte comparison, so it's more efficient here to check that\n                    // the key remainder length equals the shared nibble length, which implies\n                    // equality with the path remainder (since we already did the same check with\n                    // the path remainder and the shared nibble length).\n                    require(\n                        keyRemainder.length == sharedNibbleLength,\n                        \"MerkleTrie: key remainder must be identical to path remainder\"\n                    );\n\n                    // Our Merkle Trie is designed specifically for the purposes of the Ethereum\n                    // state trie. Empty values are not allowed in the state trie, so we can safely\n                    // say that if the value is empty, the key should not exist and the proof is\n                    // invalid.\n                    value_ = RLPReader.readBytes(currentNode.decoded[1]);\n                    require(value_.length > 0, \"MerkleTrie: value length must be greater than zero (leaf)\");\n\n                    // Extra proof elements are not allowed.\n                    require(i == proof.length - 1, \"MerkleTrie: value node must be last node in proof (leaf)\");\n\n                    return value_;\n                } else if (prefix == PREFIX_EXTENSION_EVEN || prefix == PREFIX_EXTENSION_ODD) {\n                    // Prefix of 0 or 1 means this is an extension node. We move onto the next node\n                    // in the proof and increment the key index by the length of the path remainder\n                    // which is equal to the shared nibble length.\n                    currentNodeID = _getNodeID(currentNode.decoded[1]);\n                    currentKeyIndex += sharedNibbleLength;\n                } else {\n                    revert(\"MerkleTrie: received a node with an unknown prefix\");\n                }\n            } else {\n                revert(\"MerkleTrie: received an unparseable node\");\n            }\n        }\n\n        revert(\"MerkleTrie: ran out of proof elements\");\n    }\n\n    /// @notice Parses an array of proof elements into a new array that contains both the original\n    ///         encoded element and the RLP-decoded element.\n    /// @param _proof Array of proof elements to parse.\n    /// @return proof_ Proof parsed into easily accessible structs.\n    function _parseProof(bytes[] memory _proof) private pure returns (TrieNode[] memory proof_) {\n        uint256 length = _proof.length;\n        proof_ = new TrieNode[](length);\n        for (uint256 i = 0; i < length;) {\n            proof_[i] = TrieNode({ encoded: _proof[i], decoded: RLPReader.readList(_proof[i]) });\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    /// @notice Picks out the ID for a node. Node ID is referred to as the \"hash\" within the\n    ///         specification, but nodes < 32 bytes are not actually hashed.\n    /// @param _node Node to pull an ID for.\n    /// @return id_ ID for the node, depending on the size of its contents.\n    function _getNodeID(RLPReader.RLPItem memory _node) private pure returns (bytes memory id_) {\n        id_ = _node.length < 32 ? RLPReader.readRawBytes(_node) : RLPReader.readBytes(_node);\n    }\n\n    /// @notice Gets the path for a leaf or extension node.\n    /// @param _node Node to get a path for.\n    /// @return nibbles_ Node path, converted to an array of nibbles.\n    function _getNodePath(TrieNode memory _node) private pure returns (bytes memory nibbles_) {\n        nibbles_ = Bytes.toNibbles(RLPReader.readBytes(_node.decoded[0]));\n    }\n\n    /// @notice Utility; determines the number of nibbles shared between two nibble arrays.\n    /// @param _a First nibble array.\n    /// @param _b Second nibble array.\n    /// @return shared_ Number of shared nibbles.\n    function _getSharedNibbleLength(bytes memory _a, bytes memory _b) private pure returns (uint256 shared_) {\n        uint256 max = (_a.length < _b.length) ? _a.length : _b.length;\n        for (; shared_ < max && _a[shared_] == _b[shared_];) {\n            unchecked {\n                ++shared_;\n            }\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/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"
      },
      "src/libraries/L1BlockErrors.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @notice Error returns when a non-depositor account tries to set L1 block values.\nerror NotDepositor();\n\n/// @notice Error when a chain ID is not in the interop dependency set.\nerror NotDependency();\n\n/// @notice Error when the interop dependency set size is too large.\nerror DependencySetSizeTooLarge();\n\n/// @notice Error when a chain ID already in the interop dependency set is attempted to be added.\nerror AlreadyDependency();\n\n/// @notice Error when the chain's chain ID is attempted to be removed from the interop dependency set.\nerror CantRemovedDependency();\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/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-upgradeable/contracts/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract ContextUpgradeable is Initializable {\n    function __Context_init() internal onlyInitializing {\n    }\n\n    function __Context_init_unchained() internal onlyInitializing {\n    }\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[50] private __gap;\n}\n"
      },
      "lib/solady/src/utils/LibString.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.4;\n\n/// @notice Library for converting numbers into strings and other string operations.\n/// @author Solady (https://github.com/vectorized/solady/blob/main/src/utils/LibString.sol)\n/// @author Modified from Solmate (https://github.com/transmissions11/solmate/blob/main/src/utils/LibString.sol)\n///\n/// Note:\n/// For performance and bytecode compactness, most of the string operations are restricted to\n/// byte strings (7-bit ASCII), except where otherwise specified.\n/// Usage of byte string operations on charsets with runes spanning two or more bytes\n/// can lead to undefined behavior.\nlibrary LibString {\n    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n    /*                        CUSTOM ERRORS                       */\n    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n    /// @dev The length of the output is too small to contain all the hex digits.\n    error HexLengthInsufficient();\n\n    /// @dev The length of the string is more than 32 bytes.\n    error TooBigForSmallString();\n\n    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n    /*                         CONSTANTS                          */\n    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n    /// @dev The constant returned when the `search` is not found in the string.\n    uint256 internal constant NOT_FOUND = type(uint256).max;\n\n    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n    /*                     DECIMAL OPERATIONS                     */\n    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n    /// @dev Returns the base 10 decimal representation of `value`.\n    function toString(uint256 value) internal pure returns (string memory str) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but\n            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.\n            // We will need 1 word for the trailing zeros padding, 1 word for the length,\n            // and 3 words for a maximum of 78 digits.\n            str := add(mload(0x40), 0x80)\n            // Update the free memory pointer to allocate.\n            mstore(0x40, add(str, 0x20))\n            // Zeroize the slot after the string.\n            mstore(str, 0)\n\n            // Cache the end of the memory to calculate the length later.\n            let end := str\n\n            let w := not(0) // Tsk.\n            // We write the string from rightmost digit to leftmost digit.\n            // The following is essentially a do-while loop that also handles the zero case.\n            for { let temp := value } 1 {} {\n                str := add(str, w) // `sub(str, 1)`.\n                // Write the character to the pointer.\n                // The ASCII index of the '0' character is 48.\n                mstore8(str, add(48, mod(temp, 10)))\n                // Keep dividing `temp` until zero.\n                temp := div(temp, 10)\n                if iszero(temp) { break }\n            }\n\n            let length := sub(end, str)\n            // Move the pointer 32 bytes leftwards to make room for the length.\n            str := sub(str, 0x20)\n            // Store the length.\n            mstore(str, length)\n        }\n    }\n\n    /// @dev Returns the base 10 decimal representation of `value`.\n    function toString(int256 value) internal pure returns (string memory str) {\n        if (value >= 0) {\n            return toString(uint256(value));\n        }\n        unchecked {\n            str = toString(uint256(-value));\n        }\n        /// @solidity memory-safe-assembly\n        assembly {\n            // We still have some spare memory space on the left,\n            // as we have allocated 3 words (96 bytes) for up to 78 digits.\n            let length := mload(str) // Load the string length.\n            mstore(str, 0x2d) // Store the '-' character.\n            str := sub(str, 1) // Move back the string pointer by a byte.\n            mstore(str, add(length, 1)) // Update the string length.\n        }\n    }\n\n    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n    /*                   HEXADECIMAL OPERATIONS                   */\n    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n    /// @dev Returns the hexadecimal representation of `value`,\n    /// left-padded to an input length of `length` bytes.\n    /// The output is prefixed with \"0x\" encoded using 2 hexadecimal digits per byte,\n    /// giving a total length of `length * 2 + 2` bytes.\n    /// Reverts if `length` is too small for the output to contain all the digits.\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory str) {\n        str = toHexStringNoPrefix(value, length);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let strLength := add(mload(str), 2) // Compute the length.\n            mstore(str, 0x3078) // Write the \"0x\" prefix.\n            str := sub(str, 2) // Move the pointer.\n            mstore(str, strLength) // Write the length.\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`,\n    /// left-padded to an input length of `length` bytes.\n    /// The output is prefixed with \"0x\" encoded using 2 hexadecimal digits per byte,\n    /// giving a total length of `length * 2` bytes.\n    /// Reverts if `length` is too small for the output to contain all the digits.\n    function toHexStringNoPrefix(uint256 value, uint256 length)\n        internal\n        pure\n        returns (string memory str)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // We need 0x20 bytes for the trailing zeros padding, `length * 2` bytes\n            // for the digits, 0x02 bytes for the prefix, and 0x20 bytes for the length.\n            // We add 0x20 to the total and round down to a multiple of 0x20.\n            // (0x20 + 0x20 + 0x02 + 0x20) = 0x62.\n            str := add(mload(0x40), and(add(shl(1, length), 0x42), not(0x1f)))\n            // Allocate the memory.\n            mstore(0x40, add(str, 0x20))\n            // Zeroize the slot after the string.\n            mstore(str, 0)\n\n            // Cache the end to calculate the length later.\n            let end := str\n            // Store \"0123456789abcdef\" in scratch space.\n            mstore(0x0f, 0x30313233343536373839616263646566)\n\n            let start := sub(str, add(length, length))\n            let w := not(1) // Tsk.\n            let temp := value\n            // We write the string from rightmost digit to leftmost digit.\n            // The following is essentially a do-while loop that also handles the zero case.\n            for {} 1 {} {\n                str := add(str, w) // `sub(str, 2)`.\n                mstore8(add(str, 1), mload(and(temp, 15)))\n                mstore8(str, mload(and(shr(4, temp), 15)))\n                temp := shr(8, temp)\n                if iszero(xor(str, start)) { break }\n            }\n\n            if temp {\n                mstore(0x00, 0x2194895a) // `HexLengthInsufficient()`.\n                revert(0x1c, 0x04)\n            }\n\n            // Compute the string's length.\n            let strLength := sub(end, str)\n            // Move the pointer and write the length.\n            str := sub(str, 0x20)\n            mstore(str, strLength)\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`.\n    /// The output is prefixed with \"0x\" and encoded using 2 hexadecimal digits per byte.\n    /// As address are 20 bytes long, the output will left-padded to have\n    /// a length of `20 * 2 + 2` bytes.\n    function toHexString(uint256 value) internal pure returns (string memory str) {\n        str = toHexStringNoPrefix(value);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let strLength := add(mload(str), 2) // Compute the length.\n            mstore(str, 0x3078) // Write the \"0x\" prefix.\n            str := sub(str, 2) // Move the pointer.\n            mstore(str, strLength) // Write the length.\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`.\n    /// The output is prefixed with \"0x\".\n    /// The output excludes leading \"0\" from the `toHexString` output.\n    /// `0x00: \"0x0\", 0x01: \"0x1\", 0x12: \"0x12\", 0x123: \"0x123\"`.\n    function toMinimalHexString(uint256 value) internal pure returns (string memory str) {\n        str = toHexStringNoPrefix(value);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\n            let strLength := add(mload(str), 2) // Compute the length.\n            mstore(add(str, o), 0x3078) // Write the \"0x\" prefix, accounting for leading zero.\n            str := sub(add(str, o), 2) // Move the pointer, accounting for leading zero.\n            mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`.\n    /// The output excludes leading \"0\" from the `toHexStringNoPrefix` output.\n    /// `0x00: \"0\", 0x01: \"1\", 0x12: \"12\", 0x123: \"123\"`.\n    function toMinimalHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\n        str = toHexStringNoPrefix(value);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let o := eq(byte(0, mload(add(str, 0x20))), 0x30) // Whether leading zero is present.\n            let strLength := mload(str) // Get the length.\n            str := add(str, o) // Move the pointer, accounting for leading zero.\n            mstore(str, sub(strLength, o)) // Write the length, accounting for leading zero.\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`.\n    /// The output is encoded using 2 hexadecimal digits per byte.\n    /// As address are 20 bytes long, the output will left-padded to have\n    /// a length of `20 * 2` bytes.\n    function toHexStringNoPrefix(uint256 value) internal pure returns (string memory str) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\n            // 0x02 bytes for the prefix, and 0x40 bytes for the digits.\n            // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x40) is 0xa0.\n            str := add(mload(0x40), 0x80)\n            // Allocate the memory.\n            mstore(0x40, add(str, 0x20))\n            // Zeroize the slot after the string.\n            mstore(str, 0)\n\n            // Cache the end to calculate the length later.\n            let end := str\n            // Store \"0123456789abcdef\" in scratch space.\n            mstore(0x0f, 0x30313233343536373839616263646566)\n\n            let w := not(1) // Tsk.\n            // We write the string from rightmost digit to leftmost digit.\n            // The following is essentially a do-while loop that also handles the zero case.\n            for { let temp := value } 1 {} {\n                str := add(str, w) // `sub(str, 2)`.\n                mstore8(add(str, 1), mload(and(temp, 15)))\n                mstore8(str, mload(and(shr(4, temp), 15)))\n                temp := shr(8, temp)\n                if iszero(temp) { break }\n            }\n\n            // Compute the string's length.\n            let strLength := sub(end, str)\n            // Move the pointer and write the length.\n            str := sub(str, 0x20)\n            mstore(str, strLength)\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`.\n    /// The output is prefixed with \"0x\", encoded using 2 hexadecimal digits per byte,\n    /// and the alphabets are capitalized conditionally according to\n    /// https://eips.ethereum.org/EIPS/eip-55\n    function toHexStringChecksummed(address value) internal pure returns (string memory str) {\n        str = toHexString(value);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let mask := shl(6, div(not(0), 255)) // `0b010000000100000000 ...`\n            let o := add(str, 0x22)\n            let hashed := and(keccak256(o, 40), mul(34, mask)) // `0b10001000 ... `\n            let t := shl(240, 136) // `0b10001000 << 240`\n            for { let i := 0 } 1 {} {\n                mstore(add(i, i), mul(t, byte(i, hashed)))\n                i := add(i, 1)\n                if eq(i, 20) { break }\n            }\n            mstore(o, xor(mload(o), shr(1, and(mload(0x00), and(mload(o), mask)))))\n            o := add(o, 0x20)\n            mstore(o, xor(mload(o), shr(1, and(mload(0x20), and(mload(o), mask)))))\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`.\n    /// The output is prefixed with \"0x\" and encoded using 2 hexadecimal digits per byte.\n    function toHexString(address value) internal pure returns (string memory str) {\n        str = toHexStringNoPrefix(value);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let strLength := add(mload(str), 2) // Compute the length.\n            mstore(str, 0x3078) // Write the \"0x\" prefix.\n            str := sub(str, 2) // Move the pointer.\n            mstore(str, strLength) // Write the length.\n        }\n    }\n\n    /// @dev Returns the hexadecimal representation of `value`.\n    /// The output is encoded using 2 hexadecimal digits per byte.\n    function toHexStringNoPrefix(address value) internal pure returns (string memory str) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            str := mload(0x40)\n\n            // Allocate the memory.\n            // We need 0x20 bytes for the trailing zeros padding, 0x20 bytes for the length,\n            // 0x02 bytes for the prefix, and 0x28 bytes for the digits.\n            // The next multiple of 0x20 above (0x20 + 0x20 + 0x02 + 0x28) is 0x80.\n            mstore(0x40, add(str, 0x80))\n\n            // Store \"0123456789abcdef\" in scratch space.\n            mstore(0x0f, 0x30313233343536373839616263646566)\n\n            str := add(str, 2)\n            mstore(str, 40)\n\n            let o := add(str, 0x20)\n            mstore(add(o, 40), 0)\n\n            value := shl(96, value)\n\n            // We write the string from rightmost digit to leftmost digit.\n            // The following is essentially a do-while loop that also handles the zero case.\n            for { let i := 0 } 1 {} {\n                let p := add(o, add(i, i))\n                let temp := byte(i, value)\n                mstore8(add(p, 1), mload(and(temp, 15)))\n                mstore8(p, mload(shr(4, temp)))\n                i := add(i, 1)\n                if eq(i, 20) { break }\n            }\n        }\n    }\n\n    /// @dev Returns the hex encoded string from the raw bytes.\n    /// The output is encoded using 2 hexadecimal digits per byte.\n    function toHexString(bytes memory raw) internal pure returns (string memory str) {\n        str = toHexStringNoPrefix(raw);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let strLength := add(mload(str), 2) // Compute the length.\n            mstore(str, 0x3078) // Write the \"0x\" prefix.\n            str := sub(str, 2) // Move the pointer.\n            mstore(str, strLength) // Write the length.\n        }\n    }\n\n    /// @dev Returns the hex encoded string from the raw bytes.\n    /// The output is encoded using 2 hexadecimal digits per byte.\n    function toHexStringNoPrefix(bytes memory raw) internal pure returns (string memory str) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let length := mload(raw)\n            str := add(mload(0x40), 2) // Skip 2 bytes for the optional prefix.\n            mstore(str, add(length, length)) // Store the length of the output.\n\n            // Store \"0123456789abcdef\" in scratch space.\n            mstore(0x0f, 0x30313233343536373839616263646566)\n\n            let o := add(str, 0x20)\n            let end := add(raw, length)\n\n            for {} iszero(eq(raw, end)) {} {\n                raw := add(raw, 1)\n                mstore8(add(o, 1), mload(and(mload(raw), 15)))\n                mstore8(o, mload(and(shr(4, mload(raw)), 15)))\n                o := add(o, 2)\n            }\n            mstore(o, 0) // Zeroize the slot after the string.\n            mstore(0x40, add(o, 0x20)) // Allocate the memory.\n        }\n    }\n\n    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n    /*                   RUNE STRING OPERATIONS                   */\n    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n    /// @dev Returns the number of UTF characters in the string.\n    function runeCount(string memory s) internal pure returns (uint256 result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            if mload(s) {\n                mstore(0x00, div(not(0), 255))\n                mstore(0x20, 0x0202020202020202020202020202020202020202020202020303030304040506)\n                let o := add(s, 0x20)\n                let end := add(o, mload(s))\n                for { result := 1 } 1 { result := add(result, 1) } {\n                    o := add(o, byte(0, mload(shr(250, mload(o)))))\n                    if iszero(lt(o, end)) { break }\n                }\n            }\n        }\n    }\n\n    /// @dev Returns if this string is a 7-bit ASCII string.\n    /// (i.e. all characters codes are in [0..127])\n    function is7BitASCII(string memory s) internal pure returns (bool result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let mask := shl(7, div(not(0), 255))\n            result := 1\n            let n := mload(s)\n            if n {\n                let o := add(s, 0x20)\n                let end := add(o, n)\n                let last := mload(end)\n                mstore(end, 0)\n                for {} 1 {} {\n                    if and(mask, mload(o)) {\n                        result := 0\n                        break\n                    }\n                    o := add(o, 0x20)\n                    if iszero(lt(o, end)) { break }\n                }\n                mstore(end, last)\n            }\n        }\n    }\n\n    /*´:°•.°+.*•´.*:˚.°*.˚•´.°:°•.°•.*•´.*:˚.°*.˚•´.°:°•.°+.*•´.*:*/\n    /*                   BYTE STRING OPERATIONS                   */\n    /*.•°:°.´+˚.*°.˚:*.´•*.+°.•°:´*.´•*.•°.•°:°.´:•˚°.*°.˚:*.´+°.•*/\n\n    // For performance and bytecode compactness, byte string operations are restricted\n    // to 7-bit ASCII strings. All offsets are byte offsets, not UTF character offsets.\n    // Usage of byte string operations on charsets with runes spanning two or more bytes\n    // can lead to undefined behavior.\n\n    /// @dev Returns `subject` all occurrences of `search` replaced with `replacement`.\n    function replace(string memory subject, string memory search, string memory replacement)\n        internal\n        pure\n        returns (string memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let subjectLength := mload(subject)\n            let searchLength := mload(search)\n            let replacementLength := mload(replacement)\n\n            subject := add(subject, 0x20)\n            search := add(search, 0x20)\n            replacement := add(replacement, 0x20)\n            result := add(mload(0x40), 0x20)\n\n            let subjectEnd := add(subject, subjectLength)\n            if iszero(gt(searchLength, subjectLength)) {\n                let subjectSearchEnd := add(sub(subjectEnd, searchLength), 1)\n                let h := 0\n                if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\n                let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\n                let s := mload(search)\n                for {} 1 {} {\n                    let t := mload(subject)\n                    // Whether the first `searchLength % 32` bytes of\n                    // `subject` and `search` matches.\n                    if iszero(shr(m, xor(t, s))) {\n                        if h {\n                            if iszero(eq(keccak256(subject, searchLength), h)) {\n                                mstore(result, t)\n                                result := add(result, 1)\n                                subject := add(subject, 1)\n                                if iszero(lt(subject, subjectSearchEnd)) { break }\n                                continue\n                            }\n                        }\n                        // Copy the `replacement` one word at a time.\n                        for { let o := 0 } 1 {} {\n                            mstore(add(result, o), mload(add(replacement, o)))\n                            o := add(o, 0x20)\n                            if iszero(lt(o, replacementLength)) { break }\n                        }\n                        result := add(result, replacementLength)\n                        subject := add(subject, searchLength)\n                        if searchLength {\n                            if iszero(lt(subject, subjectSearchEnd)) { break }\n                            continue\n                        }\n                    }\n                    mstore(result, t)\n                    result := add(result, 1)\n                    subject := add(subject, 1)\n                    if iszero(lt(subject, subjectSearchEnd)) { break }\n                }\n            }\n\n            let resultRemainder := result\n            result := add(mload(0x40), 0x20)\n            let k := add(sub(resultRemainder, result), sub(subjectEnd, subject))\n            // Copy the rest of the string one word at a time.\n            for {} lt(subject, subjectEnd) {} {\n                mstore(resultRemainder, mload(subject))\n                resultRemainder := add(resultRemainder, 0x20)\n                subject := add(subject, 0x20)\n            }\n            result := sub(result, 0x20)\n            let last := add(add(result, 0x20), k) // Zeroize the slot after the string.\n            mstore(last, 0)\n            mstore(0x40, add(last, 0x20)) // Allocate the memory.\n            mstore(result, k) // Store the length.\n        }\n    }\n\n    /// @dev Returns the byte index of the first location of `search` in `subject`,\n    /// searching from left to right, starting from `from`.\n    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n    function indexOf(string memory subject, string memory search, uint256 from)\n        internal\n        pure\n        returns (uint256 result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            for { let subjectLength := mload(subject) } 1 {} {\n                if iszero(mload(search)) {\n                    if iszero(gt(from, subjectLength)) {\n                        result := from\n                        break\n                    }\n                    result := subjectLength\n                    break\n                }\n                let searchLength := mload(search)\n                let subjectStart := add(subject, 0x20)\n\n                result := not(0) // Initialize to `NOT_FOUND`.\n\n                subject := add(subjectStart, from)\n                let end := add(sub(add(subjectStart, subjectLength), searchLength), 1)\n\n                let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\n                let s := mload(add(search, 0x20))\n\n                if iszero(and(lt(subject, end), lt(from, subjectLength))) { break }\n\n                if iszero(lt(searchLength, 0x20)) {\n                    for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\n                        if iszero(shr(m, xor(mload(subject), s))) {\n                            if eq(keccak256(subject, searchLength), h) {\n                                result := sub(subject, subjectStart)\n                                break\n                            }\n                        }\n                        subject := add(subject, 1)\n                        if iszero(lt(subject, end)) { break }\n                    }\n                    break\n                }\n                for {} 1 {} {\n                    if iszero(shr(m, xor(mload(subject), s))) {\n                        result := sub(subject, subjectStart)\n                        break\n                    }\n                    subject := add(subject, 1)\n                    if iszero(lt(subject, end)) { break }\n                }\n                break\n            }\n        }\n    }\n\n    /// @dev Returns the byte index of the first location of `search` in `subject`,\n    /// searching from left to right.\n    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n    function indexOf(string memory subject, string memory search)\n        internal\n        pure\n        returns (uint256 result)\n    {\n        result = indexOf(subject, search, 0);\n    }\n\n    /// @dev Returns the byte index of the first location of `search` in `subject`,\n    /// searching from right to left, starting from `from`.\n    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n    function lastIndexOf(string memory subject, string memory search, uint256 from)\n        internal\n        pure\n        returns (uint256 result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            for {} 1 {} {\n                result := not(0) // Initialize to `NOT_FOUND`.\n                let searchLength := mload(search)\n                if gt(searchLength, mload(subject)) { break }\n                let w := result\n\n                let fromMax := sub(mload(subject), searchLength)\n                if iszero(gt(fromMax, from)) { from := fromMax }\n\n                let end := add(add(subject, 0x20), w)\n                subject := add(add(subject, 0x20), from)\n                if iszero(gt(subject, end)) { break }\n                // As this function is not too often used,\n                // we shall simply use keccak256 for smaller bytecode size.\n                for { let h := keccak256(add(search, 0x20), searchLength) } 1 {} {\n                    if eq(keccak256(subject, searchLength), h) {\n                        result := sub(subject, add(end, 1))\n                        break\n                    }\n                    subject := add(subject, w) // `sub(subject, 1)`.\n                    if iszero(gt(subject, end)) { break }\n                }\n                break\n            }\n        }\n    }\n\n    /// @dev Returns the byte index of the first location of `search` in `subject`,\n    /// searching from right to left.\n    /// Returns `NOT_FOUND` (i.e. `type(uint256).max`) if the `search` is not found.\n    function lastIndexOf(string memory subject, string memory search)\n        internal\n        pure\n        returns (uint256 result)\n    {\n        result = lastIndexOf(subject, search, uint256(int256(-1)));\n    }\n\n    /// @dev Returns true if `search` is found in `subject`, false otherwise.\n    function contains(string memory subject, string memory search) internal pure returns (bool) {\n        return indexOf(subject, search) != NOT_FOUND;\n    }\n\n    /// @dev Returns whether `subject` starts with `search`.\n    function startsWith(string memory subject, string memory search)\n        internal\n        pure\n        returns (bool result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let searchLength := mload(search)\n            // Just using keccak256 directly is actually cheaper.\n            // forgefmt: disable-next-item\n            result := and(\n                iszero(gt(searchLength, mload(subject))),\n                eq(\n                    keccak256(add(subject, 0x20), searchLength),\n                    keccak256(add(search, 0x20), searchLength)\n                )\n            )\n        }\n    }\n\n    /// @dev Returns whether `subject` ends with `search`.\n    function endsWith(string memory subject, string memory search)\n        internal\n        pure\n        returns (bool result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let searchLength := mload(search)\n            let subjectLength := mload(subject)\n            // Whether `search` is not longer than `subject`.\n            let withinRange := iszero(gt(searchLength, subjectLength))\n            // Just using keccak256 directly is actually cheaper.\n            // forgefmt: disable-next-item\n            result := and(\n                withinRange,\n                eq(\n                    keccak256(\n                        // `subject + 0x20 + max(subjectLength - searchLength, 0)`.\n                        add(add(subject, 0x20), mul(withinRange, sub(subjectLength, searchLength))),\n                        searchLength\n                    ),\n                    keccak256(add(search, 0x20), searchLength)\n                )\n            )\n        }\n    }\n\n    /// @dev Returns `subject` repeated `times`.\n    function repeat(string memory subject, uint256 times)\n        internal\n        pure\n        returns (string memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let subjectLength := mload(subject)\n            if iszero(or(iszero(times), iszero(subjectLength))) {\n                subject := add(subject, 0x20)\n                result := mload(0x40)\n                let output := add(result, 0x20)\n                for {} 1 {} {\n                    // Copy the `subject` one word at a time.\n                    for { let o := 0 } 1 {} {\n                        mstore(add(output, o), mload(add(subject, o)))\n                        o := add(o, 0x20)\n                        if iszero(lt(o, subjectLength)) { break }\n                    }\n                    output := add(output, subjectLength)\n                    times := sub(times, 1)\n                    if iszero(times) { break }\n                }\n                mstore(output, 0) // Zeroize the slot after the string.\n                let resultLength := sub(output, add(result, 0x20))\n                mstore(result, resultLength) // Store the length.\n                // Allocate the memory.\n                mstore(0x40, add(result, add(resultLength, 0x20)))\n            }\n        }\n    }\n\n    /// @dev Returns a copy of `subject` sliced from `start` to `end` (exclusive).\n    /// `start` and `end` are byte offsets.\n    function slice(string memory subject, uint256 start, uint256 end)\n        internal\n        pure\n        returns (string memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let subjectLength := mload(subject)\n            if iszero(gt(subjectLength, end)) { end := subjectLength }\n            if iszero(gt(subjectLength, start)) { start := subjectLength }\n            if lt(start, end) {\n                result := mload(0x40)\n                let resultLength := sub(end, start)\n                mstore(result, resultLength)\n                subject := add(subject, start)\n                let w := not(0x1f)\n                // Copy the `subject` one word at a time, backwards.\n                for { let o := and(add(resultLength, 0x1f), w) } 1 {} {\n                    mstore(add(result, o), mload(add(subject, o)))\n                    o := add(o, w) // `sub(o, 0x20)`.\n                    if iszero(o) { break }\n                }\n                // Zeroize the slot after the string.\n                mstore(add(add(result, 0x20), resultLength), 0)\n                // Allocate memory for the length and the bytes,\n                // rounded up to a multiple of 32.\n                mstore(0x40, add(result, and(add(resultLength, 0x3f), w)))\n            }\n        }\n    }\n\n    /// @dev Returns a copy of `subject` sliced from `start` to the end of the string.\n    /// `start` is a byte offset.\n    function slice(string memory subject, uint256 start)\n        internal\n        pure\n        returns (string memory result)\n    {\n        result = slice(subject, start, uint256(int256(-1)));\n    }\n\n    /// @dev Returns all the indices of `search` in `subject`.\n    /// The indices are byte offsets.\n    function indicesOf(string memory subject, string memory search)\n        internal\n        pure\n        returns (uint256[] memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let subjectLength := mload(subject)\n            let searchLength := mload(search)\n\n            if iszero(gt(searchLength, subjectLength)) {\n                subject := add(subject, 0x20)\n                search := add(search, 0x20)\n                result := add(mload(0x40), 0x20)\n\n                let subjectStart := subject\n                let subjectSearchEnd := add(sub(add(subject, subjectLength), searchLength), 1)\n                let h := 0\n                if iszero(lt(searchLength, 0x20)) { h := keccak256(search, searchLength) }\n                let m := shl(3, sub(0x20, and(searchLength, 0x1f)))\n                let s := mload(search)\n                for {} 1 {} {\n                    let t := mload(subject)\n                    // Whether the first `searchLength % 32` bytes of\n                    // `subject` and `search` matches.\n                    if iszero(shr(m, xor(t, s))) {\n                        if h {\n                            if iszero(eq(keccak256(subject, searchLength), h)) {\n                                subject := add(subject, 1)\n                                if iszero(lt(subject, subjectSearchEnd)) { break }\n                                continue\n                            }\n                        }\n                        // Append to `result`.\n                        mstore(result, sub(subject, subjectStart))\n                        result := add(result, 0x20)\n                        // Advance `subject` by `searchLength`.\n                        subject := add(subject, searchLength)\n                        if searchLength {\n                            if iszero(lt(subject, subjectSearchEnd)) { break }\n                            continue\n                        }\n                    }\n                    subject := add(subject, 1)\n                    if iszero(lt(subject, subjectSearchEnd)) { break }\n                }\n                let resultEnd := result\n                // Assign `result` to the free memory pointer.\n                result := mload(0x40)\n                // Store the length of `result`.\n                mstore(result, shr(5, sub(resultEnd, add(result, 0x20))))\n                // Allocate memory for result.\n                // We allocate one more word, so this array can be recycled for {split}.\n                mstore(0x40, add(resultEnd, 0x20))\n            }\n        }\n    }\n\n    /// @dev Returns a arrays of strings based on the `delimiter` inside of the `subject` string.\n    function split(string memory subject, string memory delimiter)\n        internal\n        pure\n        returns (string[] memory result)\n    {\n        uint256[] memory indices = indicesOf(subject, delimiter);\n        /// @solidity memory-safe-assembly\n        assembly {\n            let w := not(0x1f)\n            let indexPtr := add(indices, 0x20)\n            let indicesEnd := add(indexPtr, shl(5, add(mload(indices), 1)))\n            mstore(add(indicesEnd, w), mload(subject))\n            mstore(indices, add(mload(indices), 1))\n            let prevIndex := 0\n            for {} 1 {} {\n                let index := mload(indexPtr)\n                mstore(indexPtr, 0x60)\n                if iszero(eq(index, prevIndex)) {\n                    let element := mload(0x40)\n                    let elementLength := sub(index, prevIndex)\n                    mstore(element, elementLength)\n                    // Copy the `subject` one word at a time, backwards.\n                    for { let o := and(add(elementLength, 0x1f), w) } 1 {} {\n                        mstore(add(element, o), mload(add(add(subject, prevIndex), o)))\n                        o := add(o, w) // `sub(o, 0x20)`.\n                        if iszero(o) { break }\n                    }\n                    // Zeroize the slot after the string.\n                    mstore(add(add(element, 0x20), elementLength), 0)\n                    // Allocate memory for the length and the bytes,\n                    // rounded up to a multiple of 32.\n                    mstore(0x40, add(element, and(add(elementLength, 0x3f), w)))\n                    // Store the `element` into the array.\n                    mstore(indexPtr, element)\n                }\n                prevIndex := add(index, mload(delimiter))\n                indexPtr := add(indexPtr, 0x20)\n                if iszero(lt(indexPtr, indicesEnd)) { break }\n            }\n            result := indices\n            if iszero(mload(delimiter)) {\n                result := add(indices, 0x20)\n                mstore(result, sub(mload(indices), 2))\n            }\n        }\n    }\n\n    /// @dev Returns a concatenated string of `a` and `b`.\n    /// Cheaper than `string.concat()` and does not de-align the free memory pointer.\n    function concat(string memory a, string memory b)\n        internal\n        pure\n        returns (string memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let w := not(0x1f)\n            result := mload(0x40)\n            let aLength := mload(a)\n            // Copy `a` one word at a time, backwards.\n            for { let o := and(add(aLength, 0x20), w) } 1 {} {\n                mstore(add(result, o), mload(add(a, o)))\n                o := add(o, w) // `sub(o, 0x20)`.\n                if iszero(o) { break }\n            }\n            let bLength := mload(b)\n            let output := add(result, aLength)\n            // Copy `b` one word at a time, backwards.\n            for { let o := and(add(bLength, 0x20), w) } 1 {} {\n                mstore(add(output, o), mload(add(b, o)))\n                o := add(o, w) // `sub(o, 0x20)`.\n                if iszero(o) { break }\n            }\n            let totalLength := add(aLength, bLength)\n            let last := add(add(result, 0x20), totalLength)\n            // Zeroize the slot after the string.\n            mstore(last, 0)\n            // Stores the length.\n            mstore(result, totalLength)\n            // Allocate memory for the length and the bytes,\n            // rounded up to a multiple of 32.\n            mstore(0x40, and(add(last, 0x1f), w))\n        }\n    }\n\n    /// @dev Returns a copy of the string in either lowercase or UPPERCASE.\n    /// WARNING! This function is only compatible with 7-bit ASCII strings.\n    function toCase(string memory subject, bool toUpper)\n        internal\n        pure\n        returns (string memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let length := mload(subject)\n            if length {\n                result := add(mload(0x40), 0x20)\n                subject := add(subject, 1)\n                let flags := shl(add(70, shl(5, toUpper)), 0x3ffffff)\n                let w := not(0)\n                for { let o := length } 1 {} {\n                    o := add(o, w)\n                    let b := and(0xff, mload(add(subject, o)))\n                    mstore8(add(result, o), xor(b, and(shr(b, flags), 0x20)))\n                    if iszero(o) { break }\n                }\n                result := mload(0x40)\n                mstore(result, length) // Store the length.\n                let last := add(add(result, 0x20), length)\n                mstore(last, 0) // Zeroize the slot after the string.\n                mstore(0x40, add(last, 0x20)) // Allocate the memory.\n            }\n        }\n    }\n\n    /// @dev Returns a string from a small bytes32 string.\n    /// `s` must be null-terminated, or behavior will be undefined.\n    function fromSmallString(bytes32 s) internal pure returns (string memory result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := mload(0x40)\n            let n := 0\n            for {} byte(n, s) { n := add(n, 1) } {} // Scan for '\\0'.\n            mstore(result, n)\n            let o := add(result, 0x20)\n            mstore(o, s)\n            mstore(add(o, n), 0)\n            mstore(0x40, add(result, 0x40))\n        }\n    }\n\n    /// @dev Returns the small string, with all bytes after the first null byte zeroized.\n    function normalizeSmallString(bytes32 s) internal pure returns (bytes32 result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            for {} byte(result, s) { result := add(result, 1) } {} // Scan for '\\0'.\n            mstore(0x00, s)\n            mstore(result, 0x00)\n            result := mload(0x00)\n        }\n    }\n\n    /// @dev Returns the string as a normalized null-terminated small string.\n    function toSmallString(string memory s) internal pure returns (bytes32 result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := mload(s)\n            if iszero(lt(result, 33)) {\n                mstore(0x00, 0xec92f9a3) // `TooBigForSmallString()`.\n                revert(0x1c, 0x04)\n            }\n            result := shl(shl(3, sub(32, result)), mload(add(s, result)))\n        }\n    }\n\n    /// @dev Returns a lowercased copy of the string.\n    /// WARNING! This function is only compatible with 7-bit ASCII strings.\n    function lower(string memory subject) internal pure returns (string memory result) {\n        result = toCase(subject, false);\n    }\n\n    /// @dev Returns an UPPERCASED copy of the string.\n    /// WARNING! This function is only compatible with 7-bit ASCII strings.\n    function upper(string memory subject) internal pure returns (string memory result) {\n        result = toCase(subject, true);\n    }\n\n    /// @dev Escapes the string to be used within HTML tags.\n    function escapeHTML(string memory s) internal pure returns (string memory result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let end := add(s, mload(s))\n            result := add(mload(0x40), 0x20)\n            // Store the bytes of the packed offsets and strides into the scratch space.\n            // `packed = (stride << 5) | offset`. Max offset is 20. Max stride is 6.\n            mstore(0x1f, 0x900094)\n            mstore(0x08, 0xc0000000a6ab)\n            // Store \"&quot;&amp;&#39;&lt;&gt;\" into the scratch space.\n            mstore(0x00, shl(64, 0x2671756f743b26616d703b262333393b266c743b2667743b))\n            for {} iszero(eq(s, end)) {} {\n                s := add(s, 1)\n                let c := and(mload(s), 0xff)\n                // Not in `[\"\\\"\",\"'\",\"&\",\"<\",\">\"]`.\n                if iszero(and(shl(c, 1), 0x500000c400000000)) {\n                    mstore8(result, c)\n                    result := add(result, 1)\n                    continue\n                }\n                let t := shr(248, mload(c))\n                mstore(result, mload(and(t, 0x1f)))\n                result := add(result, shr(5, t))\n            }\n            let last := result\n            mstore(last, 0) // Zeroize the slot after the string.\n            result := mload(0x40)\n            mstore(result, sub(last, add(result, 0x20))) // Store the length.\n            mstore(0x40, add(last, 0x20)) // Allocate the memory.\n        }\n    }\n\n    /// @dev Escapes the string to be used within double-quotes in a JSON.\n    /// If `addDoubleQuotes` is true, the result will be enclosed in double-quotes.\n    function escapeJSON(string memory s, bool addDoubleQuotes)\n        internal\n        pure\n        returns (string memory result)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let end := add(s, mload(s))\n            result := add(mload(0x40), 0x20)\n            if addDoubleQuotes {\n                mstore8(result, 34)\n                result := add(1, result)\n            }\n            // Store \"\\\\u0000\" in scratch space.\n            // Store \"0123456789abcdef\" in scratch space.\n            // Also, store `{0x08:\"b\", 0x09:\"t\", 0x0a:\"n\", 0x0c:\"f\", 0x0d:\"r\"}`.\n            // into the scratch space.\n            mstore(0x15, 0x5c75303030303031323334353637383961626364656662746e006672)\n            // Bitmask for detecting `[\"\\\"\",\"\\\\\"]`.\n            let e := or(shl(0x22, 1), shl(0x5c, 1))\n            for {} iszero(eq(s, end)) {} {\n                s := add(s, 1)\n                let c := and(mload(s), 0xff)\n                if iszero(lt(c, 0x20)) {\n                    if iszero(and(shl(c, 1), e)) {\n                        // Not in `[\"\\\"\",\"\\\\\"]`.\n                        mstore8(result, c)\n                        result := add(result, 1)\n                        continue\n                    }\n                    mstore8(result, 0x5c) // \"\\\\\".\n                    mstore8(add(result, 1), c)\n                    result := add(result, 2)\n                    continue\n                }\n                if iszero(and(shl(c, 1), 0x3700)) {\n                    // Not in `[\"\\b\",\"\\t\",\"\\n\",\"\\f\",\"\\d\"]`.\n                    mstore8(0x1d, mload(shr(4, c))) // Hex value.\n                    mstore8(0x1e, mload(and(c, 15))) // Hex value.\n                    mstore(result, mload(0x19)) // \"\\\\u00XX\".\n                    result := add(result, 6)\n                    continue\n                }\n                mstore8(result, 0x5c) // \"\\\\\".\n                mstore8(add(result, 1), mload(add(c, 8)))\n                result := add(result, 2)\n            }\n            if addDoubleQuotes {\n                mstore8(result, 34)\n                result := add(1, result)\n            }\n            let last := result\n            mstore(last, 0) // Zeroize the slot after the string.\n            result := mload(0x40)\n            mstore(result, sub(last, add(result, 0x20))) // Store the length.\n            mstore(0x40, add(last, 0x20)) // Allocate the memory.\n        }\n    }\n\n    /// @dev Escapes the string to be used within double-quotes in a JSON.\n    function escapeJSON(string memory s) internal pure returns (string memory result) {\n        result = escapeJSON(s, false);\n    }\n\n    /// @dev Returns whether `a` equals `b`.\n    function eq(string memory a, string memory b) internal pure returns (bool result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := eq(keccak256(add(a, 0x20), mload(a)), keccak256(add(b, 0x20), mload(b)))\n        }\n    }\n\n    /// @dev Returns whether `a` equals `b`, where `b` is a null-terminated small string.\n    function eqs(string memory a, bytes32 b) internal pure returns (bool result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // These should be evaluated on compile time, as far as possible.\n            let m := not(shl(7, div(not(iszero(b)), 255))) // `0x7f7f ...`.\n            let x := not(or(m, or(b, add(m, and(b, m)))))\n            let r := shl(7, iszero(iszero(shr(128, x))))\n            r := or(r, shl(6, iszero(iszero(shr(64, 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            // forgefmt: disable-next-item\n            result := gt(eq(mload(a), add(iszero(x), xor(31, shr(3, r)))),\n                xor(shr(add(8, r), b), shr(add(8, r), mload(add(a, 0x20)))))\n        }\n    }\n\n    /// @dev Packs a single string with its length into a single word.\n    /// Returns `bytes32(0)` if the length is zero or greater than 31.\n    function packOne(string memory a) internal pure returns (bytes32 result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // We don't need to zero right pad the string,\n            // since this is our own custom non-standard packing scheme.\n            result :=\n                mul(\n                    // Load the length and the bytes.\n                    mload(add(a, 0x1f)),\n                    // `length != 0 && length < 32`. Abuses underflow.\n                    // Assumes that the length is valid and within the block gas limit.\n                    lt(sub(mload(a), 1), 0x1f)\n                )\n        }\n    }\n\n    /// @dev Unpacks a string packed using {packOne}.\n    /// Returns the empty string if `packed` is `bytes32(0)`.\n    /// If `packed` is not an output of {packOne}, the output behavior is undefined.\n    function unpackOne(bytes32 packed) internal pure returns (string memory result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Grab the free memory pointer.\n            result := mload(0x40)\n            // Allocate 2 words (1 for the length, 1 for the bytes).\n            mstore(0x40, add(result, 0x40))\n            // Zeroize the length slot.\n            mstore(result, 0)\n            // Store the length and bytes.\n            mstore(add(result, 0x1f), packed)\n            // Right pad with zeroes.\n            mstore(add(add(result, 0x20), mload(result)), 0)\n        }\n    }\n\n    /// @dev Packs two strings with their lengths into a single word.\n    /// Returns `bytes32(0)` if combined length is zero or greater than 30.\n    function packTwo(string memory a, string memory b) internal pure returns (bytes32 result) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let aLength := mload(a)\n            // We don't need to zero right pad the strings,\n            // since this is our own custom non-standard packing scheme.\n            result :=\n                mul(\n                    // Load the length and the bytes of `a` and `b`.\n                    or(\n                        shl(shl(3, sub(0x1f, aLength)), mload(add(a, aLength))),\n                        mload(sub(add(b, 0x1e), aLength))\n                    ),\n                    // `totalLength != 0 && totalLength < 31`. Abuses underflow.\n                    // Assumes that the lengths are valid and within the block gas limit.\n                    lt(sub(add(aLength, mload(b)), 1), 0x1e)\n                )\n        }\n    }\n\n    /// @dev Unpacks strings packed using {packTwo}.\n    /// Returns the empty strings if `packed` is `bytes32(0)`.\n    /// If `packed` is not an output of {packTwo}, the output behavior is undefined.\n    function unpackTwo(bytes32 packed)\n        internal\n        pure\n        returns (string memory resultA, string memory resultB)\n    {\n        /// @solidity memory-safe-assembly\n        assembly {\n            // Grab the free memory pointer.\n            resultA := mload(0x40)\n            resultB := add(resultA, 0x40)\n            // Allocate 2 words for each string (1 for the length, 1 for the byte). Total 4 words.\n            mstore(0x40, add(resultB, 0x40))\n            // Zeroize the length slots.\n            mstore(resultA, 0)\n            mstore(resultB, 0)\n            // Store the lengths and bytes.\n            mstore(add(resultA, 0x1f), packed)\n            mstore(add(resultB, 0x1f), mload(add(add(resultA, 0x20), mload(resultA))))\n            // Right pad with zeroes.\n            mstore(add(add(resultA, 0x20), mload(resultA)), 0)\n            mstore(add(add(resultB, 0x20), mload(resultB)), 0)\n        }\n    }\n\n    /// @dev Directly returns `a` without copying.\n    function directReturn(string memory a) internal pure {\n        assembly {\n            // Assumes that the string does not start from the scratch space.\n            let retStart := sub(a, 0x20)\n            let retSize := add(mload(a), 0x40)\n            // Right pad with zeroes. Just in case the string is produced\n            // by a method that doesn't zero right pad.\n            mstore(add(retStart, retSize), 0)\n            // Store the return offset.\n            mstore(retStart, 0x20)\n            // End the transaction, returning the string.\n            return(retStart, retSize)\n        }\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"
      },
      "src/libraries/Bytes.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/// @title Bytes\n/// @notice Bytes is a library for manipulating byte arrays.\nlibrary Bytes {\n    /// @custom:attribution https://github.com/GNSPS/solidity-bytes-utils\n    /// @notice Slices a byte array with a given starting index and length. Returns a new byte array\n    ///         as opposed to a pointer to the original array. Will throw if trying to slice more\n    ///         bytes than exist in the array.\n    /// @param _bytes Byte array to slice.\n    /// @param _start Starting index of the slice.\n    /// @param _length Length of the slice.\n    /// @return Slice of the input byte array.\n    function slice(bytes memory _bytes, uint256 _start, uint256 _length) internal pure returns (bytes memory) {\n        unchecked {\n            require(_length + 31 >= _length, \"slice_overflow\");\n            require(_start + _length >= _start, \"slice_overflow\");\n            require(_bytes.length >= _start + _length, \"slice_outOfBounds\");\n        }\n\n        bytes memory tempBytes;\n\n        assembly {\n            switch iszero(_length)\n            case 0 {\n                // Get a location of some free memory and store it in tempBytes as\n                // Solidity does for memory variables.\n                tempBytes := mload(0x40)\n\n                // The first word of the slice result is potentially a partial\n                // word read from the original array. To read it, we calculate\n                // the length of that partial word and start copying that many\n                // bytes into the array. The first word we copy will start with\n                // data we don't care about, but the last `lengthmod` bytes will\n                // land at the beginning of the contents of the new array. When\n                // we're done copying, we overwrite the full first word with\n                // the actual length of the slice.\n                let lengthmod := and(_length, 31)\n\n                // The multiplication in the next line is necessary\n                // because when slicing multiples of 32 bytes (lengthmod == 0)\n                // the following copy loop was copying the origin's length\n                // and then ending prematurely not copying everything it should.\n                let mc := add(add(tempBytes, lengthmod), mul(0x20, iszero(lengthmod)))\n                let end := add(mc, _length)\n\n                for {\n                    // The multiplication in the next line has the same exact purpose\n                    // as the one above.\n                    let cc := add(add(add(_bytes, lengthmod), mul(0x20, iszero(lengthmod))), _start)\n                } lt(mc, end) {\n                    mc := add(mc, 0x20)\n                    cc := add(cc, 0x20)\n                } { mstore(mc, mload(cc)) }\n\n                mstore(tempBytes, _length)\n\n                //update free-memory pointer\n                //allocating the array padded to 32 bytes like the compiler does now\n                mstore(0x40, and(add(mc, 31), not(31)))\n            }\n            //if we want a zero-length slice let's just return a zero-length array\n            default {\n                tempBytes := mload(0x40)\n\n                //zero out the 32 bytes slice we are about to return\n                //we need to do it because Solidity does not garbage collect\n                mstore(tempBytes, 0)\n\n                mstore(0x40, add(tempBytes, 0x20))\n            }\n        }\n\n        return tempBytes;\n    }\n\n    /// @notice Slices a byte array with a given starting index up to the end of the original byte\n    ///         array. Returns a new array rathern than a pointer to the original.\n    /// @param _bytes Byte array to slice.\n    /// @param _start Starting index of the slice.\n    /// @return Slice of the input byte array.\n    function slice(bytes memory _bytes, uint256 _start) internal pure returns (bytes memory) {\n        if (_start >= _bytes.length) {\n            return bytes(\"\");\n        }\n        return slice(_bytes, _start, _bytes.length - _start);\n    }\n\n    /// @notice Converts a byte array into a nibble array by splitting each byte into two nibbles.\n    ///         Resulting nibble array will be exactly twice as long as the input byte array.\n    /// @param _bytes Input byte array to convert.\n    /// @return Resulting nibble array.\n    function toNibbles(bytes memory _bytes) internal pure returns (bytes memory) {\n        bytes memory _nibbles;\n        assembly {\n            // Grab a free memory offset for the new array\n            _nibbles := mload(0x40)\n\n            // Load the length of the passed bytes array from memory\n            let bytesLength := mload(_bytes)\n\n            // Calculate the length of the new nibble array\n            // This is the length of the input array times 2\n            let nibblesLength := shl(0x01, bytesLength)\n\n            // Update the free memory pointer to allocate memory for the new array.\n            // To do this, we add the length of the new array + 32 bytes for the array length\n            // rounded up to the nearest 32 byte boundary to the current free memory pointer.\n            mstore(0x40, add(_nibbles, and(not(0x1F), add(nibblesLength, 0x3F))))\n\n            // Store the length of the new array in memory\n            mstore(_nibbles, nibblesLength)\n\n            // Store the memory offset of the _bytes array's contents on the stack\n            let bytesStart := add(_bytes, 0x20)\n\n            // Store the memory offset of the nibbles array's contents on the stack\n            let nibblesStart := add(_nibbles, 0x20)\n\n            // Loop through each byte in the input array\n            for { let i := 0x00 } lt(i, bytesLength) { i := add(i, 0x01) } {\n                // Get the starting offset of the next 2 bytes in the nibbles array\n                let offset := add(nibblesStart, shl(0x01, i))\n                // Load the byte at the current index within the `_bytes` array\n                let b := byte(0x00, mload(add(bytesStart, i)))\n\n                // Pull out the first nibble and store it in the new array\n                mstore8(offset, shr(0x04, b))\n                // Pull out the second nibble and store it in the new array\n                mstore8(add(offset, 0x01), and(b, 0x0F))\n            }\n        }\n        return _nibbles;\n    }\n\n    /// @notice Compares two byte arrays by comparing their keccak256 hashes.\n    /// @param _bytes First byte array to compare.\n    /// @param _other Second byte array to compare.\n    /// @return True if the two byte arrays are equal, false otherwise.\n    function equal(bytes memory _bytes, bytes memory _other) internal pure returns (bool) {\n        return keccak256(_bytes) == keccak256(_other);\n    }\n}\n"
      },
      "src/libraries/rlp/RLPReader.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.8;\n\nimport \"./RLPErrors.sol\";\n\n/// @custom:attribution https://github.com/hamdiallam/Solidity-RLP\n/// @title RLPReader\n/// @notice RLPReader is a library for parsing RLP-encoded byte arrays into Solidity types. Adapted\n///         from Solidity-RLP (https://github.com/hamdiallam/Solidity-RLP) by Hamdi Allam with\n///         various tweaks to improve readability.\nlibrary RLPReader {\n    /// @notice Custom pointer type to avoid confusion between pointers and uint256s.\n    type MemoryPointer is uint256;\n\n    /// @notice RLP item types.\n    /// @custom:value DATA_ITEM Represents an RLP data item (NOT a list).\n    /// @custom:value LIST_ITEM Represents an RLP list item.\n    enum RLPItemType {\n        DATA_ITEM,\n        LIST_ITEM\n    }\n\n    /// @notice Struct representing an RLP item.\n    /// @custom:field length Length of the RLP item.\n    /// @custom:field ptr    Pointer to the RLP item in memory.\n    struct RLPItem {\n        uint256 length;\n        MemoryPointer ptr;\n    }\n\n    /// @notice Max list length that this library will accept.\n    uint256 internal constant MAX_LIST_LENGTH = 32;\n\n    /// @notice Converts bytes to a reference to memory position and length.\n    /// @param _in Input bytes to convert.\n    /// @return out_ Output memory reference.\n    function toRLPItem(bytes memory _in) internal pure returns (RLPItem memory out_) {\n        // Empty arrays are not RLP items.\n        if (_in.length == 0) revert EmptyItem();\n\n        MemoryPointer ptr;\n        assembly {\n            ptr := add(_in, 32)\n        }\n\n        out_ = RLPItem({ length: _in.length, ptr: ptr });\n    }\n\n    /// @notice Reads an RLP list value into a list of RLP items.\n    /// @param _in RLP list value.\n    /// @return out_ Decoded RLP list items.\n    function readList(RLPItem memory _in) internal pure returns (RLPItem[] memory out_) {\n        (uint256 listOffset, uint256 listLength, RLPItemType itemType) = _decodeLength(_in);\n\n        if (itemType != RLPItemType.LIST_ITEM) revert UnexpectedString();\n\n        if (listOffset + listLength != _in.length) revert InvalidDataRemainder();\n\n        // Solidity in-memory arrays can't be increased in size, but *can* be decreased in size by\n        // writing to the length. Since we can't know the number of RLP items without looping over\n        // the entire input, we'd have to loop twice to accurately size this array. It's easier to\n        // simply set a reasonable maximum list length and decrease the size before we finish.\n        out_ = new RLPItem[](MAX_LIST_LENGTH);\n\n        uint256 itemCount = 0;\n        uint256 offset = listOffset;\n        while (offset < _in.length) {\n            (uint256 itemOffset, uint256 itemLength,) = _decodeLength(\n                RLPItem({ length: _in.length - offset, ptr: MemoryPointer.wrap(MemoryPointer.unwrap(_in.ptr) + offset) })\n            );\n\n            // We don't need to check itemCount < out.length explicitly because Solidity already\n            // handles this check on our behalf, we'd just be wasting gas.\n            out_[itemCount] = RLPItem({\n                length: itemLength + itemOffset,\n                ptr: MemoryPointer.wrap(MemoryPointer.unwrap(_in.ptr) + offset)\n            });\n\n            itemCount += 1;\n            offset += itemOffset + itemLength;\n        }\n\n        // Decrease the array size to match the actual item count.\n        assembly {\n            mstore(out_, itemCount)\n        }\n    }\n\n    /// @notice Reads an RLP list value into a list of RLP items.\n    /// @param _in RLP list value.\n    /// @return out_ Decoded RLP list items.\n    function readList(bytes memory _in) internal pure returns (RLPItem[] memory out_) {\n        out_ = readList(toRLPItem(_in));\n    }\n\n    /// @notice Reads an RLP bytes value into bytes.\n    /// @param _in RLP bytes value.\n    /// @return out_ Decoded bytes.\n    function readBytes(RLPItem memory _in) internal pure returns (bytes memory out_) {\n        (uint256 itemOffset, uint256 itemLength, RLPItemType itemType) = _decodeLength(_in);\n\n        if (itemType != RLPItemType.DATA_ITEM) revert UnexpectedList();\n\n        if (_in.length != itemOffset + itemLength) revert InvalidDataRemainder();\n\n        out_ = _copy(_in.ptr, itemOffset, itemLength);\n    }\n\n    /// @notice Reads an RLP bytes value into bytes.\n    /// @param _in RLP bytes value.\n    /// @return out_ Decoded bytes.\n    function readBytes(bytes memory _in) internal pure returns (bytes memory out_) {\n        out_ = readBytes(toRLPItem(_in));\n    }\n\n    /// @notice Reads the raw bytes of an RLP item.\n    /// @param _in RLP item to read.\n    /// @return out_ Raw RLP bytes.\n    function readRawBytes(RLPItem memory _in) internal pure returns (bytes memory out_) {\n        out_ = _copy(_in.ptr, 0, _in.length);\n    }\n\n    /// @notice Decodes the length of an RLP item.\n    /// @param _in RLP item to decode.\n    /// @return offset_ Offset of the encoded data.\n    /// @return length_ Length of the encoded data.\n    /// @return type_ RLP item type (LIST_ITEM or DATA_ITEM).\n    function _decodeLength(RLPItem memory _in)\n        private\n        pure\n        returns (uint256 offset_, uint256 length_, RLPItemType type_)\n    {\n        // Short-circuit if there's nothing to decode, note that we perform this check when\n        // the user creates an RLP item via toRLPItem, but it's always possible for them to bypass\n        // that function and create an RLP item directly. So we need to check this anyway.\n        if (_in.length == 0) revert EmptyItem();\n\n        MemoryPointer ptr = _in.ptr;\n        uint256 prefix;\n        assembly {\n            prefix := byte(0, mload(ptr))\n        }\n\n        if (prefix <= 0x7f) {\n            // Single byte.\n            return (0, 1, RLPItemType.DATA_ITEM);\n        } else if (prefix <= 0xb7) {\n            // Short string.\n\n            // slither-disable-next-line variable-scope\n            uint256 strLen = prefix - 0x80;\n\n            if (_in.length <= strLen) revert ContentLengthMismatch();\n\n            bytes1 firstByteOfContent;\n            assembly {\n                firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))\n            }\n\n            if (strLen == 1 && firstByteOfContent < 0x80) revert InvalidHeader();\n\n            return (1, strLen, RLPItemType.DATA_ITEM);\n        } else if (prefix <= 0xbf) {\n            // Long string.\n            uint256 lenOfStrLen = prefix - 0xb7;\n\n            if (_in.length <= lenOfStrLen) revert ContentLengthMismatch();\n\n            bytes1 firstByteOfContent;\n            assembly {\n                firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))\n            }\n\n            if (firstByteOfContent == 0x00) revert InvalidHeader();\n\n            uint256 strLen;\n            assembly {\n                strLen := shr(sub(256, mul(8, lenOfStrLen)), mload(add(ptr, 1)))\n            }\n\n            if (strLen <= 55) revert InvalidHeader();\n\n            if (_in.length <= lenOfStrLen + strLen) revert ContentLengthMismatch();\n\n            return (1 + lenOfStrLen, strLen, RLPItemType.DATA_ITEM);\n        } else if (prefix <= 0xf7) {\n            // Short list.\n            // slither-disable-next-line variable-scope\n            uint256 listLen = prefix - 0xc0;\n\n            if (_in.length <= listLen) revert ContentLengthMismatch();\n\n            return (1, listLen, RLPItemType.LIST_ITEM);\n        } else {\n            // Long list.\n            uint256 lenOfListLen = prefix - 0xf7;\n\n            if (_in.length <= lenOfListLen) revert ContentLengthMismatch();\n\n            bytes1 firstByteOfContent;\n            assembly {\n                firstByteOfContent := and(mload(add(ptr, 1)), shl(248, 0xff))\n            }\n\n            if (firstByteOfContent == 0x00) revert InvalidHeader();\n\n            uint256 listLen;\n            assembly {\n                listLen := shr(sub(256, mul(8, lenOfListLen)), mload(add(ptr, 1)))\n            }\n\n            if (listLen <= 55) revert InvalidHeader();\n\n            if (_in.length <= lenOfListLen + listLen) revert ContentLengthMismatch();\n\n            return (1 + lenOfListLen, listLen, RLPItemType.LIST_ITEM);\n        }\n    }\n\n    /// @notice Copies the bytes from a memory location.\n    /// @param _src    Pointer to the location to read from.\n    /// @param _offset Offset to start reading from.\n    /// @param _length Number of bytes to read.\n    /// @return out_ Copied bytes.\n    function _copy(MemoryPointer _src, uint256 _offset, uint256 _length) private pure returns (bytes memory out_) {\n        out_ = new bytes(_length);\n        if (_length == 0) {\n            return out_;\n        }\n\n        // Mostly based on Solidity's copy_memory_to_memory:\n        // https://github.com/ethereum/solidity/blob/34dd30d71b4da730488be72ff6af7083cf2a91f6/libsolidity/codegen/YulUtilFunctions.cpp#L102-L114\n        uint256 src = MemoryPointer.unwrap(_src) + _offset;\n        assembly {\n            let dest := add(out_, 32)\n            let i := 0\n            for { } lt(i, _length) { i := add(i, 32) } { mstore(add(dest, i), mload(add(src, i))) }\n\n            if gt(i, _length) { mstore(add(dest, _length), 0) }\n        }\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"
      },
      "src/libraries/rlp/RLPErrors.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity 0.8.15;\n\n/// @notice The length of an RLP item must be greater than zero to be decodable\nerror EmptyItem();\n\n/// @notice The decoded item type for list is not a list item\nerror UnexpectedString();\n\n/// @notice The RLP item has an invalid data remainder\nerror InvalidDataRemainder();\n\n/// @notice Decoded item type for bytes is not a string item\nerror UnexpectedList();\n\n/// @notice The length of the content must be greater than the RLP item length\nerror ContentLengthMismatch();\n\n/// @notice Invalid RLP header for RLP item\nerror InvalidHeader();\n"
      }
    },
    "settings": {
      "remappings": [
        "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
        "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
        "@rari-capital/solmate/=lib/solmate/",
        "@lib-keccak/=lib/lib-keccak/contracts/lib/",
        "@solady/=lib/solady/src/",
        "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/",
        "gelato/=lib/automate/contracts/",
        "@solady-test/=lib/lib-keccak/lib/solady/test/",
        "automate/=lib/automate/contracts/",
        "erc4626-tests/=lib/automate/lib/openzeppelin-contracts/lib/erc4626-tests/",
        "hardhat/=lib/automate/node_modules/hardhat/",
        "lib-keccak/=lib/lib-keccak/contracts/",
        "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
        "openzeppelin-contracts/=lib/openzeppelin-contracts/",
        "prb-test/=lib/automate/lib/prb-test/src/",
        "prb/-est/=lib/automate/lib/prb-test/src/",
        "solady/=lib/solady/",
        "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",
      "viaIR": false,
      "libraries": {}
    }
  }}