creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "contracts/rpc-utils/MulticallV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// solhint-disable-next-line compiler-version\npragma solidity >=0.5.0;\npragma experimental ABIEncoderV2;\n\nimport \"@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol\";\n\n// implementation from https://github.com/makerdao/multicall/blob/1e1b44362640820bef92d0ccf5eeee25d9b41474/src/Multicall2.sol MIT License\n\n/// @title Multicall2 - Aggregate results from multiple read-only function calls\n/// @author Michael Elliot <mike@makerdao.com>\n/// @author Joshua Levine <joshua@makerdao.com>\n/// @author Nick Johnson <arachnid@notdot.net>\n\ncontract Multicall2 {\n    struct Call {\n        address target;\n        bytes callData;\n    }\n    struct Result {\n        bool success;\n        bytes returnData;\n    }\n\n    function aggregate(Call[] memory calls)\n        public\n        returns (uint256 blockNumber, bytes[] memory returnData)\n    {\n        blockNumber = block.number;\n        returnData = new bytes[](calls.length);\n        for (uint256 i = 0; i < calls.length; i++) {\n            (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);\n            require(success, \"Multicall aggregate: call failed\");\n            returnData[i] = ret;\n        }\n    }\n\n    function blockAndAggregate(Call[] memory calls)\n        public\n        returns (\n            uint256 blockNumber,\n            bytes32 blockHash,\n            Result[] memory returnData\n        )\n    {\n        (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls);\n    }\n\n    function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) {\n        blockHash = blockhash(blockNumber);\n    }\n\n    function getBlockNumber() public view returns (uint256 blockNumber) {\n        blockNumber = block.number;\n    }\n\n    function getCurrentBlockCoinbase() public view returns (address coinbase) {\n        coinbase = block.coinbase;\n    }\n\n    function getCurrentBlockDifficulty() public view returns (uint256 difficulty) {\n        difficulty = block.difficulty;\n    }\n\n    function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {\n        gaslimit = block.gaslimit;\n    }\n\n    function getCurrentBlockTimestamp() public view returns (uint256 timestamp) {\n        timestamp = block.timestamp;\n    }\n\n    function getEthBalance(address addr) public view returns (uint256 balance) {\n        balance = addr.balance;\n    }\n\n    function getLastBlockHash() public view returns (bytes32 blockHash) {\n        blockHash = blockhash(block.number - 1);\n    }\n\n    function tryAggregateGasRation(bool requireSuccess, Call[] memory calls)\n        public\n        returns (Result[] memory returnData)\n    {\n        returnData = new Result[](calls.length);\n        uint256 gasPerCall = gasleft() / calls.length;\n        for (uint256 i = 0; i < calls.length; i++) {\n            (bool success, bytes memory ret) = calls[i].target.call{\n                gas: gasleft() > gasPerCall ? gasPerCall : gasleft()\n            }(calls[i].callData);\n\n            if (requireSuccess) {\n                require(success, \"Multicall2 aggregate: call failed\");\n            }\n\n            returnData[i] = Result(success, ret);\n        }\n    }\n\n    function tryAggregate(bool requireSuccess, Call[] memory calls)\n        public\n        returns (Result[] memory returnData)\n    {\n        returnData = new Result[](calls.length);\n        for (uint256 i = 0; i < calls.length; i++) {\n            (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);\n\n            if (requireSuccess) {\n                require(success, \"Multicall2 aggregate: call failed\");\n            }\n\n            returnData[i] = Result(success, ret);\n        }\n    }\n\n    function tryBlockAndAggregate(bool requireSuccess, Call[] memory calls)\n        public\n        returns (\n            uint256 blockNumber,\n            bytes32 blockHash,\n            Result[] memory returnData\n        )\n    {\n        blockNumber = block.number;\n        blockHash = blockhash(block.number);\n        returnData = tryAggregate(requireSuccess, calls);\n    }\n}\n\n/// @title Arbitrum Multicall2 - Multicall2 contracts with L1 and L2 block numbers\ncontract ArbMulticall2 {\n    struct Call {\n        address target;\n        bytes callData;\n    }\n    struct Result {\n        bool success;\n        bytes returnData;\n    }\n\n    function aggregate(Call[] memory calls)\n        public\n        returns (uint256 blockNumber, bytes[] memory returnData)\n    {\n        blockNumber = ArbSys(address(100)).arbBlockNumber();\n        returnData = new bytes[](calls.length);\n        for (uint256 i = 0; i < calls.length; i++) {\n            (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);\n            require(success, \"Multicall aggregate: call failed\");\n            returnData[i] = ret;\n        }\n    }\n\n    function blockAndAggregate(Call[] memory calls)\n        public\n        returns (\n            uint256 blockNumber,\n            bytes32 blockHash,\n            Result[] memory returnData\n        )\n    {\n        (blockNumber, blockHash, returnData) = tryBlockAndAggregate(true, calls);\n    }\n\n    function getBlockHash(uint256 blockNumber) public view returns (bytes32 blockHash) {\n        blockHash = blockhash(blockNumber);\n    }\n\n    function getBlockNumber() public view returns (uint256 blockNumber) {\n        blockNumber = ArbSys(address(100)).arbBlockNumber();\n    }\n\n    function getL1BlockNumber() public view returns (uint256 l1BlockNumber) {\n        l1BlockNumber = block.number;\n    }\n\n    function getCurrentBlockCoinbase() public view returns (address coinbase) {\n        coinbase = block.coinbase;\n    }\n\n    function getCurrentBlockDifficulty() public view returns (uint256 difficulty) {\n        difficulty = block.difficulty;\n    }\n\n    function getCurrentBlockGasLimit() public view returns (uint256 gaslimit) {\n        gaslimit = block.gaslimit;\n    }\n\n    function getCurrentBlockTimestamp() public view returns (uint256 timestamp) {\n        timestamp = block.timestamp;\n    }\n\n    function getEthBalance(address addr) public view returns (uint256 balance) {\n        balance = addr.balance;\n    }\n\n    function getLastBlockHash() public view returns (bytes32 blockHash) {\n        blockHash = blockhash(block.number - 1);\n    }\n\n    function tryAggregateGasRation(bool requireSuccess, Call[] memory calls)\n        public\n        returns (Result[] memory returnData)\n    {\n        returnData = new Result[](calls.length);\n        uint256 gasPerCall = gasleft() / calls.length;\n        for (uint256 i = 0; i < calls.length; i++) {\n            (bool success, bytes memory ret) = calls[i].target.call{\n                gas: gasleft() > gasPerCall ? gasPerCall : gasleft()\n            }(calls[i].callData);\n\n            if (requireSuccess) {\n                require(success, \"Multicall2 aggregate: call failed\");\n            }\n\n            returnData[i] = Result(success, ret);\n        }\n    }\n\n    function tryAggregate(bool requireSuccess, Call[] memory calls)\n        public\n        returns (Result[] memory returnData)\n    {\n        returnData = new Result[](calls.length);\n        for (uint256 i = 0; i < calls.length; i++) {\n            (bool success, bytes memory ret) = calls[i].target.call(calls[i].callData);\n\n            if (requireSuccess) {\n                require(success, \"Multicall2 aggregate: call failed\");\n            }\n\n            returnData[i] = Result(success, ret);\n        }\n    }\n\n    function tryBlockAndAggregate(bool requireSuccess, Call[] memory calls)\n        public\n        returns (\n            uint256 blockNumber,\n            bytes32 blockHash,\n            Result[] memory returnData\n        )\n    {\n        blockNumber = ArbSys(address(100)).arbBlockNumber();\n        blockHash = blockhash(block.number);\n        returnData = tryAggregate(requireSuccess, calls);\n    }\n}\n"
      },
      "node_modules/@arbitrum/nitro-contracts/src/precompiles/ArbSys.sol": {
        "content": "// Copyright 2021-2022, Offchain Labs, Inc.\n// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE\n// SPDX-License-Identifier: BUSL-1.1\n\npragma solidity >=0.4.21 <0.9.0;\n\n/**\n * @title System level functionality\n * @notice For use by contracts to interact with core L2-specific functionality.\n * Precompiled contract that exists in every Arbitrum chain at address(100), 0x0000000000000000000000000000000000000064.\n */\ninterface ArbSys {\n    /**\n     * @notice Get Arbitrum block number (distinct from L1 block number; Arbitrum genesis block has block number 0)\n     * @return block number as int\n     */\n    function arbBlockNumber() external view returns (uint256);\n\n    /**\n     * @notice Get Arbitrum block hash (reverts unless currentBlockNum-256 <= arbBlockNum < currentBlockNum)\n     * @return block hash\n     */\n    function arbBlockHash(uint256 arbBlockNum) external view returns (bytes32);\n\n    /**\n     * @notice Gets the rollup's unique chain identifier\n     * @return Chain identifier as int\n     */\n    function arbChainID() external view returns (uint256);\n\n    /**\n     * @notice Get internal version number identifying an ArbOS build\n     * @return version number as int\n     */\n    function arbOSVersion() external view returns (uint256);\n\n    /**\n     * @notice Returns 0 since Nitro has no concept of storage gas\n     * @return uint 0\n     */\n    function getStorageGasAvailable() external view returns (uint256);\n\n    /**\n     * @notice (deprecated) check if current call is top level (meaning it was triggered by an EoA or a L1 contract)\n     * @dev this call has been deprecated and may be removed in a future release\n     * @return true if current execution frame is not a call by another L2 contract\n     */\n    function isTopLevelCall() external view returns (bool);\n\n    /**\n     * @notice map L1 sender contract address to its L2 alias\n     * @param sender sender address\n     * @param unused argument no longer used\n     * @return aliased sender address\n     */\n    function mapL1SenderContractAddressToL2Alias(address sender, address unused)\n        external\n        pure\n        returns (address);\n\n    /**\n     * @notice check if the caller (of this caller of this) is an aliased L1 contract address\n     * @return true iff the caller's address is an alias for an L1 contract address\n     */\n    function wasMyCallersAddressAliased() external view returns (bool);\n\n    /**\n     * @notice return the address of the caller (of this caller of this), without applying L1 contract address aliasing\n     * @return address of the caller's caller, without applying L1 contract address aliasing\n     */\n    function myCallersAddressWithoutAliasing() external view returns (address);\n\n    /**\n     * @notice Send given amount of Eth to dest from sender.\n     * This is a convenience function, which is equivalent to calling sendTxToL1 with empty data.\n     * @param destination recipient address on L1\n     * @return unique identifier for this L2-to-L1 transaction.\n     */\n    function withdrawEth(address destination) external payable returns (uint256);\n\n    /**\n     * @notice Send a transaction to L1\n     * @dev it is not possible to execute on the L1 any L2-to-L1 transaction which contains data\n     * to a contract address without any code (as enforced by the Bridge contract).\n     * @param destination recipient address on L1\n     * @param data (optional) calldata for L1 contract call\n     * @return a unique identifier for this L2-to-L1 transaction.\n     */\n    function sendTxToL1(address destination, bytes calldata data)\n        external\n        payable\n        returns (uint256);\n\n    /**\n     * @notice Get send Merkle tree state\n     * @return size number of sends in the history\n     * @return root root hash of the send history\n     * @return partials hashes of partial subtrees in the send history tree\n     */\n    function sendMerkleTreeState()\n        external\n        view\n        returns (\n            uint256 size,\n            bytes32 root,\n            bytes32[] memory partials\n        );\n\n    /**\n     * @notice creates a send txn from L2 to L1\n     * @param position = (level << 192) + leaf = (0 << 192) + leaf = leaf\n     */\n    event L2ToL1Tx(\n        address caller,\n        address indexed destination,\n        uint256 indexed hash,\n        uint256 indexed position,\n        uint256 arbBlockNum,\n        uint256 ethBlockNum,\n        uint256 timestamp,\n        uint256 callvalue,\n        bytes data\n    );\n\n    /// @dev DEPRECATED in favour of the new L2ToL1Tx event above after the nitro upgrade\n    event L2ToL1Transaction(\n        address caller,\n        address indexed destination,\n        uint256 indexed uniqueId,\n        uint256 indexed batchNumber,\n        uint256 indexInBatch,\n        uint256 arbBlockNum,\n        uint256 ethBlockNum,\n        uint256 timestamp,\n        uint256 callvalue,\n        bytes data\n    );\n\n    /**\n     * @notice logs a merkle branch for proof synthesis\n     * @param reserved an index meant only to align the 4th index with L2ToL1Transaction's 4th event\n     * @param hash the merkle hash\n     * @param position = (level << 192) + leaf\n     */\n    event SendMerkleUpdate(\n        uint256 indexed reserved,\n        bytes32 indexed hash,\n        uint256 indexed position\n    );\n\n    error InvalidBlockNumber(uint256 requested, uint256 current);\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "forge-std/=lib/forge-std/src/",
        "@openzeppelin/contracts-upgradeable/=node_modules/@openzeppelin/contracts-upgradeable/",
        "@openzeppelin/contracts/=node_modules/@openzeppelin/contracts/",
        "@arbitrum/=node_modules/@arbitrum/",
        "@offchainlabs/=node_modules/@offchainlabs/",
        "@arbitrum/=node_modules/@arbitrum/",
        "@ensdomains/=node_modules/@ensdomains/",
        "@offchainlabs/=node_modules/@offchainlabs/",
        "eth-gas-reporter/=node_modules/eth-gas-reporter/",
        "hardhat-deploy/=node_modules/hardhat-deploy/",
        "hardhat/=node_modules/hardhat/",
        "nitro-contracts/=lib/nitro-contracts/src/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 100
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs"
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "london",
      "viaIR": false,
      "libraries": {}
    }
  }}