creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nimport { IMessageLibManager } from \"./IMessageLibManager.sol\";\nimport { IMessagingComposer } from \"./IMessagingComposer.sol\";\nimport { IMessagingChannel } from \"./IMessagingChannel.sol\";\nimport { IMessagingContext } from \"./IMessagingContext.sol\";\n\nstruct MessagingParams {\n    uint32 dstEid;\n    bytes32 receiver;\n    bytes message;\n    bytes options;\n    bool payInLzToken;\n}\n\nstruct MessagingReceipt {\n    bytes32 guid;\n    uint64 nonce;\n    MessagingFee fee;\n}\n\nstruct MessagingFee {\n    uint256 nativeFee;\n    uint256 lzTokenFee;\n}\n\nstruct Origin {\n    uint32 srcEid;\n    bytes32 sender;\n    uint64 nonce;\n}\n\nenum ExecutionState {\n    NotExecutable,\n    Executable,\n    Executed\n}\n\ninterface ILayerZeroEndpointV2 is IMessageLibManager, IMessagingComposer, IMessagingChannel, IMessagingContext {\n    event PacketSent(bytes encodedPayload, bytes options, address sendLibrary);\n\n    event PacketVerified(Origin origin, address receiver, bytes32 payloadHash);\n\n    event PacketDelivered(Origin origin, address receiver);\n\n    event LzReceiveAlert(\n        address indexed receiver,\n        address indexed executor,\n        Origin origin,\n        bytes32 guid,\n        uint256 gas,\n        uint256 value,\n        bytes message,\n        bytes extraData,\n        bytes reason\n    );\n\n    event LzTokenSet(address token);\n\n    function quote(MessagingParams calldata _params, address _sender) external view returns (MessagingFee memory);\n\n    function send(\n        MessagingParams calldata _params,\n        address _refundAddress\n    ) external payable returns (MessagingReceipt memory);\n\n    function verify(Origin calldata _origin, address _receiver, bytes32 _payloadHash) external;\n\n    function verifiable(\n        Origin calldata _origin,\n        address _receiver,\n        address _receiveLib,\n        bytes32 _payloadHash\n    ) external view returns (bool);\n\n    function executable(Origin calldata _origin, address _receiver) external view returns (ExecutionState);\n\n    function lzReceive(\n        Origin calldata _origin,\n        address _receiver,\n        bytes32 _guid,\n        bytes calldata _message,\n        bytes calldata _extraData\n    ) external payable;\n\n    // oapp can burn messages partially by calling this function with its own business logic if messages are verified in order\n    function clear(address _oapp, Origin calldata _origin, bytes32 _guid, bytes calldata _message) external;\n\n    function setLzToken(address _lzToken) external;\n\n    function lzToken() external view returns (address);\n\n    function nativeToken() external view returns (address);\n\n    function setDelegate(address _delegate) external;\n}\n"
      },
      "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessageLibManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\nstruct SetConfigParam {\n    uint32 eid;\n    uint32 configType;\n    bytes config;\n}\n\ninterface IMessageLibManager {\n    struct Timeout {\n        address lib;\n        uint256 expiry;\n    }\n\n    event LibraryRegistered(address newLib);\n    event DefaultSendLibrarySet(uint32 eid, address newLib);\n    event DefaultReceiveLibrarySet(uint32 eid, address oldLib, address newLib);\n    event DefaultReceiveLibraryTimeoutSet(uint32 eid, address oldLib, uint256 expiry);\n    event SendLibrarySet(address sender, uint32 eid, address newLib);\n    event ReceiveLibrarySet(address receiver, uint32 eid, address oldLib, address newLib);\n    event ReceiveLibraryTimeoutSet(address receiver, uint32 eid, address oldLib, uint256 timeout);\n\n    function registerLibrary(address _lib) external;\n\n    function isRegisteredLibrary(address _lib) external view returns (bool);\n\n    function getRegisteredLibraries() external view returns (address[] memory);\n\n    function setDefaultSendLibrary(uint32 _eid, address _newLib) external;\n\n    function defaultSendLibrary(uint32 _eid) external view returns (address);\n\n    function setDefaultReceiveLibrary(uint32 _eid, address _newLib, uint256 _timeout) external;\n\n    function defaultReceiveLibrary(uint32 _eid) external view returns (address);\n\n    function setDefaultReceiveLibraryTimeout(uint32 _eid, address _lib, uint256 _expiry) external;\n\n    function defaultReceiveLibraryTimeout(uint32 _eid) external view returns (address lib, uint256 expiry);\n\n    function isSupportedEid(uint32 _eid) external view returns (bool);\n\n    /// ------------------- OApp interfaces -------------------\n    function setSendLibrary(address _oapp, uint32 _eid, address _newLib) external;\n\n    function getSendLibrary(address _sender, uint32 _eid) external view returns (address lib);\n\n    function isDefaultSendLibrary(address _sender, uint32 _eid) external view returns (bool);\n\n    function setReceiveLibrary(address _oapp, uint32 _eid, address _newLib, uint256 _gracePeriod) external;\n\n    function getReceiveLibrary(address _receiver, uint32 _eid) external view returns (address lib, bool isDefault);\n\n    function setReceiveLibraryTimeout(address _oapp, uint32 _eid, address _lib, uint256 _gracePeriod) external;\n\n    function receiveLibraryTimeout(address _receiver, uint32 _eid) external view returns (address lib, uint256 expiry);\n\n    function setConfig(address _oapp, address _lib, SetConfigParam[] calldata _params) external;\n\n    function getConfig(\n        address _oapp,\n        address _lib,\n        uint32 _eid,\n        uint32 _configType\n    ) external view returns (bytes memory config);\n}\n"
      },
      "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingChannel.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingChannel {\n    event InboundNonceSkipped(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce);\n    event PacketNilified(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);\n    event PacketBurnt(uint32 srcEid, bytes32 sender, address receiver, uint64 nonce, bytes32 payloadHash);\n\n    function eid() external view returns (uint32);\n\n    // this is an emergency function if a message cannot be verified for some reasons\n    // required to provide _nextNonce to avoid race condition\n    function skip(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce) external;\n\n    function nilify(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;\n\n    function burn(address _oapp, uint32 _srcEid, bytes32 _sender, uint64 _nonce, bytes32 _payloadHash) external;\n\n    function nextGuid(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (bytes32);\n\n    function inboundNonce(address _receiver, uint32 _srcEid, bytes32 _sender) external view returns (uint64);\n\n    function outboundNonce(address _sender, uint32 _dstEid, bytes32 _receiver) external view returns (uint64);\n\n    function inboundPayloadHash(\n        address _receiver,\n        uint32 _srcEid,\n        bytes32 _sender,\n        uint64 _nonce\n    ) external view returns (bytes32);\n}\n"
      },
      "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingComposer.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingComposer {\n    event ComposeSent(address from, address to, bytes32 guid, uint16 index, bytes message);\n    event ComposeDelivered(address from, address to, bytes32 guid, uint16 index);\n    event LzComposeAlert(\n        address indexed from,\n        address indexed to,\n        address indexed executor,\n        bytes32 guid,\n        uint16 index,\n        uint256 gas,\n        uint256 value,\n        bytes message,\n        bytes extraData,\n        bytes reason\n    );\n\n    function composeQueue(\n        address _from,\n        address _to,\n        bytes32 _guid,\n        uint16 _index\n    ) external view returns (bytes32 messageHash);\n\n    function sendCompose(address _to, bytes32 _guid, uint16 _index, bytes calldata _message) external;\n\n    function lzCompose(\n        address _from,\n        address _to,\n        bytes32 _guid,\n        uint16 _index,\n        bytes calldata _message,\n        bytes calldata _extraData\n    ) external payable;\n}\n"
      },
      "@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/IMessagingContext.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.8.0;\n\ninterface IMessagingContext {\n    function isSendingMessage() external view returns (bool);\n\n    function getSendContext() external view returns (uint32 dstEid, address sender);\n}\n"
      },
      "@layerzerolabs/lz-evm-v1-0.7/contracts/interfaces/ILayerZeroEndpoint.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n\npragma solidity >=0.5.0;\n\nimport \"./ILayerZeroUserApplicationConfig.sol\";\n\ninterface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {\n    // @notice send a LayerZero message to the specified address at a LayerZero endpoint.\n    // @param _dstChainId - the destination chain identifier\n    // @param _destination - the address on destination chain (in bytes). address length/format may vary by chains\n    // @param _payload - a custom bytes payload to send to the destination contract\n    // @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address\n    // @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction\n    // @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination\n    function send(\n        uint16 _dstChainId,\n        bytes calldata _destination,\n        bytes calldata _payload,\n        address payable _refundAddress,\n        address _zroPaymentAddress,\n        bytes calldata _adapterParams\n    ) external payable;\n\n    // @notice used by the messaging library to publish verified payload\n    // @param _srcChainId - the source chain identifier\n    // @param _srcAddress - the source contract (as bytes) at the source chain\n    // @param _dstAddress - the address on destination chain\n    // @param _nonce - the unbound message ordering nonce\n    // @param _gasLimit - the gas limit for external contract execution\n    // @param _payload - verified payload to send to the destination contract\n    function receivePayload(\n        uint16 _srcChainId,\n        bytes calldata _srcAddress,\n        address _dstAddress,\n        uint64 _nonce,\n        uint _gasLimit,\n        bytes calldata _payload\n    ) external;\n\n    // @notice get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain\n    // @param _srcChainId - the source chain identifier\n    // @param _srcAddress - the source chain contract address\n    function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);\n\n    // @notice get the outboundNonce from this source chain which, consequently, is always an EVM\n    // @param _srcAddress - the source chain contract address\n    function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);\n\n    // @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery\n    // @param _dstChainId - the destination chain identifier\n    // @param _userApplication - the user app address on this EVM chain\n    // @param _payload - the custom message to send over LayerZero\n    // @param _payInZRO - if false, user app pays the protocol fee in native token\n    // @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain\n    function estimateFees(\n        uint16 _dstChainId,\n        address _userApplication,\n        bytes calldata _payload,\n        bool _payInZRO,\n        bytes calldata _adapterParam\n    ) external view returns (uint nativeFee, uint zroFee);\n\n    // @notice get this Endpoint's immutable source identifier\n    function getChainId() external view returns (uint16);\n\n    // @notice the interface to retry failed message on this Endpoint destination\n    // @param _srcChainId - the source chain identifier\n    // @param _srcAddress - the source chain contract address\n    // @param _payload - the payload to be retried\n    function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;\n\n    // @notice query if any STORED payload (message blocking) at the endpoint.\n    // @param _srcChainId - the source chain identifier\n    // @param _srcAddress - the source chain contract address\n    function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);\n\n    // @notice query if the _libraryAddress is valid for sending msgs.\n    // @param _userApplication - the user app address on this EVM chain\n    function getSendLibraryAddress(address _userApplication) external view returns (address);\n\n    // @notice query if the _libraryAddress is valid for receiving msgs.\n    // @param _userApplication - the user app address on this EVM chain\n    function getReceiveLibraryAddress(address _userApplication) external view returns (address);\n\n    // @notice query if the non-reentrancy guard for send() is on\n    // @return true if the guard is on. false otherwise\n    function isSendingPayload() external view returns (bool);\n\n    // @notice query if the non-reentrancy guard for receive() is on\n    // @return true if the guard is on. false otherwise\n    function isReceivingPayload() external view returns (bool);\n\n    // @notice get the configuration of the LayerZero messaging library of the specified version\n    // @param _version - messaging library version\n    // @param _chainId - the chainId for the pending config change\n    // @param _userApplication - the contract address of the user application\n    // @param _configType - type of configuration. every messaging library has its own convention.\n    function getConfig(\n        uint16 _version,\n        uint16 _chainId,\n        address _userApplication,\n        uint _configType\n    ) external view returns (bytes memory);\n\n    // @notice get the send() LayerZero messaging library version\n    // @param _userApplication - the contract address of the user application\n    function getSendVersion(address _userApplication) external view returns (uint16);\n\n    // @notice get the lzReceive() LayerZero messaging library version\n    // @param _userApplication - the contract address of the user application\n    function getReceiveVersion(address _userApplication) external view returns (uint16);\n}\n"
      },
      "@layerzerolabs/lz-evm-v1-0.7/contracts/interfaces/ILayerZeroUserApplicationConfig.sol": {
        "content": "// SPDX-License-Identifier: BUSL-1.1\n\npragma solidity >=0.5.0;\n\ninterface ILayerZeroUserApplicationConfig {\n    // @notice set the configuration of the LayerZero messaging library of the specified version\n    // @param _version - messaging library version\n    // @param _chainId - the chainId for the pending config change\n    // @param _configType - type of configuration. every messaging library has its own convention.\n    // @param _config - configuration in the bytes. can encode arbitrary content.\n    function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;\n\n    // @notice set the send() LayerZero messaging library version to _version\n    // @param _version - new messaging library version\n    function setSendVersion(uint16 _version) external;\n\n    // @notice set the lzReceive() LayerZero messaging library version to _version\n    // @param _version - new messaging library version\n    function setReceiveVersion(uint16 _version) external;\n\n    // @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload\n    // @param _srcChainId - the chainId of the source chain\n    // @param _srcAddress - the contract address of the source contract at the source chain\n    function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n\n    /**\n     * @dev This empty reserved space is put in place to allow future versions to add new\n     * variables without shifting down storage in the inheritance chain.\n     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps\n     */\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/interfaces/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/introspection/IERC165Upgradeable.sol\";\n"
      },
      "@openzeppelin/contracts-upgradeable/interfaces/IERC4906Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4906.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"./IERC721Upgradeable.sol\";\n\n/// @title EIP-721 Metadata Update Extension\ninterface IERC4906Upgradeable is IERC165Upgradeable, IERC721Upgradeable {\n    /// @dev This event emits when the metadata of a token is changed.\n    /// So that the third-party platforms such as NFT market could\n    /// timely update the images and related attributes of the NFT.\n    event MetadataUpdate(uint256 _tokenId);\n\n    /// @dev This event emits when the metadata of a range of tokens is changed.\n    /// So that the third-party platforms such as NFT market could\n    /// timely update the images and related attributes of the NFTs.\n    event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/interfaces/IERC721Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC721/IERC721Upgradeable.sol\";\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 * ```solidity\n * contract MyToken is ERC20Upgradeable {\n *     function initialize() initializer public {\n *         __ERC20_init(\"MyToken\", \"MTK\");\n *     }\n * }\n *\n * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {\n *     function initializeV2() reinitializer(2) public {\n *         __ERC20Permit_init(\"MyToken\");\n *     }\n * }\n * ```\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke\n * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() {\n *     _disableInitializers();\n * }\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     * @custom:oz-retyped-from bool\n     */\n    uint8 private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Triggered when the contract has been initialized or reinitialized.\n     */\n    event Initialized(uint8 version);\n\n    /**\n     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,\n     * `onlyInitializing` functions can be used to initialize parent contracts.\n     *\n     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a\n     * constructor.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier initializer() {\n        bool isTopLevelCall = !_initializing;\n        require(\n            (isTopLevelCall && _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     * A reinitializer may be used after the original initialization step. This is essential to configure modules that\n     * are added through upgrades and that require initialization.\n     *\n     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`\n     * cannot be nested. If one is invoked in the context of another, execution will revert.\n     *\n     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in\n     * a contract, executing them in the right order is up to the developer or operator.\n     *\n     * WARNING: setting the version to 255 will prevent any future reinitialization.\n     *\n     * Emits an {Initialized} event.\n     */\n    modifier reinitializer(uint8 version) {\n        require(!_initializing && _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     * Emits an {Initialized} event the first time it is successfully executed.\n     */\n    function _disableInitializers() internal virtual {\n        require(!_initializing, \"Initializable: contract is initializing\");\n        if (_initialized != type(uint8).max) {\n            _initialized = type(uint8).max;\n            emit Initialized(type(uint8).max);\n        }\n    }\n\n    /**\n     * @dev Returns the highest version that has been initialized. See {reinitializer}.\n     */\n    function _getInitializedVersion() internal view returns (uint8) {\n        return _initialized;\n    }\n\n    /**\n     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.\n     */\n    function _isInitializing() internal view returns (bool) {\n        return _initializing;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/ERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC20Upgradeable.sol\";\nimport \"./extensions/IERC20MetadataUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../proxy/utils/Initializable.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\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 ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {\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     * All two of these values are immutable: they can only be set once during\n     * construction.\n     */\n    function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {\n        __ERC20_init_unchained(name_, symbol_);\n    }\n\n    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\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 default value returned by this function, unless\n     * it's 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(address from, address to, uint256 amount) 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(address from, address to, uint256 amount) 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            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n            // decrementing then incrementing.\n            _balances[to] += amount;\n        }\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        unchecked {\n            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n            _balances[account] += amount;\n        }\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            // Overflow not possible: amount <= accountBalance <= totalSupply.\n            _totalSupply -= amount;\n        }\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(address owner, address spender, uint256 amount) 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(address owner, address spender, uint256 amount) 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(address from, address to, uint256 amount) 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(address from, address to, uint256 amount) internal virtual {}\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[45] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.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 \"../IERC20Upgradeable.sol\";\n\n/**\n * @dev Interface for the optional metadata functions from the ERC20 standard.\n *\n * _Available since v4.1._\n */\ninterface IERC20MetadataUpgradeable is IERC20Upgradeable {\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"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 IERC20Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721Upgradeable.sol\";\nimport \"./IERC721ReceiverUpgradeable.sol\";\nimport \"./extensions/IERC721MetadataUpgradeable.sol\";\nimport \"../../utils/AddressUpgradeable.sol\";\nimport \"../../utils/ContextUpgradeable.sol\";\nimport \"../../utils/StringsUpgradeable.sol\";\nimport \"../../utils/introspection/ERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {\n    using AddressUpgradeable for address;\n    using StringsUpgradeable for uint256;\n\n    // Token name\n    string private _name;\n\n    // Token symbol\n    string private _symbol;\n\n    // Mapping from token ID to owner address\n    mapping(uint256 => address) private _owners;\n\n    // Mapping owner address to token count\n    mapping(address => uint256) private _balances;\n\n    // Mapping from token ID to approved address\n    mapping(uint256 => address) private _tokenApprovals;\n\n    // Mapping from owner to operator approvals\n    mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n    /**\n     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n     */\n    function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {\n        __ERC721_init_unchained(name_, symbol_);\n    }\n\n    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {\n        return\n            interfaceId == type(IERC721Upgradeable).interfaceId ||\n            interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721-balanceOf}.\n     */\n    function balanceOf(address owner) public view virtual override returns (uint256) {\n        require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n        return _balances[owner];\n    }\n\n    /**\n     * @dev See {IERC721-ownerOf}.\n     */\n    function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n        address owner = _ownerOf(tokenId);\n        require(owner != address(0), \"ERC721: invalid token ID\");\n        return owner;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-name}.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-symbol}.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-tokenURI}.\n     */\n    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n        _requireMinted(tokenId);\n\n        string memory baseURI = _baseURI();\n        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n    }\n\n    /**\n     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n     * by default, can be overridden in child contracts.\n     */\n    function _baseURI() internal view virtual returns (string memory) {\n        return \"\";\n    }\n\n    /**\n     * @dev See {IERC721-approve}.\n     */\n    function approve(address to, uint256 tokenId) public virtual override {\n        address owner = ERC721Upgradeable.ownerOf(tokenId);\n        require(to != owner, \"ERC721: approval to current owner\");\n\n        require(\n            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n            \"ERC721: approve caller is not token owner or approved for all\"\n        );\n\n        _approve(to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-getApproved}.\n     */\n    function getApproved(uint256 tokenId) public view virtual override returns (address) {\n        _requireMinted(tokenId);\n\n        return _tokenApprovals[tokenId];\n    }\n\n    /**\n     * @dev See {IERC721-setApprovalForAll}.\n     */\n    function setApprovalForAll(address operator, bool approved) public virtual override {\n        _setApprovalForAll(_msgSender(), operator, approved);\n    }\n\n    /**\n     * @dev See {IERC721-isApprovedForAll}.\n     */\n    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n        return _operatorApprovals[owner][operator];\n    }\n\n    /**\n     * @dev See {IERC721-transferFrom}.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n        //solhint-disable-next-line max-line-length\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n        _transfer(from, to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n        safeTransferFrom(from, to, tokenId, \"\");\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n        _safeTransfer(from, to, tokenId, data);\n    }\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * `data` is additional data, it has no specified format and it is sent in call to `to`.\n     *\n     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n     * implement alternative mechanisms to perform token transfer, such as signature-based.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n        _transfer(from, to, tokenId);\n        require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n    }\n\n    /**\n     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n     */\n    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n        return _owners[tokenId];\n    }\n\n    /**\n     * @dev Returns whether `tokenId` exists.\n     *\n     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n     *\n     * Tokens start existing when they are minted (`_mint`),\n     * and stop existing when they are burned (`_burn`).\n     */\n    function _exists(uint256 tokenId) internal view virtual returns (bool) {\n        return _ownerOf(tokenId) != address(0);\n    }\n\n    /**\n     * @dev Returns whether `spender` is allowed to manage `tokenId`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n        address owner = ERC721Upgradeable.ownerOf(tokenId);\n        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n    }\n\n    /**\n     * @dev Safely mints `tokenId` and transfers it to `to`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeMint(address to, uint256 tokenId) internal virtual {\n        _safeMint(to, tokenId, \"\");\n    }\n\n    /**\n     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n     */\n    function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n        _mint(to, tokenId);\n        require(\n            _checkOnERC721Received(address(0), to, tokenId, data),\n            \"ERC721: transfer to non ERC721Receiver implementer\"\n        );\n    }\n\n    /**\n     * @dev Mints `tokenId` and transfers it to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - `to` cannot be the zero address.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _mint(address to, uint256 tokenId) internal virtual {\n        require(to != address(0), \"ERC721: mint to the zero address\");\n        require(!_exists(tokenId), \"ERC721: token already minted\");\n\n        _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n        // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n        require(!_exists(tokenId), \"ERC721: token already minted\");\n\n        unchecked {\n            // Will not overflow unless all 2**256 token ids are minted to the same owner.\n            // Given that tokens are minted one by one, it is impossible in practice that\n            // this ever happens. Might change if we allow batch minting.\n            // The ERC fails to describe this case.\n            _balances[to] += 1;\n        }\n\n        _owners[tokenId] = to;\n\n        emit Transfer(address(0), to, tokenId);\n\n        _afterTokenTransfer(address(0), to, tokenId, 1);\n    }\n\n    /**\n     * @dev Destroys `tokenId`.\n     * The approval is cleared when the token is burned.\n     * This is an internal function that does not check if the sender is authorized to operate on the token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _burn(uint256 tokenId) internal virtual {\n        address owner = ERC721Upgradeable.ownerOf(tokenId);\n\n        _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n        owner = ERC721Upgradeable.ownerOf(tokenId);\n\n        // Clear approvals\n        delete _tokenApprovals[tokenId];\n\n        unchecked {\n            // Cannot overflow, as that would require more tokens to be burned/transferred\n            // out than the owner initially received through minting and transferring in.\n            _balances[owner] -= 1;\n        }\n        delete _owners[tokenId];\n\n        emit Transfer(owner, address(0), tokenId);\n\n        _afterTokenTransfer(owner, address(0), tokenId, 1);\n    }\n\n    /**\n     * @dev Transfers `tokenId` from `from` to `to`.\n     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _transfer(address from, address to, uint256 tokenId) internal virtual {\n        require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n        require(to != address(0), \"ERC721: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, tokenId, 1);\n\n        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n        require(ERC721Upgradeable.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n        // Clear approvals from the previous owner\n        delete _tokenApprovals[tokenId];\n\n        unchecked {\n            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n            // `from`'s balance is the number of token held, which is at least one before the current\n            // transfer.\n            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n            // all 2**256 token ids to be minted, which in practice is impossible.\n            _balances[from] -= 1;\n            _balances[to] += 1;\n        }\n        _owners[tokenId] = to;\n\n        emit Transfer(from, to, tokenId);\n\n        _afterTokenTransfer(from, to, tokenId, 1);\n    }\n\n    /**\n     * @dev Approve `to` to operate on `tokenId`\n     *\n     * Emits an {Approval} event.\n     */\n    function _approve(address to, uint256 tokenId) internal virtual {\n        _tokenApprovals[tokenId] = to;\n        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);\n    }\n\n    /**\n     * @dev Approve `operator` to operate on all of `owner` tokens\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n        require(owner != operator, \"ERC721: approve to caller\");\n        _operatorApprovals[owner][operator] = approved;\n        emit ApprovalForAll(owner, operator, approved);\n    }\n\n    /**\n     * @dev Reverts if the `tokenId` has not been minted yet.\n     */\n    function _requireMinted(uint256 tokenId) internal view virtual {\n        require(_exists(tokenId), \"ERC721: invalid token ID\");\n    }\n\n    /**\n     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n     * The call is not executed if the target address is not a contract.\n     *\n     * @param from address representing the previous owner of the given token ID\n     * @param to target address that will receive the tokens\n     * @param tokenId uint256 ID of the token to be transferred\n     * @param data bytes optional data to send along with the call\n     * @return bool whether the call correctly returned the expected magic value\n     */\n    function _checkOnERC721Received(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory data\n    ) private returns (bool) {\n        if (to.isContract()) {\n            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n                return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;\n            } catch (bytes memory reason) {\n                if (reason.length == 0) {\n                    revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n                } else {\n                    /// @solidity memory-safe-assembly\n                    assembly {\n                        revert(add(32, reason), mload(reason))\n                    }\n                }\n            }\n        } else {\n            return true;\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n     *\n     * Calling conditions:\n     *\n     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n     * - When `from` is zero, the tokens will be minted for `to`.\n     * - When `to` is zero, ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     * - `batchSize` is non-zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n     *\n     * Calling conditions:\n     *\n     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n     * - When `from` is zero, the tokens were minted for `to`.\n     * - When `to` is zero, ``from``'s tokens were burned.\n     * - `from` and `to` are never both zero.\n     * - `batchSize` is non-zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n    /**\n     * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n     *\n     * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\n     * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\n     * that `ownerOf(tokenId)` is `a`.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function __unsafe_increaseBalance(address account, uint256 amount) internal {\n        _balances[account] += amount;\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[44] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721Upgradeable.sol\";\nimport \"./IERC721EnumerableUpgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev This implements an optional extension of {ERC721} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {\n    function __ERC721Enumerable_init() internal onlyInitializing {\n    }\n\n    function __ERC721Enumerable_init_unchained() internal onlyInitializing {\n    }\n    // Mapping from owner to list of owned token IDs\n    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n    // Mapping from token ID to index of the owner tokens list\n    mapping(uint256 => uint256) private _ownedTokensIndex;\n\n    // Array with all token ids, used for enumeration\n    uint256[] private _allTokens;\n\n    // Mapping from token id to position in the allTokens array\n    mapping(uint256 => uint256) private _allTokensIndex;\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) {\n        return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n        require(index < ERC721Upgradeable.balanceOf(owner), \"ERC721Enumerable: owner index out of bounds\");\n        return _ownedTokens[owner][index];\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _allTokens.length;\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-tokenByIndex}.\n     */\n    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n        require(index < ERC721EnumerableUpgradeable.totalSupply(), \"ERC721Enumerable: global index out of bounds\");\n        return _allTokens[index];\n    }\n\n    /**\n     * @dev See {ERC721-_beforeTokenTransfer}.\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 firstTokenId,\n        uint256 batchSize\n    ) internal virtual override {\n        super._beforeTokenTransfer(from, to, firstTokenId, batchSize);\n\n        if (batchSize > 1) {\n            // Will only trigger during construction. Batch transferring (minting) is not available afterwards.\n            revert(\"ERC721Enumerable: consecutive transfers not supported\");\n        }\n\n        uint256 tokenId = firstTokenId;\n\n        if (from == address(0)) {\n            _addTokenToAllTokensEnumeration(tokenId);\n        } else if (from != to) {\n            _removeTokenFromOwnerEnumeration(from, tokenId);\n        }\n        if (to == address(0)) {\n            _removeTokenFromAllTokensEnumeration(tokenId);\n        } else if (to != from) {\n            _addTokenToOwnerEnumeration(to, tokenId);\n        }\n    }\n\n    /**\n     * @dev Private function to add a token to this extension's ownership-tracking data structures.\n     * @param to address representing the new owner of the given token ID\n     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n     */\n    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n        uint256 length = ERC721Upgradeable.balanceOf(to);\n        _ownedTokens[to][length] = tokenId;\n        _ownedTokensIndex[tokenId] = length;\n    }\n\n    /**\n     * @dev Private function to add a token to this extension's token tracking data structures.\n     * @param tokenId uint256 ID of the token to be added to the tokens list\n     */\n    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n        _allTokensIndex[tokenId] = _allTokens.length;\n        _allTokens.push(tokenId);\n    }\n\n    /**\n     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n     * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n     * @param from address representing the previous owner of the given token ID\n     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n     */\n    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n        // then delete the last slot (swap and pop).\n\n        uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1;\n        uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n        // When the token to delete is the last token, the swap operation is unnecessary\n        if (tokenIndex != lastTokenIndex) {\n            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n        }\n\n        // This also deletes the contents at the last position of the array\n        delete _ownedTokensIndex[tokenId];\n        delete _ownedTokens[from][lastTokenIndex];\n    }\n\n    /**\n     * @dev Private function to remove a token from this extension's token tracking data structures.\n     * This has O(1) time complexity, but alters the order of the _allTokens array.\n     * @param tokenId uint256 ID of the token to be removed from the tokens list\n     */\n    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n        // then delete the last slot (swap and pop).\n\n        uint256 lastTokenIndex = _allTokens.length - 1;\n        uint256 tokenIndex = _allTokensIndex[tokenId];\n\n        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n        uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n        // This also deletes the contents at the last position of the array\n        delete _allTokensIndex[tokenId];\n        _allTokens.pop();\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[46] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/extensions/ERC721URIStorage.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721Upgradeable.sol\";\nimport \"../../../interfaces/IERC4906Upgradeable.sol\";\nimport \"../../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev ERC721 token with storage based token URI management.\n */\nabstract contract ERC721URIStorageUpgradeable is Initializable, IERC4906Upgradeable, ERC721Upgradeable {\n    function __ERC721URIStorage_init() internal onlyInitializing {\n    }\n\n    function __ERC721URIStorage_init_unchained() internal onlyInitializing {\n    }\n    using StringsUpgradeable for uint256;\n\n    // Optional mapping for token URIs\n    mapping(uint256 => string) private _tokenURIs;\n\n    /**\n     * @dev See {IERC165-supportsInterface}\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC721Upgradeable, IERC165Upgradeable) returns (bool) {\n        return interfaceId == bytes4(0x49064906) || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721Metadata-tokenURI}.\n     */\n    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n        _requireMinted(tokenId);\n\n        string memory _tokenURI = _tokenURIs[tokenId];\n        string memory base = _baseURI();\n\n        // If there is no base URI, return the token URI.\n        if (bytes(base).length == 0) {\n            return _tokenURI;\n        }\n        // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).\n        if (bytes(_tokenURI).length > 0) {\n            return string(abi.encodePacked(base, _tokenURI));\n        }\n\n        return super.tokenURI(tokenId);\n    }\n\n    /**\n     * @dev Sets `_tokenURI` as the tokenURI of `tokenId`.\n     *\n     * Emits {MetadataUpdate}.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {\n        require(_exists(tokenId), \"ERC721URIStorage: URI set of nonexistent token\");\n        _tokenURIs[tokenId] = _tokenURI;\n\n        emit MetadataUpdate(tokenId);\n    }\n\n    /**\n     * @dev See {ERC721-_burn}. This override additionally checks to see if a\n     * token-specific URI was set for the token, and if so, it deletes the token URI from\n     * the storage mapping.\n     */\n    function _burn(uint256 tokenId) internal virtual override {\n        super._burn(tokenId);\n\n        if (bytes(_tokenURIs[tokenId]).length != 0) {\n            delete _tokenURIs[tokenId];\n        }\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"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721EnumerableUpgradeable is IERC721Upgradeable {\n    /**\n     * @dev Returns the total amount of tokens stored by the contract.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n     * Use along with {totalSupply} to enumerate all tokens.\n     */\n    function tokenByIndex(uint256 index) external view returns (uint256);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721Upgradeable.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721MetadataUpgradeable is IERC721Upgradeable {\n    /**\n     * @dev Returns the token collection name.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the token collection symbol.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n     */\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721ReceiverUpgradeable {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 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"
      },
      "@openzeppelin/contracts-upgradeable/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"
      },
      "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165Upgradeable.sol\";\nimport \"../../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {\n    function __ERC165_init() internal onlyInitializing {\n    }\n\n    function __ERC165_init_unchained() internal onlyInitializing {\n    }\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165Upgradeable).interfaceId;\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"
      },
      "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165Upgradeable {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 MathUpgradeable {\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(uint256 x, uint256 y, uint256 denominator) 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                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\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(uint256 x, uint256 y, uint256 denominator, Rounding rounding) 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. If 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        //\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)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\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        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/math/SignedMathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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 SignedMathUpgradeable {\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"
      },
      "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/MathUpgradeable.sol\";\nimport \"./math/SignedMathUpgradeable.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary StringsUpgradeable {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = MathUpgradeable.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMathUpgradeable.abs(value))));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, MathUpgradeable.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "@openzeppelin/contracts/access/AccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/AccessControl.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IAccessControl.sol\";\nimport \"../utils/Context.sol\";\nimport \"../utils/Strings.sol\";\nimport \"../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Contract module that allows children to implement role-based access\n * control mechanisms. This is a lightweight version that doesn't allow enumerating role\n * members except through off-chain means by accessing the contract event logs. Some\n * applications may benefit from on-chain enumerability, for those cases see\n * {AccessControlEnumerable}.\n *\n * Roles are referred to by their `bytes32` identifier. These should be exposed\n * in the external API and be unique. The best way to achieve this is by\n * using `public constant` hash digests:\n *\n * ```solidity\n * bytes32 public constant MY_ROLE = keccak256(\"MY_ROLE\");\n * ```\n *\n * Roles can be used to represent a set of permissions. To restrict access to a\n * function call, use {hasRole}:\n *\n * ```solidity\n * function foo() public {\n *     require(hasRole(MY_ROLE, msg.sender));\n *     ...\n * }\n * ```\n *\n * Roles can be granted and revoked dynamically via the {grantRole} and\n * {revokeRole} functions. Each role has an associated admin role, and only\n * accounts that have a role's admin role can call {grantRole} and {revokeRole}.\n *\n * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means\n * that only accounts with this role will be able to grant or revoke other\n * roles. More complex role relationships can be created by using\n * {_setRoleAdmin}.\n *\n * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to\n * grant and revoke this role. Extra precautions should be taken to secure\n * accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}\n * to enforce additional security measures for this role.\n */\nabstract contract AccessControl is Context, IAccessControl, ERC165 {\n    struct RoleData {\n        mapping(address => bool) members;\n        bytes32 adminRole;\n    }\n\n    mapping(bytes32 => RoleData) private _roles;\n\n    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;\n\n    /**\n     * @dev Modifier that checks that an account has a specific role. Reverts\n     * with a standardized message including the required role.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     *\n     * _Available since v4.1._\n     */\n    modifier onlyRole(bytes32 role) {\n        _checkRole(role);\n        _;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {\n        return _roles[role].members[account];\n    }\n\n    /**\n     * @dev Revert with a standard message if `_msgSender()` is missing `role`.\n     * Overriding this function changes the behavior of the {onlyRole} modifier.\n     *\n     * Format of the revert message is described in {_checkRole}.\n     *\n     * _Available since v4.6._\n     */\n    function _checkRole(bytes32 role) internal view virtual {\n        _checkRole(role, _msgSender());\n    }\n\n    /**\n     * @dev Revert with a standard message if `account` is missing `role`.\n     *\n     * The format of the revert reason is given by the following regular expression:\n     *\n     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/\n     */\n    function _checkRole(bytes32 role, address account) internal view virtual {\n        if (!hasRole(role, account)) {\n            revert(\n                string(\n                    abi.encodePacked(\n                        \"AccessControl: account \",\n                        Strings.toHexString(account),\n                        \" is missing role \",\n                        Strings.toHexString(uint256(role), 32)\n                    )\n                )\n            );\n        }\n    }\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {\n        return _roles[role].adminRole;\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been revoked `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function renounceRole(bytes32 role, address account) public virtual override {\n        require(account == _msgSender(), \"AccessControl: can only renounce roles for self\");\n\n        _revokeRole(role, account);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event. Note that unlike {grantRole}, this function doesn't perform any\n     * checks on the calling account.\n     *\n     * May emit a {RoleGranted} event.\n     *\n     * [WARNING]\n     * ====\n     * This function should only be called from the constructor when setting\n     * up the initial roles for the system.\n     *\n     * Using this function in any other way is effectively circumventing the admin\n     * system imposed by {AccessControl}.\n     * ====\n     *\n     * NOTE: This function is deprecated in favor of {_grantRole}.\n     */\n    function _setupRole(bytes32 role, address account) internal virtual {\n        _grantRole(role, account);\n    }\n\n    /**\n     * @dev Sets `adminRole` as ``role``'s admin role.\n     *\n     * Emits a {RoleAdminChanged} event.\n     */\n    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {\n        bytes32 previousAdminRole = getRoleAdmin(role);\n        _roles[role].adminRole = adminRole;\n        emit RoleAdminChanged(role, previousAdminRole, adminRole);\n    }\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleGranted} event.\n     */\n    function _grantRole(bytes32 role, address account) internal virtual {\n        if (!hasRole(role, account)) {\n            _roles[role].members[account] = true;\n            emit RoleGranted(role, account, _msgSender());\n        }\n    }\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * Internal function without access restriction.\n     *\n     * May emit a {RoleRevoked} event.\n     */\n    function _revokeRole(bytes32 role, address account) internal virtual {\n        if (hasRole(role, account)) {\n            _roles[role].members[account] = false;\n            emit RoleRevoked(role, account, _msgSender());\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/access/IAccessControl.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev External interface of AccessControl declared to support ERC165 detection.\n */\ninterface IAccessControl {\n    /**\n     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`\n     *\n     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite\n     * {RoleAdminChanged} not being emitted signaling this.\n     *\n     * _Available since v3.1._\n     */\n    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);\n\n    /**\n     * @dev Emitted when `account` is granted `role`.\n     *\n     * `sender` is the account that originated the contract call, an admin role\n     * bearer except when using {AccessControl-_setupRole}.\n     */\n    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Emitted when `account` is revoked `role`.\n     *\n     * `sender` is the account that originated the contract call:\n     *   - if using `revokeRole`, it is the admin role bearer\n     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)\n     */\n    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);\n\n    /**\n     * @dev Returns `true` if `account` has been granted `role`.\n     */\n    function hasRole(bytes32 role, address account) external view returns (bool);\n\n    /**\n     * @dev Returns the admin role that controls `role`. See {grantRole} and\n     * {revokeRole}.\n     *\n     * To change a role's admin, use {AccessControl-_setRoleAdmin}.\n     */\n    function getRoleAdmin(bytes32 role) external view returns (bytes32);\n\n    /**\n     * @dev Grants `role` to `account`.\n     *\n     * If `account` had not been already granted `role`, emits a {RoleGranted}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function grantRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from `account`.\n     *\n     * If `account` had been granted `role`, emits a {RoleRevoked} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have ``role``'s admin role.\n     */\n    function revokeRole(bytes32 role, address account) external;\n\n    /**\n     * @dev Revokes `role` from the calling account.\n     *\n     * Roles are often managed via {grantRole} and {revokeRole}: this function's\n     * purpose is to provide a mechanism for accounts to lose their privileges\n     * if they are compromised (such as when a trusted device is misplaced).\n     *\n     * If the calling account had been granted `role`, emits a {RoleRevoked}\n     * event.\n     *\n     * Requirements:\n     *\n     * - the caller must be `account`.\n     */\n    function renounceRole(bytes32 role, address account) external;\n}\n"
      },
      "@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.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 Ownable is Context {\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    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
      },
      "@openzeppelin/contracts/crosschain/CrossChainEnabled.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (crosschain/CrossChainEnabled.sol)\n\npragma solidity ^0.8.4;\n\nimport \"./errors.sol\";\n\n/**\n * @dev Provides information for building cross-chain aware contracts. This\n * abstract contract provides accessors and modifiers to control the execution\n * flow when receiving cross-chain messages.\n *\n * Actual implementations of cross-chain aware contracts, which are based on\n * this abstraction, will  have to inherit from a bridge-specific\n * specialization. Such specializations are provided under\n * `crosschain/<chain>/CrossChainEnabled<chain>.sol`.\n *\n * _Available since v4.6._\n */\nabstract contract CrossChainEnabled {\n    /**\n     * @dev Throws if the current function call is not the result of a\n     * cross-chain execution.\n     */\n    modifier onlyCrossChain() {\n        if (!_isCrossChain()) revert NotCrossChainCall();\n        _;\n    }\n\n    /**\n     * @dev Throws if the current function call is not the result of a\n     * cross-chain execution initiated by `account`.\n     */\n    modifier onlyCrossChainSender(address expected) {\n        address actual = _crossChainSender();\n        if (expected != actual) revert InvalidCrossChainSender(actual, expected);\n        _;\n    }\n\n    /**\n     * @dev Returns whether the current function call is the result of a\n     * cross-chain message.\n     */\n    function _isCrossChain() internal view virtual returns (bool);\n\n    /**\n     * @dev Returns the address of the sender of the cross-chain message that\n     * triggered the current function call.\n     *\n     * IMPORTANT: Should revert with `NotCrossChainCall` if the current function\n     * call is not the result of a cross-chain message.\n     */\n    function _crossChainSender() internal view virtual returns (address);\n}\n"
      },
      "@openzeppelin/contracts/crosschain/errors.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (crosschain/errors.sol)\n\npragma solidity ^0.8.4;\n\nerror NotCrossChainCall();\nerror InvalidCrossChainSender(address actual, address expected);\n"
      },
      "@openzeppelin/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (crosschain/optimism/CrossChainEnabledOptimism.sol)\n\npragma solidity ^0.8.4;\n\nimport \"../CrossChainEnabled.sol\";\nimport \"./LibOptimism.sol\";\n\n/**\n * @dev https://www.optimism.io/[Optimism] specialization or the\n * {CrossChainEnabled} abstraction.\n *\n * The messenger (`CrossDomainMessenger`) contract is provided and maintained by\n * the optimism team. You can find the address of this contract on mainnet and\n * kovan in the https://github.com/ethereum-optimism/optimism/tree/develop/packages/contracts/deployments[deployments section of Optimism monorepo].\n *\n * _Available since v4.6._\n */\nabstract contract CrossChainEnabledOptimism is CrossChainEnabled {\n    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable\n    address private immutable _messenger;\n\n    /// @custom:oz-upgrades-unsafe-allow constructor\n    constructor(address messenger) {\n        _messenger = messenger;\n    }\n\n    /**\n     * @dev see {CrossChainEnabled-_isCrossChain}\n     */\n    function _isCrossChain() internal view virtual override returns (bool) {\n        return LibOptimism.isCrossChain(_messenger);\n    }\n\n    /**\n     * @dev see {CrossChainEnabled-_crossChainSender}\n     */\n    function _crossChainSender() internal view virtual override onlyCrossChain returns (address) {\n        return LibOptimism.crossChainSender(_messenger);\n    }\n}\n"
      },
      "@openzeppelin/contracts/crosschain/optimism/LibOptimism.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (crosschain/optimism/LibOptimism.sol)\n\npragma solidity ^0.8.4;\n\nimport {ICrossDomainMessenger as Optimism_Bridge} from \"../../vendor/optimism/ICrossDomainMessenger.sol\";\nimport \"../errors.sol\";\n\n/**\n * @dev Primitives for cross-chain aware contracts for https://www.optimism.io/[Optimism].\n * See the https://community.optimism.io/docs/developers/bridge/messaging/#accessing-msg-sender[documentation]\n * for the functionality used here.\n */\nlibrary LibOptimism {\n    /**\n     * @dev Returns whether the current function call is the result of a\n     * cross-chain message relayed by `messenger`.\n     */\n    function isCrossChain(address messenger) internal view returns (bool) {\n        return msg.sender == messenger;\n    }\n\n    /**\n     * @dev Returns the address of the sender that triggered the current\n     * cross-chain message through `messenger`.\n     *\n     * NOTE: {isCrossChain} should be checked before trying to recover the\n     * sender, as it will revert with `NotCrossChainCall` if the current\n     * function call is not the result of a cross-chain message.\n     */\n    function crossChainSender(address messenger) internal view returns (address) {\n        if (!isCrossChain(messenger)) revert NotCrossChainCall();\n\n        return Optimism_Bridge(messenger).xDomainMessageSender();\n    }\n}\n"
      },
      "@openzeppelin/contracts/governance/TimelockController.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (governance/TimelockController.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../access/AccessControl.sol\";\nimport \"../token/ERC721/IERC721Receiver.sol\";\nimport \"../token/ERC1155/IERC1155Receiver.sol\";\n\n/**\n * @dev Contract module which acts as a timelocked controller. When set as the\n * owner of an `Ownable` smart contract, it enforces a timelock on all\n * `onlyOwner` maintenance operations. This gives time for users of the\n * controlled contract to exit before a potentially dangerous maintenance\n * operation is applied.\n *\n * By default, this contract is self administered, meaning administration tasks\n * have to go through the timelock process. The proposer (resp executor) role\n * is in charge of proposing (resp executing) operations. A common use case is\n * to position this {TimelockController} as the owner of a smart contract, with\n * a multisig or a DAO as the sole proposer.\n *\n * _Available since v3.3._\n */\ncontract TimelockController is AccessControl, IERC721Receiver, IERC1155Receiver {\n    bytes32 public constant TIMELOCK_ADMIN_ROLE = keccak256(\"TIMELOCK_ADMIN_ROLE\");\n    bytes32 public constant PROPOSER_ROLE = keccak256(\"PROPOSER_ROLE\");\n    bytes32 public constant EXECUTOR_ROLE = keccak256(\"EXECUTOR_ROLE\");\n    bytes32 public constant CANCELLER_ROLE = keccak256(\"CANCELLER_ROLE\");\n    uint256 internal constant _DONE_TIMESTAMP = uint256(1);\n\n    mapping(bytes32 => uint256) private _timestamps;\n    uint256 private _minDelay;\n\n    /**\n     * @dev Emitted when a call is scheduled as part of operation `id`.\n     */\n    event CallScheduled(\n        bytes32 indexed id,\n        uint256 indexed index,\n        address target,\n        uint256 value,\n        bytes data,\n        bytes32 predecessor,\n        uint256 delay\n    );\n\n    /**\n     * @dev Emitted when a call is performed as part of operation `id`.\n     */\n    event CallExecuted(bytes32 indexed id, uint256 indexed index, address target, uint256 value, bytes data);\n\n    /**\n     * @dev Emitted when new proposal is scheduled with non-zero salt.\n     */\n    event CallSalt(bytes32 indexed id, bytes32 salt);\n\n    /**\n     * @dev Emitted when operation `id` is cancelled.\n     */\n    event Cancelled(bytes32 indexed id);\n\n    /**\n     * @dev Emitted when the minimum delay for future operations is modified.\n     */\n    event MinDelayChange(uint256 oldDuration, uint256 newDuration);\n\n    /**\n     * @dev Initializes the contract with the following parameters:\n     *\n     * - `minDelay`: initial minimum delay for operations\n     * - `proposers`: accounts to be granted proposer and canceller roles\n     * - `executors`: accounts to be granted executor role\n     * - `admin`: optional account to be granted admin role; disable with zero address\n     *\n     * IMPORTANT: The optional admin can aid with initial configuration of roles after deployment\n     * without being subject to delay, but this role should be subsequently renounced in favor of\n     * administration through timelocked proposals. Previous versions of this contract would assign\n     * this admin to the deployer automatically and should be renounced as well.\n     */\n    constructor(uint256 minDelay, address[] memory proposers, address[] memory executors, address admin) {\n        _setRoleAdmin(TIMELOCK_ADMIN_ROLE, TIMELOCK_ADMIN_ROLE);\n        _setRoleAdmin(PROPOSER_ROLE, TIMELOCK_ADMIN_ROLE);\n        _setRoleAdmin(EXECUTOR_ROLE, TIMELOCK_ADMIN_ROLE);\n        _setRoleAdmin(CANCELLER_ROLE, TIMELOCK_ADMIN_ROLE);\n\n        // self administration\n        _setupRole(TIMELOCK_ADMIN_ROLE, address(this));\n\n        // optional admin\n        if (admin != address(0)) {\n            _setupRole(TIMELOCK_ADMIN_ROLE, admin);\n        }\n\n        // register proposers and cancellers\n        for (uint256 i = 0; i < proposers.length; ++i) {\n            _setupRole(PROPOSER_ROLE, proposers[i]);\n            _setupRole(CANCELLER_ROLE, proposers[i]);\n        }\n\n        // register executors\n        for (uint256 i = 0; i < executors.length; ++i) {\n            _setupRole(EXECUTOR_ROLE, executors[i]);\n        }\n\n        _minDelay = minDelay;\n        emit MinDelayChange(0, minDelay);\n    }\n\n    /**\n     * @dev Modifier to make a function callable only by a certain role. In\n     * addition to checking the sender's role, `address(0)` 's role is also\n     * considered. Granting a role to `address(0)` is equivalent to enabling\n     * this role for everyone.\n     */\n    modifier onlyRoleOrOpenRole(bytes32 role) {\n        if (!hasRole(role, address(0))) {\n            _checkRole(role, _msgSender());\n        }\n        _;\n    }\n\n    /**\n     * @dev Contract might receive/hold ETH as part of the maintenance process.\n     */\n    receive() external payable {}\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, AccessControl) returns (bool) {\n        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev Returns whether an id correspond to a registered operation. This\n     * includes both Pending, Ready and Done operations.\n     */\n    function isOperation(bytes32 id) public view virtual returns (bool) {\n        return getTimestamp(id) > 0;\n    }\n\n    /**\n     * @dev Returns whether an operation is pending or not. Note that a \"pending\" operation may also be \"ready\".\n     */\n    function isOperationPending(bytes32 id) public view virtual returns (bool) {\n        return getTimestamp(id) > _DONE_TIMESTAMP;\n    }\n\n    /**\n     * @dev Returns whether an operation is ready for execution. Note that a \"ready\" operation is also \"pending\".\n     */\n    function isOperationReady(bytes32 id) public view virtual returns (bool) {\n        uint256 timestamp = getTimestamp(id);\n        return timestamp > _DONE_TIMESTAMP && timestamp <= block.timestamp;\n    }\n\n    /**\n     * @dev Returns whether an operation is done or not.\n     */\n    function isOperationDone(bytes32 id) public view virtual returns (bool) {\n        return getTimestamp(id) == _DONE_TIMESTAMP;\n    }\n\n    /**\n     * @dev Returns the timestamp at which an operation becomes ready (0 for\n     * unset operations, 1 for done operations).\n     */\n    function getTimestamp(bytes32 id) public view virtual returns (uint256) {\n        return _timestamps[id];\n    }\n\n    /**\n     * @dev Returns the minimum delay for an operation to become valid.\n     *\n     * This value can be changed by executing an operation that calls `updateDelay`.\n     */\n    function getMinDelay() public view virtual returns (uint256) {\n        return _minDelay;\n    }\n\n    /**\n     * @dev Returns the identifier of an operation containing a single\n     * transaction.\n     */\n    function hashOperation(\n        address target,\n        uint256 value,\n        bytes calldata data,\n        bytes32 predecessor,\n        bytes32 salt\n    ) public pure virtual returns (bytes32) {\n        return keccak256(abi.encode(target, value, data, predecessor, salt));\n    }\n\n    /**\n     * @dev Returns the identifier of an operation containing a batch of\n     * transactions.\n     */\n    function hashOperationBatch(\n        address[] calldata targets,\n        uint256[] calldata values,\n        bytes[] calldata payloads,\n        bytes32 predecessor,\n        bytes32 salt\n    ) public pure virtual returns (bytes32) {\n        return keccak256(abi.encode(targets, values, payloads, predecessor, salt));\n    }\n\n    /**\n     * @dev Schedule an operation containing a single transaction.\n     *\n     * Emits {CallSalt} if salt is nonzero, and {CallScheduled}.\n     *\n     * Requirements:\n     *\n     * - the caller must have the 'proposer' role.\n     */\n    function schedule(\n        address target,\n        uint256 value,\n        bytes calldata data,\n        bytes32 predecessor,\n        bytes32 salt,\n        uint256 delay\n    ) public virtual onlyRole(PROPOSER_ROLE) {\n        bytes32 id = hashOperation(target, value, data, predecessor, salt);\n        _schedule(id, delay);\n        emit CallScheduled(id, 0, target, value, data, predecessor, delay);\n        if (salt != bytes32(0)) {\n            emit CallSalt(id, salt);\n        }\n    }\n\n    /**\n     * @dev Schedule an operation containing a batch of transactions.\n     *\n     * Emits {CallSalt} if salt is nonzero, and one {CallScheduled} event per transaction in the batch.\n     *\n     * Requirements:\n     *\n     * - the caller must have the 'proposer' role.\n     */\n    function scheduleBatch(\n        address[] calldata targets,\n        uint256[] calldata values,\n        bytes[] calldata payloads,\n        bytes32 predecessor,\n        bytes32 salt,\n        uint256 delay\n    ) public virtual onlyRole(PROPOSER_ROLE) {\n        require(targets.length == values.length, \"TimelockController: length mismatch\");\n        require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n        bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n        _schedule(id, delay);\n        for (uint256 i = 0; i < targets.length; ++i) {\n            emit CallScheduled(id, i, targets[i], values[i], payloads[i], predecessor, delay);\n        }\n        if (salt != bytes32(0)) {\n            emit CallSalt(id, salt);\n        }\n    }\n\n    /**\n     * @dev Schedule an operation that is to become valid after a given delay.\n     */\n    function _schedule(bytes32 id, uint256 delay) private {\n        require(!isOperation(id), \"TimelockController: operation already scheduled\");\n        require(delay >= getMinDelay(), \"TimelockController: insufficient delay\");\n        _timestamps[id] = block.timestamp + delay;\n    }\n\n    /**\n     * @dev Cancel an operation.\n     *\n     * Requirements:\n     *\n     * - the caller must have the 'canceller' role.\n     */\n    function cancel(bytes32 id) public virtual onlyRole(CANCELLER_ROLE) {\n        require(isOperationPending(id), \"TimelockController: operation cannot be cancelled\");\n        delete _timestamps[id];\n\n        emit Cancelled(id);\n    }\n\n    /**\n     * @dev Execute an (ready) operation containing a single transaction.\n     *\n     * Emits a {CallExecuted} event.\n     *\n     * Requirements:\n     *\n     * - the caller must have the 'executor' role.\n     */\n    // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\n    // thus any modifications to the operation during reentrancy should be caught.\n    // slither-disable-next-line reentrancy-eth\n    function execute(\n        address target,\n        uint256 value,\n        bytes calldata payload,\n        bytes32 predecessor,\n        bytes32 salt\n    ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n        bytes32 id = hashOperation(target, value, payload, predecessor, salt);\n\n        _beforeCall(id, predecessor);\n        _execute(target, value, payload);\n        emit CallExecuted(id, 0, target, value, payload);\n        _afterCall(id);\n    }\n\n    /**\n     * @dev Execute an (ready) operation containing a batch of transactions.\n     *\n     * Emits one {CallExecuted} event per transaction in the batch.\n     *\n     * Requirements:\n     *\n     * - the caller must have the 'executor' role.\n     */\n    // This function can reenter, but it doesn't pose a risk because _afterCall checks that the proposal is pending,\n    // thus any modifications to the operation during reentrancy should be caught.\n    // slither-disable-next-line reentrancy-eth\n    function executeBatch(\n        address[] calldata targets,\n        uint256[] calldata values,\n        bytes[] calldata payloads,\n        bytes32 predecessor,\n        bytes32 salt\n    ) public payable virtual onlyRoleOrOpenRole(EXECUTOR_ROLE) {\n        require(targets.length == values.length, \"TimelockController: length mismatch\");\n        require(targets.length == payloads.length, \"TimelockController: length mismatch\");\n\n        bytes32 id = hashOperationBatch(targets, values, payloads, predecessor, salt);\n\n        _beforeCall(id, predecessor);\n        for (uint256 i = 0; i < targets.length; ++i) {\n            address target = targets[i];\n            uint256 value = values[i];\n            bytes calldata payload = payloads[i];\n            _execute(target, value, payload);\n            emit CallExecuted(id, i, target, value, payload);\n        }\n        _afterCall(id);\n    }\n\n    /**\n     * @dev Execute an operation's call.\n     */\n    function _execute(address target, uint256 value, bytes calldata data) internal virtual {\n        (bool success, ) = target.call{value: value}(data);\n        require(success, \"TimelockController: underlying transaction reverted\");\n    }\n\n    /**\n     * @dev Checks before execution of an operation's calls.\n     */\n    function _beforeCall(bytes32 id, bytes32 predecessor) private view {\n        require(isOperationReady(id), \"TimelockController: operation is not ready\");\n        require(predecessor == bytes32(0) || isOperationDone(predecessor), \"TimelockController: missing dependency\");\n    }\n\n    /**\n     * @dev Checks after execution of an operation's calls.\n     */\n    function _afterCall(bytes32 id) private {\n        require(isOperationReady(id), \"TimelockController: operation is not ready\");\n        _timestamps[id] = _DONE_TIMESTAMP;\n    }\n\n    /**\n     * @dev Changes the minimum timelock duration for future operations.\n     *\n     * Emits a {MinDelayChange} event.\n     *\n     * Requirements:\n     *\n     * - the caller must be the timelock itself. This can only be achieved by scheduling and later executing\n     * an operation where the timelock is the target and the data is the ABI-encoded call to this function.\n     */\n    function updateDelay(uint256 newDelay) external virtual {\n        require(msg.sender == address(this), \"TimelockController: caller must be timelock\");\n        emit MinDelayChange(_minDelay, newDelay);\n        _minDelay = newDelay;\n    }\n\n    /**\n     * @dev See {IERC721Receiver-onERC721Received}.\n     */\n    function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n\n    /**\n     * @dev See {IERC1155Receiver-onERC1155Received}.\n     */\n    function onERC1155Received(\n        address,\n        address,\n        uint256,\n        uint256,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155Received.selector;\n    }\n\n    /**\n     * @dev See {IERC1155Receiver-onERC1155BatchReceived}.\n     */\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] memory,\n        uint256[] memory,\n        bytes memory\n    ) public virtual override returns (bytes4) {\n        return this.onERC1155BatchReceived.selector;\n    }\n}\n"
      },
      "@openzeppelin/contracts/interfaces/draft-IERC1822.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified\n * proxy whose upgrades are fully controlled by the current implementation.\n */\ninterface IERC1822Proxiable {\n    /**\n     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation\n     * address.\n     *\n     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks\n     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this\n     * function revert if invoked through a proxy.\n     */\n    function proxiableUUID() external view returns (bytes32);\n}\n"
      },
      "@openzeppelin/contracts/interfaces/IERC1967.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC1967.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev ERC-1967: Proxy Storage Slots. This interface contains the events defined in the ERC.\n *\n * _Available since v4.8.3._\n */\ninterface IERC1967 {\n    /**\n     * @dev Emitted when the implementation is upgraded.\n     */\n    event Upgraded(address indexed implementation);\n\n    /**\n     * @dev Emitted when the admin account has changed.\n     */\n    event AdminChanged(address previousAdmin, address newAdmin);\n\n    /**\n     * @dev Emitted when the beacon is changed.\n     */\n    event BeaconUpgraded(address indexed beacon);\n}\n"
      },
      "@openzeppelin/contracts/interfaces/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\n"
      },
      "@openzeppelin/contracts/interfaces/IERC4626.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (interfaces/IERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\nimport \"../token/ERC20/extensions/IERC20Metadata.sol\";\n\n/**\n * @dev Interface of the ERC4626 \"Tokenized Vault Standard\", as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[ERC-4626].\n *\n * _Available since v4.7._\n */\ninterface IERC4626 is IERC20, IERC20Metadata {\n    event Deposit(address indexed sender, address indexed owner, uint256 assets, uint256 shares);\n\n    event Withdraw(\n        address indexed sender,\n        address indexed receiver,\n        address indexed owner,\n        uint256 assets,\n        uint256 shares\n    );\n\n    /**\n     * @dev Returns the address of the underlying token used for the Vault for accounting, depositing, and withdrawing.\n     *\n     * - MUST be an ERC-20 token contract.\n     * - MUST NOT revert.\n     */\n    function asset() external view returns (address assetTokenAddress);\n\n    /**\n     * @dev Returns the total amount of the underlying asset that is “managed” by Vault.\n     *\n     * - SHOULD include any compounding that occurs from yield.\n     * - MUST be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT revert.\n     */\n    function totalAssets() external view returns (uint256 totalManagedAssets);\n\n    /**\n     * @dev Returns the amount of shares that the Vault would exchange for the amount of assets provided, in an ideal\n     * scenario where all the conditions are met.\n     *\n     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT show any variations depending on the caller.\n     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n     * - MUST NOT revert.\n     *\n     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n     * from.\n     */\n    function convertToShares(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Returns the amount of assets that the Vault would exchange for the amount of shares provided, in an ideal\n     * scenario where all the conditions are met.\n     *\n     * - MUST NOT be inclusive of any fees that are charged against assets in the Vault.\n     * - MUST NOT show any variations depending on the caller.\n     * - MUST NOT reflect slippage or other on-chain conditions, when performing the actual exchange.\n     * - MUST NOT revert.\n     *\n     * NOTE: This calculation MAY NOT reflect the “per-user” price-per-share, and instead should reflect the\n     * “average-user’s” price-per-share, meaning what the average user should expect to see when exchanging to and\n     * from.\n     */\n    function convertToAssets(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Returns the maximum amount of the underlying asset that can be deposited into the Vault for the receiver,\n     * through a deposit call.\n     *\n     * - MUST return a limited value if receiver is subject to some deposit limit.\n     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of assets that may be deposited.\n     * - MUST NOT revert.\n     */\n    function maxDeposit(address receiver) external view returns (uint256 maxAssets);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their deposit at the current block, given\n     * current on-chain conditions.\n     *\n     * - MUST return as close to and no more than the exact amount of Vault shares that would be minted in a deposit\n     *   call in the same transaction. I.e. deposit should return the same or more shares as previewDeposit if called\n     *   in the same transaction.\n     * - MUST NOT account for deposit limits like those returned from maxDeposit and should always act as though the\n     *   deposit would be accepted, regardless if the user has enough tokens approved, etc.\n     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToShares and previewDeposit SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewDeposit(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Mints shares Vault shares to receiver by depositing exactly amount of underlying tokens.\n     *\n     * - MUST emit the Deposit event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   deposit execution, and are accounted for during deposit.\n     * - MUST revert if all of assets cannot be deposited (due to deposit limit being reached, slippage, the user not\n     *   approving enough underlying tokens to the Vault contract, etc).\n     *\n     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function deposit(uint256 assets, address receiver) external returns (uint256 shares);\n\n    /**\n     * @dev Returns the maximum amount of the Vault shares that can be minted for the receiver, through a mint call.\n     * - MUST return a limited value if receiver is subject to some mint limit.\n     * - MUST return 2 ** 256 - 1 if there is no limit on the maximum amount of shares that may be minted.\n     * - MUST NOT revert.\n     */\n    function maxMint(address receiver) external view returns (uint256 maxShares);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their mint at the current block, given\n     * current on-chain conditions.\n     *\n     * - MUST return as close to and no fewer than the exact amount of assets that would be deposited in a mint call\n     *   in the same transaction. I.e. mint should return the same or fewer assets as previewMint if called in the\n     *   same transaction.\n     * - MUST NOT account for mint limits like those returned from maxMint and should always act as though the mint\n     *   would be accepted, regardless if the user has enough tokens approved, etc.\n     * - MUST be inclusive of deposit fees. Integrators should be aware of the existence of deposit fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToAssets and previewMint SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by minting.\n     */\n    function previewMint(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Mints exactly shares Vault shares to receiver by depositing amount of underlying tokens.\n     *\n     * - MUST emit the Deposit event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the mint\n     *   execution, and are accounted for during mint.\n     * - MUST revert if all of shares cannot be minted (due to deposit limit being reached, slippage, the user not\n     *   approving enough underlying tokens to the Vault contract, etc).\n     *\n     * NOTE: most implementations will require pre-approval of the Vault with the Vault’s underlying asset token.\n     */\n    function mint(uint256 shares, address receiver) external returns (uint256 assets);\n\n    /**\n     * @dev Returns the maximum amount of the underlying asset that can be withdrawn from the owner balance in the\n     * Vault, through a withdraw call.\n     *\n     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n     * - MUST NOT revert.\n     */\n    function maxWithdraw(address owner) external view returns (uint256 maxAssets);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their withdrawal at the current block,\n     * given current on-chain conditions.\n     *\n     * - MUST return as close to and no fewer than the exact amount of Vault shares that would be burned in a withdraw\n     *   call in the same transaction. I.e. withdraw should return the same or fewer shares as previewWithdraw if\n     *   called\n     *   in the same transaction.\n     * - MUST NOT account for withdrawal limits like those returned from maxWithdraw and should always act as though\n     *   the withdrawal would be accepted, regardless if the user has enough shares, etc.\n     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToShares and previewWithdraw SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by depositing.\n     */\n    function previewWithdraw(uint256 assets) external view returns (uint256 shares);\n\n    /**\n     * @dev Burns shares from owner and sends exactly assets of underlying tokens to receiver.\n     *\n     * - MUST emit the Withdraw event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   withdraw execution, and are accounted for during withdraw.\n     * - MUST revert if all of assets cannot be withdrawn (due to withdrawal limit being reached, slippage, the owner\n     *   not having enough shares, etc).\n     *\n     * Note that some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function withdraw(uint256 assets, address receiver, address owner) external returns (uint256 shares);\n\n    /**\n     * @dev Returns the maximum amount of Vault shares that can be redeemed from the owner balance in the Vault,\n     * through a redeem call.\n     *\n     * - MUST return a limited value if owner is subject to some withdrawal limit or timelock.\n     * - MUST return balanceOf(owner) if owner is not subject to any withdrawal limit or timelock.\n     * - MUST NOT revert.\n     */\n    function maxRedeem(address owner) external view returns (uint256 maxShares);\n\n    /**\n     * @dev Allows an on-chain or off-chain user to simulate the effects of their redeemption at the current block,\n     * given current on-chain conditions.\n     *\n     * - MUST return as close to and no more than the exact amount of assets that would be withdrawn in a redeem call\n     *   in the same transaction. I.e. redeem should return the same or more assets as previewRedeem if called in the\n     *   same transaction.\n     * - MUST NOT account for redemption limits like those returned from maxRedeem and should always act as though the\n     *   redemption would be accepted, regardless if the user has enough shares, etc.\n     * - MUST be inclusive of withdrawal fees. Integrators should be aware of the existence of withdrawal fees.\n     * - MUST NOT revert.\n     *\n     * NOTE: any unfavorable discrepancy between convertToAssets and previewRedeem SHOULD be considered slippage in\n     * share price or some other type of condition, meaning the depositor will lose assets by redeeming.\n     */\n    function previewRedeem(uint256 shares) external view returns (uint256 assets);\n\n    /**\n     * @dev Burns exactly shares from owner and sends assets of underlying tokens to receiver.\n     *\n     * - MUST emit the Withdraw event.\n     * - MAY support an additional flow in which the underlying tokens are owned by the Vault contract before the\n     *   redeem execution, and are accounted for during redeem.\n     * - MUST revert if all of shares cannot be redeemed (due to withdrawal limit being reached, slippage, the owner\n     *   not having enough shares, etc).\n     *\n     * NOTE: some implementations will require pre-requesting to the Vault before a withdrawal may be performed.\n     * Those methods should be performed separately.\n     */\n    function redeem(uint256 shares, address receiver, address owner) external returns (uint256 assets);\n}\n"
      },
      "@openzeppelin/contracts/proxy/beacon/IBeacon.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This is the interface that {BeaconProxy} expects of its beacon.\n */\ninterface IBeacon {\n    /**\n     * @dev Must return an address that can be used as a delegate call target.\n     *\n     * {BeaconProxy} will check that this address is a contract.\n     */\n    function implementation() external view returns (address);\n}\n"
      },
      "@openzeppelin/contracts/proxy/ERC1967/ERC1967Proxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/ERC1967/ERC1967Proxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Proxy.sol\";\nimport \"./ERC1967Upgrade.sol\";\n\n/**\n * @dev This contract implements an upgradeable proxy. It is upgradeable because calls are delegated to an\n * implementation address that can be changed. This address is stored in storage in the location specified by\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967], so that it doesn't conflict with the storage layout of the\n * implementation behind the proxy.\n */\ncontract ERC1967Proxy is Proxy, ERC1967Upgrade {\n    /**\n     * @dev Initializes the upgradeable proxy with an initial implementation specified by `_logic`.\n     *\n     * If `_data` is nonempty, it's used as data in a delegate call to `_logic`. This will typically be an encoded\n     * function call, and allows initializing the storage of the proxy like a Solidity constructor.\n     */\n    constructor(address _logic, bytes memory _data) payable {\n        _upgradeToAndCall(_logic, _data, false);\n    }\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _implementation() internal view virtual override returns (address impl) {\n        return ERC1967Upgrade._getImplementation();\n    }\n}\n"
      },
      "@openzeppelin/contracts/proxy/ERC1967/ERC1967Upgrade.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/ERC1967/ERC1967Upgrade.sol)\n\npragma solidity ^0.8.2;\n\nimport \"../beacon/IBeacon.sol\";\nimport \"../../interfaces/IERC1967.sol\";\nimport \"../../interfaces/draft-IERC1822.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/StorageSlot.sol\";\n\n/**\n * @dev This abstract contract provides getters and event emitting update functions for\n * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.\n *\n * _Available since v4.1._\n */\nabstract contract ERC1967Upgrade is IERC1967 {\n    // This is the keccak-256 hash of \"eip1967.proxy.rollback\" subtracted by 1\n    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;\n\n    /**\n     * @dev Storage slot with the address of the current implementation.\n     * This is the keccak-256 hash of \"eip1967.proxy.implementation\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n\n    /**\n     * @dev Returns the current implementation address.\n     */\n    function _getImplementation() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 implementation slot.\n     */\n    function _setImplementation(address newImplementation) private {\n        require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n        StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n    }\n\n    /**\n     * @dev Perform implementation upgrade\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeTo(address newImplementation) internal {\n        _setImplementation(newImplementation);\n        emit Upgraded(newImplementation);\n    }\n\n    /**\n     * @dev Perform implementation upgrade with additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCall(address newImplementation, bytes memory data, bool forceCall) internal {\n        _upgradeTo(newImplementation);\n        if (data.length > 0 || forceCall) {\n            Address.functionDelegateCall(newImplementation, data);\n        }\n    }\n\n    /**\n     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.\n     *\n     * Emits an {Upgraded} event.\n     */\n    function _upgradeToAndCallUUPS(address newImplementation, bytes memory data, bool forceCall) internal {\n        // Upgrades from old implementations will perform a rollback test. This test requires the new\n        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing\n        // this special case will break upgrade paths from old UUPS implementation to new ones.\n        if (StorageSlot.getBooleanSlot(_ROLLBACK_SLOT).value) {\n            _setImplementation(newImplementation);\n        } else {\n            try IERC1822Proxiable(newImplementation).proxiableUUID() returns (bytes32 slot) {\n                require(slot == _IMPLEMENTATION_SLOT, \"ERC1967Upgrade: unsupported proxiableUUID\");\n            } catch {\n                revert(\"ERC1967Upgrade: new implementation is not UUPS\");\n            }\n            _upgradeToAndCall(newImplementation, data, forceCall);\n        }\n    }\n\n    /**\n     * @dev Storage slot with the admin of the contract.\n     * This is the keccak-256 hash of \"eip1967.proxy.admin\" subtracted by 1, and is\n     * validated in the constructor.\n     */\n    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;\n\n    /**\n     * @dev Returns the current admin.\n     */\n    function _getAdmin() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_ADMIN_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new address in the EIP1967 admin slot.\n     */\n    function _setAdmin(address newAdmin) private {\n        require(newAdmin != address(0), \"ERC1967: new admin is the zero address\");\n        StorageSlot.getAddressSlot(_ADMIN_SLOT).value = newAdmin;\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {AdminChanged} event.\n     */\n    function _changeAdmin(address newAdmin) internal {\n        emit AdminChanged(_getAdmin(), newAdmin);\n        _setAdmin(newAdmin);\n    }\n\n    /**\n     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.\n     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.\n     */\n    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;\n\n    /**\n     * @dev Returns the current beacon.\n     */\n    function _getBeacon() internal view returns (address) {\n        return StorageSlot.getAddressSlot(_BEACON_SLOT).value;\n    }\n\n    /**\n     * @dev Stores a new beacon in the EIP1967 beacon slot.\n     */\n    function _setBeacon(address newBeacon) private {\n        require(Address.isContract(newBeacon), \"ERC1967: new beacon is not a contract\");\n        require(\n            Address.isContract(IBeacon(newBeacon).implementation()),\n            \"ERC1967: beacon implementation is not a contract\"\n        );\n        StorageSlot.getAddressSlot(_BEACON_SLOT).value = newBeacon;\n    }\n\n    /**\n     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does\n     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).\n     *\n     * Emits a {BeaconUpgraded} event.\n     */\n    function _upgradeBeaconToAndCall(address newBeacon, bytes memory data, bool forceCall) internal {\n        _setBeacon(newBeacon);\n        emit BeaconUpgraded(newBeacon);\n        if (data.length > 0 || forceCall) {\n            Address.functionDelegateCall(IBeacon(newBeacon).implementation(), data);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/proxy/Proxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (proxy/Proxy.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev This abstract contract provides a fallback function that delegates all calls to another contract using the EVM\n * instruction `delegatecall`. We refer to the second contract as the _implementation_ behind the proxy, and it has to\n * be specified by overriding the virtual {_implementation} function.\n *\n * Additionally, delegation to the implementation can be triggered manually through the {_fallback} function, or to a\n * different contract through the {_delegate} function.\n *\n * The success and return data of the delegated call will be returned back to the caller of the proxy.\n */\nabstract contract Proxy {\n    /**\n     * @dev Delegates the current call to `implementation`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _delegate(address implementation) internal virtual {\n        assembly {\n            // Copy msg.data. We take full control of memory in this inline assembly\n            // block because it will not return to Solidity code. We overwrite the\n            // Solidity scratch pad at memory position 0.\n            calldatacopy(0, 0, calldatasize())\n\n            // Call the implementation.\n            // out and outsize are 0 because we don't know the size yet.\n            let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0)\n\n            // Copy the returned data.\n            returndatacopy(0, 0, returndatasize())\n\n            switch result\n            // delegatecall returns 0 on error.\n            case 0 {\n                revert(0, returndatasize())\n            }\n            default {\n                return(0, returndatasize())\n            }\n        }\n    }\n\n    /**\n     * @dev This is a virtual function that should be overridden so it returns the address to which the fallback function\n     * and {_fallback} should delegate.\n     */\n    function _implementation() internal view virtual returns (address);\n\n    /**\n     * @dev Delegates the current call to the address returned by `_implementation()`.\n     *\n     * This function does not return to its internal call site, it will return directly to the external caller.\n     */\n    function _fallback() internal virtual {\n        _beforeFallback();\n        _delegate(_implementation());\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other\n     * function in the contract matches the call data.\n     */\n    fallback() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if call data\n     * is empty.\n     */\n    receive() external payable virtual {\n        _fallback();\n    }\n\n    /**\n     * @dev Hook that is called before falling back to the implementation. Can happen as part of a manual `_fallback`\n     * call, or as part of the Solidity `fallback` or `receive` functions.\n     *\n     * If overridden should call `super._beforeFallback()`.\n     */\n    function _beforeFallback() internal virtual {}\n}\n"
      },
      "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.3) (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./TransparentUpgradeableProxy.sol\";\nimport \"../../access/Ownable.sol\";\n\n/**\n * @dev This is an auxiliary contract meant to be assigned as the admin of a {TransparentUpgradeableProxy}. For an\n * explanation of why you would want to use this see the documentation for {TransparentUpgradeableProxy}.\n */\ncontract ProxyAdmin is Ownable {\n    /**\n     * @dev Returns the current implementation of `proxy`.\n     *\n     * Requirements:\n     *\n     * - This contract must be the admin of `proxy`.\n     */\n    function getProxyImplementation(ITransparentUpgradeableProxy proxy) public view virtual returns (address) {\n        // We need to manually run the static call since the getter cannot be flagged as view\n        // bytes4(keccak256(\"implementation()\")) == 0x5c60da1b\n        (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"5c60da1b\");\n        require(success);\n        return abi.decode(returndata, (address));\n    }\n\n    /**\n     * @dev Returns the current admin of `proxy`.\n     *\n     * Requirements:\n     *\n     * - This contract must be the admin of `proxy`.\n     */\n    function getProxyAdmin(ITransparentUpgradeableProxy proxy) public view virtual returns (address) {\n        // We need to manually run the static call since the getter cannot be flagged as view\n        // bytes4(keccak256(\"admin()\")) == 0xf851a440\n        (bool success, bytes memory returndata) = address(proxy).staticcall(hex\"f851a440\");\n        require(success);\n        return abi.decode(returndata, (address));\n    }\n\n    /**\n     * @dev Changes the admin of `proxy` to `newAdmin`.\n     *\n     * Requirements:\n     *\n     * - This contract must be the current admin of `proxy`.\n     */\n    function changeProxyAdmin(ITransparentUpgradeableProxy proxy, address newAdmin) public virtual onlyOwner {\n        proxy.changeAdmin(newAdmin);\n    }\n\n    /**\n     * @dev Upgrades `proxy` to `implementation`. See {TransparentUpgradeableProxy-upgradeTo}.\n     *\n     * Requirements:\n     *\n     * - This contract must be the admin of `proxy`.\n     */\n    function upgrade(ITransparentUpgradeableProxy proxy, address implementation) public virtual onlyOwner {\n        proxy.upgradeTo(implementation);\n    }\n\n    /**\n     * @dev Upgrades `proxy` to `implementation` and calls a function on the new implementation. See\n     * {TransparentUpgradeableProxy-upgradeToAndCall}.\n     *\n     * Requirements:\n     *\n     * - This contract must be the admin of `proxy`.\n     */\n    function upgradeAndCall(\n        ITransparentUpgradeableProxy proxy,\n        address implementation,\n        bytes memory data\n    ) public payable virtual onlyOwner {\n        proxy.upgradeToAndCall{value: msg.value}(implementation, data);\n    }\n}\n"
      },
      "@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC1967/ERC1967Proxy.sol\";\n\n/**\n * @dev Interface for {TransparentUpgradeableProxy}. In order to implement transparency, {TransparentUpgradeableProxy}\n * does not implement this interface directly, and some of its functions are implemented by an internal dispatch\n * mechanism. The compiler is unaware that these functions are implemented by {TransparentUpgradeableProxy} and will not\n * include them in the ABI so this interface must be used to interact with it.\n */\ninterface ITransparentUpgradeableProxy is IERC1967 {\n    function admin() external view returns (address);\n\n    function implementation() external view returns (address);\n\n    function changeAdmin(address) external;\n\n    function upgradeTo(address) external;\n\n    function upgradeToAndCall(address, bytes memory) external payable;\n}\n\n/**\n * @dev This contract implements a proxy that is upgradeable by an admin.\n *\n * To avoid https://medium.com/nomic-labs-blog/malicious-backdoors-in-ethereum-proxies-62629adf3357[proxy selector\n * clashing], which can potentially be used in an attack, this contract uses the\n * https://blog.openzeppelin.com/the-transparent-proxy-pattern/[transparent proxy pattern]. This pattern implies two\n * things that go hand in hand:\n *\n * 1. If any account other than the admin calls the proxy, the call will be forwarded to the implementation, even if\n * that call matches one of the admin functions exposed by the proxy itself.\n * 2. If the admin calls the proxy, it can access the admin functions, but its calls will never be forwarded to the\n * implementation. If the admin tries to call a function on the implementation it will fail with an error that says\n * \"admin cannot fallback to proxy target\".\n *\n * These properties mean that the admin account can only be used for admin actions like upgrading the proxy or changing\n * the admin, so it's best if it's a dedicated account that is not used for anything else. This will avoid headaches due\n * to sudden errors when trying to call a function from the proxy implementation.\n *\n * Our recommendation is for the dedicated account to be an instance of the {ProxyAdmin} contract. If set up this way,\n * you should think of the `ProxyAdmin` instance as the real administrative interface of your proxy.\n *\n * NOTE: The real interface of this proxy is that defined in `ITransparentUpgradeableProxy`. This contract does not\n * inherit from that interface, and instead the admin functions are implicitly implemented using a custom dispatch\n * mechanism in `_fallback`. Consequently, the compiler will not produce an ABI for this contract. This is necessary to\n * fully implement transparency without decoding reverts caused by selector clashes between the proxy and the\n * implementation.\n *\n * WARNING: It is not recommended to extend this contract to add additional external functions. If you do so, the compiler\n * will not check that there are no selector conflicts, due to the note above. A selector clash between any new function\n * and the functions declared in {ITransparentUpgradeableProxy} will be resolved in favor of the new one. This could\n * render the admin operations inaccessible, which could prevent upgradeability. Transparency may also be compromised.\n */\ncontract TransparentUpgradeableProxy is ERC1967Proxy {\n    /**\n     * @dev Initializes an upgradeable proxy managed by `_admin`, backed by the implementation at `_logic`, and\n     * optionally initialized with `_data` as explained in {ERC1967Proxy-constructor}.\n     */\n    constructor(address _logic, address admin_, bytes memory _data) payable ERC1967Proxy(_logic, _data) {\n        _changeAdmin(admin_);\n    }\n\n    /**\n     * @dev Modifier used internally that will delegate the call to the implementation unless the sender is the admin.\n     *\n     * CAUTION: This modifier is deprecated, as it could cause issues if the modified function has arguments, and the\n     * implementation provides a function with the same selector.\n     */\n    modifier ifAdmin() {\n        if (msg.sender == _getAdmin()) {\n            _;\n        } else {\n            _fallback();\n        }\n    }\n\n    /**\n     * @dev If caller is the admin process the call internally, otherwise transparently fallback to the proxy behavior\n     */\n    function _fallback() internal virtual override {\n        if (msg.sender == _getAdmin()) {\n            bytes memory ret;\n            bytes4 selector = msg.sig;\n            if (selector == ITransparentUpgradeableProxy.upgradeTo.selector) {\n                ret = _dispatchUpgradeTo();\n            } else if (selector == ITransparentUpgradeableProxy.upgradeToAndCall.selector) {\n                ret = _dispatchUpgradeToAndCall();\n            } else if (selector == ITransparentUpgradeableProxy.changeAdmin.selector) {\n                ret = _dispatchChangeAdmin();\n            } else if (selector == ITransparentUpgradeableProxy.admin.selector) {\n                ret = _dispatchAdmin();\n            } else if (selector == ITransparentUpgradeableProxy.implementation.selector) {\n                ret = _dispatchImplementation();\n            } else {\n                revert(\"TransparentUpgradeableProxy: admin cannot fallback to proxy target\");\n            }\n            assembly {\n                return(add(ret, 0x20), mload(ret))\n            }\n        } else {\n            super._fallback();\n        }\n    }\n\n    /**\n     * @dev Returns the current admin.\n     *\n     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n     * `0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103`\n     */\n    function _dispatchAdmin() private returns (bytes memory) {\n        _requireZeroValue();\n\n        address admin = _getAdmin();\n        return abi.encode(admin);\n    }\n\n    /**\n     * @dev Returns the current implementation.\n     *\n     * TIP: To get this value clients can read directly from the storage slot shown below (specified by EIP1967) using the\n     * https://eth.wiki/json-rpc/API#eth_getstorageat[`eth_getStorageAt`] RPC call.\n     * `0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc`\n     */\n    function _dispatchImplementation() private returns (bytes memory) {\n        _requireZeroValue();\n\n        address implementation = _implementation();\n        return abi.encode(implementation);\n    }\n\n    /**\n     * @dev Changes the admin of the proxy.\n     *\n     * Emits an {AdminChanged} event.\n     */\n    function _dispatchChangeAdmin() private returns (bytes memory) {\n        _requireZeroValue();\n\n        address newAdmin = abi.decode(msg.data[4:], (address));\n        _changeAdmin(newAdmin);\n\n        return \"\";\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy.\n     */\n    function _dispatchUpgradeTo() private returns (bytes memory) {\n        _requireZeroValue();\n\n        address newImplementation = abi.decode(msg.data[4:], (address));\n        _upgradeToAndCall(newImplementation, bytes(\"\"), false);\n\n        return \"\";\n    }\n\n    /**\n     * @dev Upgrade the implementation of the proxy, and then call a function from the new implementation as specified\n     * by `data`, which should be an encoded function call. This is useful to initialize new storage variables in the\n     * proxied contract.\n     */\n    function _dispatchUpgradeToAndCall() private returns (bytes memory) {\n        (address newImplementation, bytes memory data) = abi.decode(msg.data[4:], (address, bytes));\n        _upgradeToAndCall(newImplementation, data, true);\n\n        return \"\";\n    }\n\n    /**\n     * @dev Returns the current admin.\n     *\n     * CAUTION: This function is deprecated. Use {ERC1967Upgrade-_getAdmin} instead.\n     */\n    function _admin() internal view virtual returns (address) {\n        return _getAdmin();\n    }\n\n    /**\n     * @dev To keep this contract fully transparent, all `ifAdmin` functions must be payable. This helper is here to\n     * emulate some proxy functions being non-payable while still allowing value to pass through.\n     */\n    function _requireZeroValue() private {\n        require(msg.value == 0);\n    }\n}\n"
      },
      "@openzeppelin/contracts/security/Pausable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which allows children to implement an emergency stop\n * mechanism that can be triggered by an authorized account.\n *\n * This module is used through inheritance. It will make available the\n * modifiers `whenNotPaused` and `whenPaused`, which can be applied to\n * the functions of your contract. Note that they will not be pausable by\n * simply including this module, only once the modifiers are put in place.\n */\nabstract contract Pausable is Context {\n    /**\n     * @dev Emitted when the pause is triggered by `account`.\n     */\n    event Paused(address account);\n\n    /**\n     * @dev Emitted when the pause is lifted by `account`.\n     */\n    event Unpaused(address account);\n\n    bool private _paused;\n\n    /**\n     * @dev Initializes the contract in unpaused state.\n     */\n    constructor() {\n        _paused = false;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is not paused.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    modifier whenNotPaused() {\n        _requireNotPaused();\n        _;\n    }\n\n    /**\n     * @dev Modifier to make a function callable only when the contract is paused.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    modifier whenPaused() {\n        _requirePaused();\n        _;\n    }\n\n    /**\n     * @dev Returns true if the contract is paused, and false otherwise.\n     */\n    function paused() public view virtual returns (bool) {\n        return _paused;\n    }\n\n    /**\n     * @dev Throws if the contract is paused.\n     */\n    function _requireNotPaused() internal view virtual {\n        require(!paused(), \"Pausable: paused\");\n    }\n\n    /**\n     * @dev Throws if the contract is not paused.\n     */\n    function _requirePaused() internal view virtual {\n        require(paused(), \"Pausable: not paused\");\n    }\n\n    /**\n     * @dev Triggers stopped state.\n     *\n     * Requirements:\n     *\n     * - The contract must not be paused.\n     */\n    function _pause() internal virtual whenNotPaused {\n        _paused = true;\n        emit Paused(_msgSender());\n    }\n\n    /**\n     * @dev Returns to normal state.\n     *\n     * Requirements:\n     *\n     * - The contract must be paused.\n     */\n    function _unpause() internal virtual whenPaused {\n        _paused = false;\n        emit Unpaused(_msgSender());\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n    /**\n     * @dev Handles the receipt of a single ERC1155 token type. This function is\n     * called at the end of a `safeTransferFrom` after the balance has been updated.\n     *\n     * NOTE: To accept the transfer, this must return\n     * `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`\n     * (i.e. 0xf23a6e61, or its own function selector).\n     *\n     * @param operator The address which initiated the transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param id The ID of the token being transferred\n     * @param value The amount of tokens being transferred\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` if transfer is allowed\n     */\n    function onERC1155Received(\n        address operator,\n        address from,\n        uint256 id,\n        uint256 value,\n        bytes calldata data\n    ) external returns (bytes4);\n\n    /**\n     * @dev Handles the receipt of a multiple ERC1155 token types. This function\n     * is called at the end of a `safeBatchTransferFrom` after the balances have\n     * been updated.\n     *\n     * NOTE: To accept the transfer(s), this must return\n     * `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`\n     * (i.e. 0xbc197c81, or its own function selector).\n     *\n     * @param operator The address which initiated the batch transfer (i.e. msg.sender)\n     * @param from The address which previously owned the token\n     * @param ids An array containing ids of each token being transferred (order and length must match values array)\n     * @param values An array containing amounts of each token being transferred (order and length must match ids array)\n     * @param data Additional data with no specified format\n     * @return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` if transfer is allowed\n     */\n    function onERC1155BatchReceived(\n        address operator,\n        address from,\n        uint256[] calldata ids,\n        uint256[] calldata values,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/ERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How\n * to implement supply mechanisms].\n *\n * The default value of {decimals} is 18. To change this, you should override\n * this function so it returns a different value.\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     * 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 default value returned by this function, unless\n     * it's 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(address from, address to, uint256 amount) 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(address from, address to, uint256 amount) 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            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by\n            // decrementing then incrementing.\n            _balances[to] += amount;\n        }\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        unchecked {\n            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.\n            _balances[account] += amount;\n        }\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            // Overflow not possible: amount <= accountBalance <= totalSupply.\n            _totalSupply -= amount;\n        }\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(address owner, address spender, uint256 amount) 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(address owner, address spender, uint256 amount) 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(address from, address to, uint256 amount) 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(address from, address to, uint256 amount) internal virtual {}\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/ERC4626.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC20.sol\";\nimport \"../utils/SafeERC20.sol\";\nimport \"../../../interfaces/IERC4626.sol\";\nimport \"../../../utils/math/Math.sol\";\n\n/**\n * @dev Implementation of the ERC4626 \"Tokenized Vault Standard\" as defined in\n * https://eips.ethereum.org/EIPS/eip-4626[EIP-4626].\n *\n * This extension allows the minting and burning of \"shares\" (represented using the ERC20 inheritance) in exchange for\n * underlying \"assets\" through standardized {deposit}, {mint}, {redeem} and {burn} workflows. This contract extends\n * the ERC20 standard. Any additional extensions included along it would affect the \"shares\" token represented by this\n * contract and not the \"assets\" token which is an independent contract.\n *\n * [CAUTION]\n * ====\n * In empty (or nearly empty) ERC-4626 vaults, deposits are at high risk of being stolen through frontrunning\n * with a \"donation\" to the vault that inflates the price of a share. This is variously known as a donation or inflation\n * attack and is essentially a problem of slippage. Vault deployers can protect against this attack by making an initial\n * deposit of a non-trivial amount of the asset, such that price manipulation becomes infeasible. Withdrawals may\n * similarly be affected by slippage. Users can protect against this attack as well as unexpected slippage in general by\n * verifying the amount received is as expected, using a wrapper that performs these checks such as\n * https://github.com/fei-protocol/ERC4626#erc4626router-and-base[ERC4626Router].\n *\n * Since v4.9, this implementation uses virtual assets and shares to mitigate that risk. The `_decimalsOffset()`\n * corresponds to an offset in the decimal representation between the underlying asset's decimals and the vault\n * decimals. This offset also determines the rate of virtual shares to virtual assets in the vault, which itself\n * determines the initial exchange rate. While not fully preventing the attack, analysis shows that the default offset\n * (0) makes it non-profitable, as a result of the value being captured by the virtual shares (out of the attacker's\n * donation) matching the attacker's expected gains. With a larger offset, the attack becomes orders of magnitude more\n * expensive than it is profitable. More details about the underlying math can be found\n * xref:erc4626.adoc#inflation-attack[here].\n *\n * The drawback of this approach is that the virtual shares do capture (a very small) part of the value being accrued\n * to the vault. Also, if the vault experiences losses, the users try to exit the vault, the virtual shares and assets\n * will cause the first user to exit to experience reduced losses in detriment to the last users that will experience\n * bigger losses. Developers willing to revert back to the pre-v4.9 behavior just need to override the\n * `_convertToShares` and `_convertToAssets` functions.\n *\n * To learn more, check out our xref:ROOT:erc4626.adoc[ERC-4626 guide].\n * ====\n *\n * _Available since v4.7._\n */\nabstract contract ERC4626 is ERC20, IERC4626 {\n    using Math for uint256;\n\n    IERC20 private immutable _asset;\n    uint8 private immutable _underlyingDecimals;\n\n    /**\n     * @dev Set the underlying asset contract. This must be an ERC20-compatible contract (ERC20 or ERC777).\n     */\n    constructor(IERC20 asset_) {\n        (bool success, uint8 assetDecimals) = _tryGetAssetDecimals(asset_);\n        _underlyingDecimals = success ? assetDecimals : 18;\n        _asset = asset_;\n    }\n\n    /**\n     * @dev Attempts to fetch the asset decimals. A return value of false indicates that the attempt failed in some way.\n     */\n    function _tryGetAssetDecimals(IERC20 asset_) private view returns (bool, uint8) {\n        (bool success, bytes memory encodedDecimals) = address(asset_).staticcall(\n            abi.encodeWithSelector(IERC20Metadata.decimals.selector)\n        );\n        if (success && encodedDecimals.length >= 32) {\n            uint256 returnedDecimals = abi.decode(encodedDecimals, (uint256));\n            if (returnedDecimals <= type(uint8).max) {\n                return (true, uint8(returnedDecimals));\n            }\n        }\n        return (false, 0);\n    }\n\n    /**\n     * @dev Decimals are computed by adding the decimal offset on top of the underlying asset's decimals. This\n     * \"original\" value is cached during construction of the vault contract. If this read operation fails (e.g., the\n     * asset has not been created yet), a default of 18 is used to represent the underlying asset's decimals.\n     *\n     * See {IERC20Metadata-decimals}.\n     */\n    function decimals() public view virtual override(IERC20Metadata, ERC20) returns (uint8) {\n        return _underlyingDecimals + _decimalsOffset();\n    }\n\n    /** @dev See {IERC4626-asset}. */\n    function asset() public view virtual override returns (address) {\n        return address(_asset);\n    }\n\n    /** @dev See {IERC4626-totalAssets}. */\n    function totalAssets() public view virtual override returns (uint256) {\n        return _asset.balanceOf(address(this));\n    }\n\n    /** @dev See {IERC4626-convertToShares}. */\n    function convertToShares(uint256 assets) public view virtual override returns (uint256) {\n        return _convertToShares(assets, Math.Rounding.Down);\n    }\n\n    /** @dev See {IERC4626-convertToAssets}. */\n    function convertToAssets(uint256 shares) public view virtual override returns (uint256) {\n        return _convertToAssets(shares, Math.Rounding.Down);\n    }\n\n    /** @dev See {IERC4626-maxDeposit}. */\n    function maxDeposit(address) public view virtual override returns (uint256) {\n        return type(uint256).max;\n    }\n\n    /** @dev See {IERC4626-maxMint}. */\n    function maxMint(address) public view virtual override returns (uint256) {\n        return type(uint256).max;\n    }\n\n    /** @dev See {IERC4626-maxWithdraw}. */\n    function maxWithdraw(address owner) public view virtual override returns (uint256) {\n        return _convertToAssets(balanceOf(owner), Math.Rounding.Down);\n    }\n\n    /** @dev See {IERC4626-maxRedeem}. */\n    function maxRedeem(address owner) public view virtual override returns (uint256) {\n        return balanceOf(owner);\n    }\n\n    /** @dev See {IERC4626-previewDeposit}. */\n    function previewDeposit(uint256 assets) public view virtual override returns (uint256) {\n        return _convertToShares(assets, Math.Rounding.Down);\n    }\n\n    /** @dev See {IERC4626-previewMint}. */\n    function previewMint(uint256 shares) public view virtual override returns (uint256) {\n        return _convertToAssets(shares, Math.Rounding.Up);\n    }\n\n    /** @dev See {IERC4626-previewWithdraw}. */\n    function previewWithdraw(uint256 assets) public view virtual override returns (uint256) {\n        return _convertToShares(assets, Math.Rounding.Up);\n    }\n\n    /** @dev See {IERC4626-previewRedeem}. */\n    function previewRedeem(uint256 shares) public view virtual override returns (uint256) {\n        return _convertToAssets(shares, Math.Rounding.Down);\n    }\n\n    /** @dev See {IERC4626-deposit}. */\n    function deposit(uint256 assets, address receiver) public virtual override returns (uint256) {\n        require(assets <= maxDeposit(receiver), \"ERC4626: deposit more than max\");\n\n        uint256 shares = previewDeposit(assets);\n        _deposit(_msgSender(), receiver, assets, shares);\n\n        return shares;\n    }\n\n    /** @dev See {IERC4626-mint}.\n     *\n     * As opposed to {deposit}, minting is allowed even if the vault is in a state where the price of a share is zero.\n     * In this case, the shares will be minted without requiring any assets to be deposited.\n     */\n    function mint(uint256 shares, address receiver) public virtual override returns (uint256) {\n        require(shares <= maxMint(receiver), \"ERC4626: mint more than max\");\n\n        uint256 assets = previewMint(shares);\n        _deposit(_msgSender(), receiver, assets, shares);\n\n        return assets;\n    }\n\n    /** @dev See {IERC4626-withdraw}. */\n    function withdraw(uint256 assets, address receiver, address owner) public virtual override returns (uint256) {\n        require(assets <= maxWithdraw(owner), \"ERC4626: withdraw more than max\");\n\n        uint256 shares = previewWithdraw(assets);\n        _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n        return shares;\n    }\n\n    /** @dev See {IERC4626-redeem}. */\n    function redeem(uint256 shares, address receiver, address owner) public virtual override returns (uint256) {\n        require(shares <= maxRedeem(owner), \"ERC4626: redeem more than max\");\n\n        uint256 assets = previewRedeem(shares);\n        _withdraw(_msgSender(), receiver, owner, assets, shares);\n\n        return assets;\n    }\n\n    /**\n     * @dev Internal conversion function (from assets to shares) with support for rounding direction.\n     */\n    function _convertToShares(uint256 assets, Math.Rounding rounding) internal view virtual returns (uint256) {\n        return assets.mulDiv(totalSupply() + 10 ** _decimalsOffset(), totalAssets() + 1, rounding);\n    }\n\n    /**\n     * @dev Internal conversion function (from shares to assets) with support for rounding direction.\n     */\n    function _convertToAssets(uint256 shares, Math.Rounding rounding) internal view virtual returns (uint256) {\n        return shares.mulDiv(totalAssets() + 1, totalSupply() + 10 ** _decimalsOffset(), rounding);\n    }\n\n    /**\n     * @dev Deposit/mint common workflow.\n     */\n    function _deposit(address caller, address receiver, uint256 assets, uint256 shares) internal virtual {\n        // If _asset is ERC777, `transferFrom` can trigger a reentrancy BEFORE the transfer happens through the\n        // `tokensToSend` hook. On the other hand, the `tokenReceived` hook, that is triggered after the transfer,\n        // calls the vault, which is assumed not malicious.\n        //\n        // Conclusion: we need to do the transfer before we mint so that any reentrancy would happen before the\n        // assets are transferred and before the shares are minted, which is a valid state.\n        // slither-disable-next-line reentrancy-no-eth\n        SafeERC20.safeTransferFrom(_asset, caller, address(this), assets);\n        _mint(receiver, shares);\n\n        emit Deposit(caller, receiver, assets, shares);\n    }\n\n    /**\n     * @dev Withdraw/redeem common workflow.\n     */\n    function _withdraw(\n        address caller,\n        address receiver,\n        address owner,\n        uint256 assets,\n        uint256 shares\n    ) internal virtual {\n        if (caller != owner) {\n            _spendAllowance(owner, caller, shares);\n        }\n\n        // If _asset is ERC777, `transfer` can trigger a reentrancy AFTER the transfer happens through the\n        // `tokensReceived` hook. On the other hand, the `tokensToSend` hook, that is triggered before the transfer,\n        // calls the vault, which is assumed not malicious.\n        //\n        // Conclusion: we need to do the transfer after the burn so that any reentrancy would happen after the\n        // shares are burned and after the assets are transferred, which is a valid state.\n        _burn(owner, shares);\n        SafeERC20.safeTransfer(_asset, receiver, assets);\n\n        emit Withdraw(caller, receiver, owner, assets, shares);\n    }\n\n    function _decimalsOffset() internal view virtual returns (uint8) {\n        return 0;\n    }\n}\n"
      },
      "@openzeppelin/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"
      },
      "@openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/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"
      },
      "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/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    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(IERC20 token, address spender, uint256 value) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        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        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     *\n     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/ERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/ERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC721.sol\";\nimport \"./IERC721Receiver.sol\";\nimport \"./extensions/IERC721Metadata.sol\";\nimport \"../../utils/Address.sol\";\nimport \"../../utils/Context.sol\";\nimport \"../../utils/Strings.sol\";\nimport \"../../utils/introspection/ERC165.sol\";\n\n/**\n * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including\n * the Metadata extension, but not including the Enumerable extension, which is available separately as\n * {ERC721Enumerable}.\n */\ncontract ERC721 is Context, ERC165, IERC721, IERC721Metadata {\n    using Address for address;\n    using Strings for uint256;\n\n    // Token name\n    string private _name;\n\n    // Token symbol\n    string private _symbol;\n\n    // Mapping from token ID to owner address\n    mapping(uint256 => address) private _owners;\n\n    // Mapping owner address to token count\n    mapping(address => uint256) private _balances;\n\n    // Mapping from token ID to approved address\n    mapping(uint256 => address) private _tokenApprovals;\n\n    // Mapping from owner to operator approvals\n    mapping(address => mapping(address => bool)) private _operatorApprovals;\n\n    /**\n     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.\n     */\n    constructor(string memory name_, string memory symbol_) {\n        _name = name_;\n        _symbol = symbol_;\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {\n        return\n            interfaceId == type(IERC721).interfaceId ||\n            interfaceId == type(IERC721Metadata).interfaceId ||\n            super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721-balanceOf}.\n     */\n    function balanceOf(address owner) public view virtual override returns (uint256) {\n        require(owner != address(0), \"ERC721: address zero is not a valid owner\");\n        return _balances[owner];\n    }\n\n    /**\n     * @dev See {IERC721-ownerOf}.\n     */\n    function ownerOf(uint256 tokenId) public view virtual override returns (address) {\n        address owner = _ownerOf(tokenId);\n        require(owner != address(0), \"ERC721: invalid token ID\");\n        return owner;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-name}.\n     */\n    function name() public view virtual override returns (string memory) {\n        return _name;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-symbol}.\n     */\n    function symbol() public view virtual override returns (string memory) {\n        return _symbol;\n    }\n\n    /**\n     * @dev See {IERC721Metadata-tokenURI}.\n     */\n    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {\n        _requireMinted(tokenId);\n\n        string memory baseURI = _baseURI();\n        return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : \"\";\n    }\n\n    /**\n     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each\n     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty\n     * by default, can be overridden in child contracts.\n     */\n    function _baseURI() internal view virtual returns (string memory) {\n        return \"\";\n    }\n\n    /**\n     * @dev See {IERC721-approve}.\n     */\n    function approve(address to, uint256 tokenId) public virtual override {\n        address owner = ERC721.ownerOf(tokenId);\n        require(to != owner, \"ERC721: approval to current owner\");\n\n        require(\n            _msgSender() == owner || isApprovedForAll(owner, _msgSender()),\n            \"ERC721: approve caller is not token owner or approved for all\"\n        );\n\n        _approve(to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-getApproved}.\n     */\n    function getApproved(uint256 tokenId) public view virtual override returns (address) {\n        _requireMinted(tokenId);\n\n        return _tokenApprovals[tokenId];\n    }\n\n    /**\n     * @dev See {IERC721-setApprovalForAll}.\n     */\n    function setApprovalForAll(address operator, bool approved) public virtual override {\n        _setApprovalForAll(_msgSender(), operator, approved);\n    }\n\n    /**\n     * @dev See {IERC721-isApprovedForAll}.\n     */\n    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {\n        return _operatorApprovals[owner][operator];\n    }\n\n    /**\n     * @dev See {IERC721-transferFrom}.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) public virtual override {\n        //solhint-disable-next-line max-line-length\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n\n        _transfer(from, to, tokenId);\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {\n        safeTransferFrom(from, to, tokenId, \"\");\n    }\n\n    /**\n     * @dev See {IERC721-safeTransferFrom}.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public virtual override {\n        require(_isApprovedOrOwner(_msgSender(), tokenId), \"ERC721: caller is not token owner or approved\");\n        _safeTransfer(from, to, tokenId, data);\n    }\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * `data` is additional data, it has no specified format and it is sent in call to `to`.\n     *\n     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.\n     * implement alternative mechanisms to perform token transfer, such as signature-based.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory data) internal virtual {\n        _transfer(from, to, tokenId);\n        require(_checkOnERC721Received(from, to, tokenId, data), \"ERC721: transfer to non ERC721Receiver implementer\");\n    }\n\n    /**\n     * @dev Returns the owner of the `tokenId`. Does NOT revert if token doesn't exist\n     */\n    function _ownerOf(uint256 tokenId) internal view virtual returns (address) {\n        return _owners[tokenId];\n    }\n\n    /**\n     * @dev Returns whether `tokenId` exists.\n     *\n     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.\n     *\n     * Tokens start existing when they are minted (`_mint`),\n     * and stop existing when they are burned (`_burn`).\n     */\n    function _exists(uint256 tokenId) internal view virtual returns (bool) {\n        return _ownerOf(tokenId) != address(0);\n    }\n\n    /**\n     * @dev Returns whether `spender` is allowed to manage `tokenId`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {\n        address owner = ERC721.ownerOf(tokenId);\n        return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == spender);\n    }\n\n    /**\n     * @dev Safely mints `tokenId` and transfers it to `to`.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _safeMint(address to, uint256 tokenId) internal virtual {\n        _safeMint(to, tokenId, \"\");\n    }\n\n    /**\n     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is\n     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.\n     */\n    function _safeMint(address to, uint256 tokenId, bytes memory data) internal virtual {\n        _mint(to, tokenId);\n        require(\n            _checkOnERC721Received(address(0), to, tokenId, data),\n            \"ERC721: transfer to non ERC721Receiver implementer\"\n        );\n    }\n\n    /**\n     * @dev Mints `tokenId` and transfers it to `to`.\n     *\n     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible\n     *\n     * Requirements:\n     *\n     * - `tokenId` must not exist.\n     * - `to` cannot be the zero address.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _mint(address to, uint256 tokenId) internal virtual {\n        require(to != address(0), \"ERC721: mint to the zero address\");\n        require(!_exists(tokenId), \"ERC721: token already minted\");\n\n        _beforeTokenTransfer(address(0), to, tokenId, 1);\n\n        // Check that tokenId was not minted by `_beforeTokenTransfer` hook\n        require(!_exists(tokenId), \"ERC721: token already minted\");\n\n        unchecked {\n            // Will not overflow unless all 2**256 token ids are minted to the same owner.\n            // Given that tokens are minted one by one, it is impossible in practice that\n            // this ever happens. Might change if we allow batch minting.\n            // The ERC fails to describe this case.\n            _balances[to] += 1;\n        }\n\n        _owners[tokenId] = to;\n\n        emit Transfer(address(0), to, tokenId);\n\n        _afterTokenTransfer(address(0), to, tokenId, 1);\n    }\n\n    /**\n     * @dev Destroys `tokenId`.\n     * The approval is cleared when the token is burned.\n     * This is an internal function that does not check if the sender is authorized to operate on the token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _burn(uint256 tokenId) internal virtual {\n        address owner = ERC721.ownerOf(tokenId);\n\n        _beforeTokenTransfer(owner, address(0), tokenId, 1);\n\n        // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook\n        owner = ERC721.ownerOf(tokenId);\n\n        // Clear approvals\n        delete _tokenApprovals[tokenId];\n\n        unchecked {\n            // Cannot overflow, as that would require more tokens to be burned/transferred\n            // out than the owner initially received through minting and transferring in.\n            _balances[owner] -= 1;\n        }\n        delete _owners[tokenId];\n\n        emit Transfer(owner, address(0), tokenId);\n\n        _afterTokenTransfer(owner, address(0), tokenId, 1);\n    }\n\n    /**\n     * @dev Transfers `tokenId` from `from` to `to`.\n     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     *\n     * Emits a {Transfer} event.\n     */\n    function _transfer(address from, address to, uint256 tokenId) internal virtual {\n        require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n        require(to != address(0), \"ERC721: transfer to the zero address\");\n\n        _beforeTokenTransfer(from, to, tokenId, 1);\n\n        // Check that tokenId was not transferred by `_beforeTokenTransfer` hook\n        require(ERC721.ownerOf(tokenId) == from, \"ERC721: transfer from incorrect owner\");\n\n        // Clear approvals from the previous owner\n        delete _tokenApprovals[tokenId];\n\n        unchecked {\n            // `_balances[from]` cannot overflow for the same reason as described in `_burn`:\n            // `from`'s balance is the number of token held, which is at least one before the current\n            // transfer.\n            // `_balances[to]` could overflow in the conditions described in `_mint`. That would require\n            // all 2**256 token ids to be minted, which in practice is impossible.\n            _balances[from] -= 1;\n            _balances[to] += 1;\n        }\n        _owners[tokenId] = to;\n\n        emit Transfer(from, to, tokenId);\n\n        _afterTokenTransfer(from, to, tokenId, 1);\n    }\n\n    /**\n     * @dev Approve `to` to operate on `tokenId`\n     *\n     * Emits an {Approval} event.\n     */\n    function _approve(address to, uint256 tokenId) internal virtual {\n        _tokenApprovals[tokenId] = to;\n        emit Approval(ERC721.ownerOf(tokenId), to, tokenId);\n    }\n\n    /**\n     * @dev Approve `operator` to operate on all of `owner` tokens\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function _setApprovalForAll(address owner, address operator, bool approved) internal virtual {\n        require(owner != operator, \"ERC721: approve to caller\");\n        _operatorApprovals[owner][operator] = approved;\n        emit ApprovalForAll(owner, operator, approved);\n    }\n\n    /**\n     * @dev Reverts if the `tokenId` has not been minted yet.\n     */\n    function _requireMinted(uint256 tokenId) internal view virtual {\n        require(_exists(tokenId), \"ERC721: invalid token ID\");\n    }\n\n    /**\n     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.\n     * The call is not executed if the target address is not a contract.\n     *\n     * @param from address representing the previous owner of the given token ID\n     * @param to target address that will receive the tokens\n     * @param tokenId uint256 ID of the token to be transferred\n     * @param data bytes optional data to send along with the call\n     * @return bool whether the call correctly returned the expected magic value\n     */\n    function _checkOnERC721Received(\n        address from,\n        address to,\n        uint256 tokenId,\n        bytes memory data\n    ) private returns (bool) {\n        if (to.isContract()) {\n            try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {\n                return retval == IERC721Receiver.onERC721Received.selector;\n            } catch (bytes memory reason) {\n                if (reason.length == 0) {\n                    revert(\"ERC721: transfer to non ERC721Receiver implementer\");\n                } else {\n                    /// @solidity memory-safe-assembly\n                    assembly {\n                        revert(add(32, reason), mload(reason))\n                    }\n                }\n            }\n        } else {\n            return true;\n        }\n    }\n\n    /**\n     * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n     *\n     * Calling conditions:\n     *\n     * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`.\n     * - When `from` is zero, the tokens will be minted for `to`.\n     * - When `to` is zero, ``from``'s tokens will be burned.\n     * - `from` and `to` are never both zero.\n     * - `batchSize` is non-zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _beforeTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n    /**\n     * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is\n     * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1.\n     *\n     * Calling conditions:\n     *\n     * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`.\n     * - When `from` is zero, the tokens were minted for `to`.\n     * - When `to` is zero, ``from``'s tokens were burned.\n     * - `from` and `to` are never both zero.\n     * - `batchSize` is non-zero.\n     *\n     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].\n     */\n    function _afterTokenTransfer(address from, address to, uint256 firstTokenId, uint256 batchSize) internal virtual {}\n\n    /**\n     * @dev Unsafe write access to the balances, used by extensions that \"mint\" tokens using an {ownerOf} override.\n     *\n     * WARNING: Anyone calling this MUST ensure that the balances remain consistent with the ownership. The invariant\n     * being that for any address `a` the value returned by `balanceOf(a)` must be equal to the number of tokens such\n     * that `ownerOf(tokenId)` is `a`.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function __unsafe_increaseBalance(address account, uint256 amount) internal {\n        _balances[account] += amount;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../ERC721.sol\";\nimport \"./IERC721Enumerable.sol\";\n\n/**\n * @dev This implements an optional extension of {ERC721} defined in the EIP that adds\n * enumerability of all the token ids in the contract as well as all token ids owned by each\n * account.\n */\nabstract contract ERC721Enumerable is ERC721, IERC721Enumerable {\n    // Mapping from owner to list of owned token IDs\n    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;\n\n    // Mapping from token ID to index of the owner tokens list\n    mapping(uint256 => uint256) private _ownedTokensIndex;\n\n    // Array with all token ids, used for enumeration\n    uint256[] private _allTokens;\n\n    // Mapping from token id to position in the allTokens array\n    mapping(uint256 => uint256) private _allTokensIndex;\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {\n        return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId);\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {\n        require(index < ERC721.balanceOf(owner), \"ERC721Enumerable: owner index out of bounds\");\n        return _ownedTokens[owner][index];\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-totalSupply}.\n     */\n    function totalSupply() public view virtual override returns (uint256) {\n        return _allTokens.length;\n    }\n\n    /**\n     * @dev See {IERC721Enumerable-tokenByIndex}.\n     */\n    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {\n        require(index < ERC721Enumerable.totalSupply(), \"ERC721Enumerable: global index out of bounds\");\n        return _allTokens[index];\n    }\n\n    /**\n     * @dev See {ERC721-_beforeTokenTransfer}.\n     */\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 firstTokenId,\n        uint256 batchSize\n    ) internal virtual override {\n        super._beforeTokenTransfer(from, to, firstTokenId, batchSize);\n\n        if (batchSize > 1) {\n            // Will only trigger during construction. Batch transferring (minting) is not available afterwards.\n            revert(\"ERC721Enumerable: consecutive transfers not supported\");\n        }\n\n        uint256 tokenId = firstTokenId;\n\n        if (from == address(0)) {\n            _addTokenToAllTokensEnumeration(tokenId);\n        } else if (from != to) {\n            _removeTokenFromOwnerEnumeration(from, tokenId);\n        }\n        if (to == address(0)) {\n            _removeTokenFromAllTokensEnumeration(tokenId);\n        } else if (to != from) {\n            _addTokenToOwnerEnumeration(to, tokenId);\n        }\n    }\n\n    /**\n     * @dev Private function to add a token to this extension's ownership-tracking data structures.\n     * @param to address representing the new owner of the given token ID\n     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address\n     */\n    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {\n        uint256 length = ERC721.balanceOf(to);\n        _ownedTokens[to][length] = tokenId;\n        _ownedTokensIndex[tokenId] = length;\n    }\n\n    /**\n     * @dev Private function to add a token to this extension's token tracking data structures.\n     * @param tokenId uint256 ID of the token to be added to the tokens list\n     */\n    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {\n        _allTokensIndex[tokenId] = _allTokens.length;\n        _allTokens.push(tokenId);\n    }\n\n    /**\n     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that\n     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for\n     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).\n     * This has O(1) time complexity, but alters the order of the _ownedTokens array.\n     * @param from address representing the previous owner of the given token ID\n     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address\n     */\n    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {\n        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and\n        // then delete the last slot (swap and pop).\n\n        uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;\n        uint256 tokenIndex = _ownedTokensIndex[tokenId];\n\n        // When the token to delete is the last token, the swap operation is unnecessary\n        if (tokenIndex != lastTokenIndex) {\n            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];\n\n            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n        }\n\n        // This also deletes the contents at the last position of the array\n        delete _ownedTokensIndex[tokenId];\n        delete _ownedTokens[from][lastTokenIndex];\n    }\n\n    /**\n     * @dev Private function to remove a token from this extension's token tracking data structures.\n     * This has O(1) time complexity, but alters the order of the _allTokens array.\n     * @param tokenId uint256 ID of the token to be removed from the tokens list\n     */\n    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {\n        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and\n        // then delete the last slot (swap and pop).\n\n        uint256 lastTokenIndex = _allTokens.length - 1;\n        uint256 tokenIndex = _allTokensIndex[tokenId];\n\n        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so\n        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding\n        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)\n        uint256 lastTokenId = _allTokens[lastTokenIndex];\n\n        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token\n        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index\n\n        // This also deletes the contents at the last position of the array\n        delete _allTokensIndex[tokenId];\n        _allTokens.pop();\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Enumerable is IERC721 {\n    /**\n     * @dev Returns the total amount of tokens stored by the contract.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.\n     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.\n     */\n    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);\n\n    /**\n     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.\n     * Use along with {totalSupply} to enumerate all tokens.\n     */\n    function tokenByIndex(uint256 index) external view returns (uint256);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC721.sol\";\n\n/**\n * @title ERC-721 Non-Fungible Token Standard, optional metadata extension\n * @dev See https://eips.ethereum.org/EIPS/eip-721\n */\ninterface IERC721Metadata is IERC721 {\n    /**\n     * @dev Returns the token collection name.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the token collection symbol.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.\n     */\n    function tokenURI(uint256 tokenId) external view returns (string memory);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the caller.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @title ERC721 token receiver interface\n * @dev Interface for any contract that wants to support safeTransfers\n * from ERC721 asset contracts.\n */\ninterface IERC721Receiver {\n    /**\n     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}\n     * by `operator` from `from`, this function is called.\n     *\n     * It must return its Solidity selector to confirm the token transfer.\n     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.\n     *\n     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(\n        address operator,\n        address from,\n        uint256 tokenId,\n        bytes calldata data\n    ) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://consensys.net/diligence/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.8.0/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(address target, bytes memory data, uint256 value) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\n        // Look for revert reason and bubble it up if present\n        if (returndata.length > 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"
      },
      "@openzeppelin/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"
      },
      "@openzeppelin/contracts/utils/Create2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Create2.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.\n * `CREATE2` can be used to compute in advance the address where a smart\n * contract will be deployed, which allows for interesting new mechanisms known\n * as 'counterfactual interactions'.\n *\n * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more\n * information.\n */\nlibrary Create2 {\n    /**\n     * @dev Deploys a contract using `CREATE2`. The address where the contract\n     * will be deployed can be known in advance via {computeAddress}.\n     *\n     * The bytecode for a contract can be obtained from Solidity with\n     * `type(contractName).creationCode`.\n     *\n     * Requirements:\n     *\n     * - `bytecode` must not be empty.\n     * - `salt` must have not been used for `bytecode` already.\n     * - the factory must have a balance of at least `amount`.\n     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.\n     */\n    function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {\n        require(address(this).balance >= amount, \"Create2: insufficient balance\");\n        require(bytecode.length != 0, \"Create2: bytecode length is zero\");\n        /// @solidity memory-safe-assembly\n        assembly {\n            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)\n        }\n        require(addr != address(0), \"Create2: Failed on deploy\");\n    }\n\n    /**\n     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the\n     * `bytecodeHash` or `salt` will result in a new destination address.\n     */\n    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {\n        return computeAddress(salt, bytecodeHash, address(this));\n    }\n\n    /**\n     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at\n     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.\n     */\n    function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40) // Get free memory pointer\n\n            // |                   | ↓ ptr ...  ↓ ptr + 0x0B (start) ...  ↓ ptr + 0x20 ...  ↓ ptr + 0x40 ...   |\n            // |-------------------|---------------------------------------------------------------------------|\n            // | bytecodeHash      |                                                        CCCCCCCCCCCCC...CC |\n            // | salt              |                                      BBBBBBBBBBBBB...BB                   |\n            // | deployer          | 000000...0000AAAAAAAAAAAAAAAAAAA...AA                                     |\n            // | 0xFF              |            FF                                                             |\n            // |-------------------|---------------------------------------------------------------------------|\n            // | memory            | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |\n            // | keccak(start, 85) |            ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |\n\n            mstore(add(ptr, 0x40), bytecodeHash)\n            mstore(add(ptr, 0x20), salt)\n            mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes\n            let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff\n            mstore8(start, 0xff)\n            addr := keccak256(start, 85)\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/cryptography/ECDSA.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/cryptography/ECDSA.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../Strings.sol\";\n\n/**\n * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.\n *\n * These functions can be used to verify that a message was signed by the holder\n * of the private keys of a given address.\n */\nlibrary ECDSA {\n    enum RecoverError {\n        NoError,\n        InvalidSignature,\n        InvalidSignatureLength,\n        InvalidSignatureS,\n        InvalidSignatureV // Deprecated in v4.8\n    }\n\n    function _throwError(RecoverError error) private pure {\n        if (error == RecoverError.NoError) {\n            return; // no error: do nothing\n        } else if (error == RecoverError.InvalidSignature) {\n            revert(\"ECDSA: invalid signature\");\n        } else if (error == RecoverError.InvalidSignatureLength) {\n            revert(\"ECDSA: invalid signature length\");\n        } else if (error == RecoverError.InvalidSignatureS) {\n            revert(\"ECDSA: invalid signature 's' value\");\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature` or error string. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     *\n     * Documentation for signature generation:\n     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]\n     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {\n        if (signature.length == 65) {\n            bytes32 r;\n            bytes32 s;\n            uint8 v;\n            // ecrecover takes the signature parameters, and the only way to get them\n            // currently is to use assembly.\n            /// @solidity memory-safe-assembly\n            assembly {\n                r := mload(add(signature, 0x20))\n                s := mload(add(signature, 0x40))\n                v := byte(0, mload(add(signature, 0x60)))\n            }\n            return tryRecover(hash, v, r, s);\n        } else {\n            return (address(0), RecoverError.InvalidSignatureLength);\n        }\n    }\n\n    /**\n     * @dev Returns the address that signed a hashed message (`hash`) with\n     * `signature`. This address can then be used for verification purposes.\n     *\n     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:\n     * this function rejects them by requiring the `s` value to be in the lower\n     * half order, and the `v` value to be either 27 or 28.\n     *\n     * IMPORTANT: `hash` _must_ be the result of a hash operation for the\n     * verification to be secure: it is possible to craft signatures that\n     * recover to arbitrary addresses for non-hashed data. A safe way to ensure\n     * this is by receiving a hash of the original message (which may otherwise\n     * be too long), and then calling {toEthSignedMessageHash} on it.\n     */\n    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, signature);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.\n     *\n     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address, RecoverError) {\n        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);\n        uint8 v = uint8((uint256(vs) >> 255) + 27);\n        return tryRecover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.\n     *\n     * _Available since v4.2._\n     */\n    function recover(bytes32 hash, bytes32 r, bytes32 vs) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, r, vs);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     *\n     * _Available since v4.3._\n     */\n    function tryRecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address, RecoverError) {\n        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature\n        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines\n        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most\n        // signatures from current libraries generate a unique signature with an s-value in the lower half order.\n        //\n        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value\n        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or\n        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept\n        // these malleable signatures as well.\n        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {\n            return (address(0), RecoverError.InvalidSignatureS);\n        }\n\n        // If the signature is valid (and not malleable), return the signer address\n        address signer = ecrecover(hash, v, r, s);\n        if (signer == address(0)) {\n            return (address(0), RecoverError.InvalidSignature);\n        }\n\n        return (signer, RecoverError.NoError);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) internal pure returns (address) {\n        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);\n        _throwError(error);\n        return recovered;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32 message) {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, \"\\x19Ethereum Signed Message:\\n32\")\n            mstore(0x1c, hash)\n            message := keccak256(0x00, 0x3c)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from `s`. This\n     * produces hash corresponding to the one signed with the\n     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]\n     * JSON-RPC method as part of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n\", Strings.toString(s.length), s));\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Typed Data, created from a\n     * `domainSeparator` and a `structHash`. This produces hash corresponding\n     * to the one signed with the\n     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]\n     * JSON-RPC method as part of EIP-712.\n     *\n     * See {recover}.\n     */\n    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32 data) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            let ptr := mload(0x40)\n            mstore(ptr, \"\\x19\\x01\")\n            mstore(add(ptr, 0x02), domainSeparator)\n            mstore(add(ptr, 0x22), structHash)\n            data := keccak256(ptr, 0x42)\n        }\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Data with intended validator, created from a\n     * `validator` and `data` according to the version 0 of EIP-191.\n     *\n     * See {recover}.\n     */\n    function toDataWithIntendedValidatorHash(address validator, bytes memory data) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x00\", validator, data));\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check\n * for the additional interface id that will be supported. For example:\n *\n * ```solidity\n * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);\n * }\n * ```\n *\n * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.\n */\nabstract contract ERC165 is IERC165 {\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[EIP].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      },
      "@openzeppelin/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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(uint256 x, uint256 y, uint256 denominator) 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                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\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(uint256 x, uint256 y, uint256 denominator, Rounding rounding) 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. If 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        //\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)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\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        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/math/SignedMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.8.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"
      },
      "@openzeppelin/contracts/utils/StorageSlot.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/StorageSlot.sol)\n// This file was procedurally generated from scripts/generate/templates/StorageSlot.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for reading and writing primitive types to specific storage slots.\n *\n * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.\n * This library helps with reading and writing to such slots without the need for inline assembly.\n *\n * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.\n *\n * Example usage to set ERC1967 implementation slot:\n * ```solidity\n * contract ERC1967 {\n *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;\n *\n *     function _getImplementation() internal view returns (address) {\n *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;\n *     }\n *\n *     function _setImplementation(address newImplementation) internal {\n *         require(Address.isContract(newImplementation), \"ERC1967: new implementation is not a contract\");\n *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;\n *     }\n * }\n * ```\n *\n * _Available since v4.1 for `address`, `bool`, `bytes32`, `uint256`._\n * _Available since v4.9 for `string`, `bytes`._\n */\nlibrary StorageSlot {\n    struct AddressSlot {\n        address value;\n    }\n\n    struct BooleanSlot {\n        bool value;\n    }\n\n    struct Bytes32Slot {\n        bytes32 value;\n    }\n\n    struct Uint256Slot {\n        uint256 value;\n    }\n\n    struct StringSlot {\n        string value;\n    }\n\n    struct BytesSlot {\n        bytes value;\n    }\n\n    /**\n     * @dev Returns an `AddressSlot` with member `value` located at `slot`.\n     */\n    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.\n     */\n    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.\n     */\n    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.\n     */\n    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` with member `value` located at `slot`.\n     */\n    function getStringSlot(bytes32 slot) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `StringSlot` representation of the string storage pointer `store`.\n     */\n    function getStringSlot(string storage store) internal pure returns (StringSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` with member `value` located at `slot`.\n     */\n    function getBytesSlot(bytes32 slot) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := slot\n        }\n    }\n\n    /**\n     * @dev Returns an `BytesSlot` representation of the bytes storage pointer `store`.\n     */\n    function getBytesSlot(bytes storage store) internal pure returns (BytesSlot storage r) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            r.slot := store.slot\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/Strings.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/Strings.sol)\n\npragma solidity ^0.8.0;\n\nimport \"./math/Math.sol\";\nimport \"./math/SignedMath.sol\";\n\n/**\n * @dev String operations.\n */\nlibrary Strings {\n    bytes16 private constant _SYMBOLS = \"0123456789abcdef\";\n    uint8 private constant _ADDRESS_LENGTH = 20;\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` decimal representation.\n     */\n    function toString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            uint256 length = Math.log10(value) + 1;\n            string memory buffer = new string(length);\n            uint256 ptr;\n            /// @solidity memory-safe-assembly\n            assembly {\n                ptr := add(buffer, add(32, length))\n            }\n            while (true) {\n                ptr--;\n                /// @solidity memory-safe-assembly\n                assembly {\n                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))\n                }\n                value /= 10;\n                if (value == 0) break;\n            }\n            return buffer;\n        }\n    }\n\n    /**\n     * @dev Converts a `int256` to its ASCII `string` decimal representation.\n     */\n    function toString(int256 value) internal pure returns (string memory) {\n        return string(abi.encodePacked(value < 0 ? \"-\" : \"\", toString(SignedMath.abs(value))));\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.\n     */\n    function toHexString(uint256 value) internal pure returns (string memory) {\n        unchecked {\n            return toHexString(value, Math.log256(value) + 1);\n        }\n    }\n\n    /**\n     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.\n     */\n    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {\n        bytes memory buffer = new bytes(2 * length + 2);\n        buffer[0] = \"0\";\n        buffer[1] = \"x\";\n        for (uint256 i = 2 * length + 1; i > 1; --i) {\n            buffer[i] = _SYMBOLS[value & 0xf];\n            value >>= 4;\n        }\n        require(value == 0, \"Strings: hex length insufficient\");\n        return string(buffer);\n    }\n\n    /**\n     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.\n     */\n    function toHexString(address addr) internal pure returns (string memory) {\n        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);\n    }\n\n    /**\n     * @dev Returns true if the two strings are equal.\n     */\n    function equal(string memory a, string memory b) internal pure returns (bool) {\n        return keccak256(bytes(a)) == keccak256(bytes(b));\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/structs/EnumerableMap.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableMap.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableMap.js.\n\npragma solidity ^0.8.0;\n\nimport \"./EnumerableSet.sol\";\n\n/**\n * @dev Library for managing an enumerable variant of Solidity's\n * https://solidity.readthedocs.io/en/latest/types.html#mapping-types[`mapping`]\n * type.\n *\n * Maps have the following properties:\n *\n * - Entries are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Entries are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableMap for EnumerableMap.UintToAddressMap;\n *\n *     // Declare a set state variable\n *     EnumerableMap.UintToAddressMap private myMap;\n * }\n * ```\n *\n * The following map types are supported:\n *\n * - `uint256 -> address` (`UintToAddressMap`) since v3.0.0\n * - `address -> uint256` (`AddressToUintMap`) since v4.6.0\n * - `bytes32 -> bytes32` (`Bytes32ToBytes32Map`) since v4.6.0\n * - `uint256 -> uint256` (`UintToUintMap`) since v4.7.0\n * - `bytes32 -> uint256` (`Bytes32ToUintMap`) since v4.7.0\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableMap, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableMap.\n * ====\n */\nlibrary EnumerableMap {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Map type with\n    // bytes32 keys and values.\n    // The Map implementation uses private functions, and user-facing\n    // implementations (such as Uint256ToAddressMap) are just wrappers around\n    // the underlying Map.\n    // This means that we can only create new EnumerableMaps for types that fit\n    // in bytes32.\n\n    struct Bytes32ToBytes32Map {\n        // Storage of keys\n        EnumerableSet.Bytes32Set _keys;\n        mapping(bytes32 => bytes32) _values;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(Bytes32ToBytes32Map storage map, bytes32 key, bytes32 value) internal returns (bool) {\n        map._values[key] = value;\n        return map._keys.add(key);\n    }\n\n    /**\n     * @dev Removes a key-value pair from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(Bytes32ToBytes32Map storage map, bytes32 key) internal returns (bool) {\n        delete map._values[key];\n        return map._keys.remove(key);\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool) {\n        return map._keys.contains(key);\n    }\n\n    /**\n     * @dev Returns the number of key-value pairs in the map. O(1).\n     */\n    function length(Bytes32ToBytes32Map storage map) internal view returns (uint256) {\n        return map._keys.length();\n    }\n\n    /**\n     * @dev Returns the key-value pair stored at position `index` in the map. O(1).\n     *\n     * Note that there are no guarantees on the ordering of entries inside the\n     * array, and it may change when more entries are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32ToBytes32Map storage map, uint256 index) internal view returns (bytes32, bytes32) {\n        bytes32 key = map._keys.at(index);\n        return (key, map._values[key]);\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bool, bytes32) {\n        bytes32 value = map._values[key];\n        if (value == bytes32(0)) {\n            return (contains(map, key), bytes32(0));\n        } else {\n            return (true, value);\n        }\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(Bytes32ToBytes32Map storage map, bytes32 key) internal view returns (bytes32) {\n        bytes32 value = map._values[key];\n        require(value != 0 || contains(map, key), \"EnumerableMap: nonexistent key\");\n        return value;\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        Bytes32ToBytes32Map storage map,\n        bytes32 key,\n        string memory errorMessage\n    ) internal view returns (bytes32) {\n        bytes32 value = map._values[key];\n        require(value != 0 || contains(map, key), errorMessage);\n        return value;\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(Bytes32ToBytes32Map storage map) internal view returns (bytes32[] memory) {\n        return map._keys.values();\n    }\n\n    // UintToUintMap\n\n    struct UintToUintMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(UintToUintMap storage map, uint256 key, uint256 value) internal returns (bool) {\n        return set(map._inner, bytes32(key), bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(UintToUintMap storage map, uint256 key) internal returns (bool) {\n        return remove(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(UintToUintMap storage map, uint256 key) internal view returns (bool) {\n        return contains(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(UintToUintMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintToUintMap storage map, uint256 index) internal view returns (uint256, uint256) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (uint256(key), uint256(value));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(UintToUintMap storage map, uint256 key) internal view returns (bool, uint256) {\n        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));\n        return (success, uint256(value));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(UintToUintMap storage map, uint256 key) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(key)));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(UintToUintMap storage map, uint256 key, string memory errorMessage) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(key), errorMessage));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(UintToUintMap storage map) internal view returns (uint256[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintToAddressMap\n\n    struct UintToAddressMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(UintToAddressMap storage map, uint256 key, address value) internal returns (bool) {\n        return set(map._inner, bytes32(key), bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(UintToAddressMap storage map, uint256 key) internal returns (bool) {\n        return remove(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(UintToAddressMap storage map, uint256 key) internal view returns (bool) {\n        return contains(map._inner, bytes32(key));\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(UintToAddressMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintToAddressMap storage map, uint256 index) internal view returns (uint256, address) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (uint256(key), address(uint160(uint256(value))));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(UintToAddressMap storage map, uint256 key) internal view returns (bool, address) {\n        (bool success, bytes32 value) = tryGet(map._inner, bytes32(key));\n        return (success, address(uint160(uint256(value))));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(UintToAddressMap storage map, uint256 key) internal view returns (address) {\n        return address(uint160(uint256(get(map._inner, bytes32(key)))));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        UintToAddressMap storage map,\n        uint256 key,\n        string memory errorMessage\n    ) internal view returns (address) {\n        return address(uint160(uint256(get(map._inner, bytes32(key), errorMessage))));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(UintToAddressMap storage map) internal view returns (uint256[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressToUintMap\n\n    struct AddressToUintMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(AddressToUintMap storage map, address key, uint256 value) internal returns (bool) {\n        return set(map._inner, bytes32(uint256(uint160(key))), bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(AddressToUintMap storage map, address key) internal returns (bool) {\n        return remove(map._inner, bytes32(uint256(uint160(key))));\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(AddressToUintMap storage map, address key) internal view returns (bool) {\n        return contains(map._inner, bytes32(uint256(uint160(key))));\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(AddressToUintMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressToUintMap storage map, uint256 index) internal view returns (address, uint256) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (address(uint160(uint256(key))), uint256(value));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(AddressToUintMap storage map, address key) internal view returns (bool, uint256) {\n        (bool success, bytes32 value) = tryGet(map._inner, bytes32(uint256(uint160(key))));\n        return (success, uint256(value));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(AddressToUintMap storage map, address key) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(uint256(uint160(key)))));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        AddressToUintMap storage map,\n        address key,\n        string memory errorMessage\n    ) internal view returns (uint256) {\n        return uint256(get(map._inner, bytes32(uint256(uint160(key))), errorMessage));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(AddressToUintMap storage map) internal view returns (address[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // Bytes32ToUintMap\n\n    struct Bytes32ToUintMap {\n        Bytes32ToBytes32Map _inner;\n    }\n\n    /**\n     * @dev Adds a key-value pair to a map, or updates the value for an existing\n     * key. O(1).\n     *\n     * Returns true if the key was added to the map, that is if it was not\n     * already present.\n     */\n    function set(Bytes32ToUintMap storage map, bytes32 key, uint256 value) internal returns (bool) {\n        return set(map._inner, key, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a map. O(1).\n     *\n     * Returns true if the key was removed from the map, that is if it was present.\n     */\n    function remove(Bytes32ToUintMap storage map, bytes32 key) internal returns (bool) {\n        return remove(map._inner, key);\n    }\n\n    /**\n     * @dev Returns true if the key is in the map. O(1).\n     */\n    function contains(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool) {\n        return contains(map._inner, key);\n    }\n\n    /**\n     * @dev Returns the number of elements in the map. O(1).\n     */\n    function length(Bytes32ToUintMap storage map) internal view returns (uint256) {\n        return length(map._inner);\n    }\n\n    /**\n     * @dev Returns the element stored at position `index` in the map. O(1).\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32ToUintMap storage map, uint256 index) internal view returns (bytes32, uint256) {\n        (bytes32 key, bytes32 value) = at(map._inner, index);\n        return (key, uint256(value));\n    }\n\n    /**\n     * @dev Tries to returns the value associated with `key`. O(1).\n     * Does not revert if `key` is not in the map.\n     */\n    function tryGet(Bytes32ToUintMap storage map, bytes32 key) internal view returns (bool, uint256) {\n        (bool success, bytes32 value) = tryGet(map._inner, key);\n        return (success, uint256(value));\n    }\n\n    /**\n     * @dev Returns the value associated with `key`. O(1).\n     *\n     * Requirements:\n     *\n     * - `key` must be in the map.\n     */\n    function get(Bytes32ToUintMap storage map, bytes32 key) internal view returns (uint256) {\n        return uint256(get(map._inner, key));\n    }\n\n    /**\n     * @dev Same as {get}, with a custom error message when `key` is not in the map.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryGet}.\n     */\n    function get(\n        Bytes32ToUintMap storage map,\n        bytes32 key,\n        string memory errorMessage\n    ) internal view returns (uint256) {\n        return uint256(get(map._inner, key, errorMessage));\n    }\n\n    /**\n     * @dev Return the an array containing all the keys\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the map grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function keys(Bytes32ToUintMap storage map) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = keys(map._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
      },
      "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (utils/structs/EnumerableSet.sol)\n// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```solidity\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n *\n * [WARNING]\n * ====\n * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure\n * unusable.\n * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.\n *\n * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an\n * array of EnumerableSet.\n * ====\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastValue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastValue;\n                // Update the index for the moved value\n                set._indexes[lastValue] = valueIndex; // Replace lastValue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        bytes32[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        /// @solidity memory-safe-assembly\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
      },
      "@openzeppelin/contracts/vendor/optimism/ICrossDomainMessenger.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (vendor/optimism/ICrossDomainMessenger.sol)\npragma solidity >0.5.0 <0.9.0;\n\n/**\n * @title ICrossDomainMessenger\n */\ninterface ICrossDomainMessenger {\n    /**********\n     * Events *\n     **********/\n\n    event SentMessage(address indexed target, address sender, bytes message, uint256 messageNonce, uint256 gasLimit);\n    event RelayedMessage(bytes32 indexed msgHash);\n    event FailedRelayedMessage(bytes32 indexed msgHash);\n\n    /*************\n     * Variables *\n     *************/\n\n    function xDomainMessageSender() external view returns (address);\n\n    /********************\n     * Public Functions *\n     ********************/\n\n    /**\n     * Sends a cross domain message to the target messenger.\n     * @param _target Target contract address.\n     * @param _message Message to send to the target.\n     * @param _gasLimit Gas limit for the provided message.\n     */\n    function sendMessage(address _target, bytes calldata _message, uint32 _gasLimit) external;\n}\n"
      },
      "contracts/client/GasRouter.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport {Router} from \"./Router.sol\";\nimport {StandardHookMetadata} from \"../hooks/libs/StandardHookMetadata.sol\";\n\nabstract contract GasRouter is Router {\n    // ============ Mutable Storage ============\n    mapping(uint32 => uint256) public destinationGas;\n\n    struct GasRouterConfig {\n        uint32 domain;\n        uint256 gas;\n    }\n\n    constructor(address _mailbox) Router(_mailbox) {}\n\n    /**\n     * @notice Sets the gas amount dispatched for each configured domain.\n     * @param gasConfigs The array of GasRouterConfig structs\n     */\n    function setDestinationGas(\n        GasRouterConfig[] calldata gasConfigs\n    ) external onlyOwner {\n        for (uint256 i = 0; i < gasConfigs.length; i += 1) {\n            _setDestinationGas(gasConfigs[i].domain, gasConfigs[i].gas);\n        }\n    }\n\n    /**\n     * @notice Sets the gas amount dispatched for each configured domain.\n     * @param domain The destination domain ID\n     * @param gas The gas limit\n     */\n    function setDestinationGas(uint32 domain, uint256 gas) external onlyOwner {\n        _setDestinationGas(domain, gas);\n    }\n\n    /**\n     * @notice Returns the gas payment required to dispatch a message to the given domain's router.\n     * @param _destinationDomain The domain of the router.\n     * @return _gasPayment Payment computed by the registered InterchainGasPaymaster.\n     */\n    function quoteGasPayment(\n        uint32 _destinationDomain\n    ) external view returns (uint256 _gasPayment) {\n        return _quoteDispatch(_destinationDomain, \"\");\n    }\n\n    function _metadata(\n        uint32 _destination\n    ) internal view virtual override returns (bytes memory) {\n        return\n            StandardHookMetadata.overrideGasLimit(destinationGas[_destination]);\n    }\n\n    function _setDestinationGas(uint32 domain, uint256 gas) internal {\n        destinationGas[domain] = gas;\n    }\n}\n"
      },
      "contracts/client/MailboxClient.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\n// ============ Internal Imports ============\nimport {IMailbox} from \"../interfaces/IMailbox.sol\";\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\nimport {IInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\nimport {Message} from \"../libs/Message.sol\";\n\n// ============ External Imports ============\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nabstract contract MailboxClient is OwnableUpgradeable {\n    using Message for bytes;\n\n    IMailbox public immutable mailbox;\n\n    uint32 public immutable localDomain;\n\n    IPostDispatchHook public hook;\n\n    IInterchainSecurityModule public interchainSecurityModule;\n\n    uint256[48] private __GAP; // gap for upgrade safety\n\n    // ============ Modifiers ============\n    modifier onlyContract(address _contract) {\n        require(\n            Address.isContract(_contract),\n            \"MailboxClient: invalid mailbox\"\n        );\n        _;\n    }\n\n    modifier onlyContractOrNull(address _contract) {\n        require(\n            Address.isContract(_contract) || _contract == address(0),\n            \"MailboxClient: invalid contract setting\"\n        );\n        _;\n    }\n\n    /**\n     * @notice Only accept messages from an Hyperlane Mailbox contract\n     */\n    modifier onlyMailbox() {\n        require(\n            msg.sender == address(mailbox),\n            \"MailboxClient: sender not mailbox\"\n        );\n        _;\n    }\n\n    constructor(address _mailbox) onlyContract(_mailbox) {\n        mailbox = IMailbox(_mailbox);\n        localDomain = mailbox.localDomain();\n        _transferOwnership(msg.sender);\n    }\n\n    /**\n     * @notice Sets the address of the application's custom hook.\n     * @param _hook The address of the hook contract.\n     */\n    function setHook(address _hook) public onlyContractOrNull(_hook) onlyOwner {\n        hook = IPostDispatchHook(_hook);\n    }\n\n    /**\n     * @notice Sets the address of the application's custom interchain security module.\n     * @param _module The address of the interchain security module contract.\n     */\n    function setInterchainSecurityModule(\n        address _module\n    ) public onlyContractOrNull(_module) onlyOwner {\n        interchainSecurityModule = IInterchainSecurityModule(_module);\n    }\n\n    // ======== Initializer =========\n    function _MailboxClient_initialize(\n        address _hook,\n        address _interchainSecurityModule,\n        address _owner\n    ) internal onlyInitializing {\n        __Ownable_init();\n        setHook(_hook);\n        setInterchainSecurityModule(_interchainSecurityModule);\n        _transferOwnership(_owner);\n    }\n\n    function _isLatestDispatched(bytes32 id) internal view returns (bool) {\n        return mailbox.latestDispatchedId() == id;\n    }\n\n    function _metadata(\n        uint32 /*_destinationDomain*/\n    ) internal view virtual returns (bytes memory) {\n        return \"\";\n    }\n\n    function _dispatch(\n        uint32 _destinationDomain,\n        bytes32 _recipient,\n        bytes memory _messageBody\n    ) internal virtual returns (bytes32) {\n        return\n            _dispatch(_destinationDomain, _recipient, msg.value, _messageBody);\n    }\n\n    function _dispatch(\n        uint32 _destinationDomain,\n        bytes32 _recipient,\n        uint256 _value,\n        bytes memory _messageBody\n    ) internal virtual returns (bytes32) {\n        return\n            mailbox.dispatch{value: _value}(\n                _destinationDomain,\n                _recipient,\n                _messageBody,\n                _metadata(_destinationDomain),\n                hook\n            );\n    }\n\n    function _quoteDispatch(\n        uint32 _destinationDomain,\n        bytes32 _recipient,\n        bytes memory _messageBody\n    ) internal view virtual returns (uint256) {\n        return\n            mailbox.quoteDispatch(\n                _destinationDomain,\n                _recipient,\n                _messageBody,\n                _metadata(_destinationDomain),\n                hook\n            );\n    }\n}\n"
      },
      "contracts/client/Router.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\n// ============ Internal Imports ============\nimport {IMessageRecipient} from \"../interfaces/IMessageRecipient.sol\";\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\nimport {IInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\nimport {MailboxClient} from \"./MailboxClient.sol\";\nimport {EnumerableMapExtended} from \"../libs/EnumerableMapExtended.sol\";\n\n// ============ External Imports ============\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\n\nabstract contract Router is MailboxClient, IMessageRecipient {\n    using EnumerableMapExtended for EnumerableMapExtended.UintToBytes32Map;\n    using Strings for uint32;\n\n    // ============ Mutable Storage ============\n    EnumerableMapExtended.UintToBytes32Map internal _routers;\n\n    uint256[48] private __GAP; // gap for upgrade safety\n\n    constructor(address _mailbox) MailboxClient(_mailbox) {}\n\n    // ============ External functions ============\n    function domains() external view returns (uint32[] memory) {\n        return _routers.uint32Keys();\n    }\n\n    /**\n     * @notice Returns the address of the Router contract for the given domain\n     * @param _domain The remote domain ID.\n     * @dev Returns 0 address if no router is enrolled for the given domain\n     * @return router The address of the Router contract for the given domain\n     */\n    function routers(uint32 _domain) public view virtual returns (bytes32) {\n        (, bytes32 _router) = _routers.tryGet(_domain);\n        return _router;\n    }\n\n    /**\n     * @notice Unregister the domain\n     * @param _domain The domain of the remote Application Router\n     */\n    function unenrollRemoteRouter(uint32 _domain) external virtual onlyOwner {\n        _unenrollRemoteRouter(_domain);\n    }\n\n    /**\n     * @notice Register the address of a Router contract for the same Application on a remote chain\n     * @param _domain The domain of the remote Application Router\n     * @param _router The address of the remote Application Router\n     */\n    function enrollRemoteRouter(\n        uint32 _domain,\n        bytes32 _router\n    ) external virtual onlyOwner {\n        _enrollRemoteRouter(_domain, _router);\n    }\n\n    /**\n     * @notice Batch version of `enrollRemoteRouter`\n     * @param _domains The domains of the remote Application Routers\n     * @param _addresses The addresses of the remote Application Routers\n     */\n    function enrollRemoteRouters(\n        uint32[] calldata _domains,\n        bytes32[] calldata _addresses\n    ) external virtual onlyOwner {\n        require(_domains.length == _addresses.length, \"!length\");\n        uint256 length = _domains.length;\n        for (uint256 i = 0; i < length; i += 1) {\n            _enrollRemoteRouter(_domains[i], _addresses[i]);\n        }\n    }\n\n    /**\n     * @notice Batch version of `unenrollRemoteRouter`\n     * @param _domains The domains of the remote Application Routers\n     */\n    function unenrollRemoteRouters(\n        uint32[] calldata _domains\n    ) external virtual onlyOwner {\n        uint256 length = _domains.length;\n        for (uint256 i = 0; i < length; i += 1) {\n            _unenrollRemoteRouter(_domains[i]);\n        }\n    }\n\n    /**\n     * @notice Handles an incoming message\n     * @param _origin The origin domain\n     * @param _sender The sender address\n     * @param _message The message\n     */\n    function handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message\n    ) external payable virtual override onlyMailbox {\n        bytes32 _router = _mustHaveRemoteRouter(_origin);\n        require(_router == _sender, \"Enrolled router does not match sender\");\n        _handle(_origin, _sender, _message);\n    }\n\n    // ============ Virtual functions ============\n    function _handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message\n    ) internal virtual;\n\n    // ============ Internal functions ============\n\n    /**\n     * @notice Set the router for a given domain\n     * @param _domain The domain\n     * @param _address The new router\n     */\n    function _enrollRemoteRouter(\n        uint32 _domain,\n        bytes32 _address\n    ) internal virtual {\n        _routers.set(_domain, _address);\n    }\n\n    /**\n     * @notice Remove the router for a given domain\n     * @param _domain The domain\n     */\n    function _unenrollRemoteRouter(uint32 _domain) internal virtual {\n        require(_routers.remove(_domain), _domainNotFoundError(_domain));\n    }\n\n    /**\n     * @notice Return true if the given domain / router is the address of a remote Application Router\n     * @param _domain The domain of the potential remote Application Router\n     * @param _address The address of the potential remote Application Router\n     */\n    function _isRemoteRouter(\n        uint32 _domain,\n        bytes32 _address\n    ) internal view returns (bool) {\n        return routers(_domain) == _address;\n    }\n\n    /**\n     * @notice Assert that the given domain has a Application Router registered and return its address\n     * @param _domain The domain of the chain for which to get the Application Router\n     * @return _router The address of the remote Application Router on _domain\n     */\n    function _mustHaveRemoteRouter(\n        uint32 _domain\n    ) internal view returns (bytes32) {\n        (bool contained, bytes32 _router) = _routers.tryGet(_domain);\n        require(contained, _domainNotFoundError(_domain));\n        return _router;\n    }\n\n    function _domainNotFoundError(\n        uint32 _domain\n    ) internal pure returns (string memory) {\n        return\n            string.concat(\n                \"No router enrolled for domain: \",\n                _domain.toString()\n            );\n    }\n\n    function _dispatch(\n        uint32 _destinationDomain,\n        bytes memory _messageBody\n    ) internal virtual returns (bytes32) {\n        return _dispatch(_destinationDomain, msg.value, _messageBody);\n    }\n\n    function _dispatch(\n        uint32 _destinationDomain,\n        uint256 _value,\n        bytes memory _messageBody\n    ) internal virtual returns (bytes32) {\n        bytes32 _router = _mustHaveRemoteRouter(_destinationDomain);\n        return\n            super._dispatch(_destinationDomain, _router, _value, _messageBody);\n    }\n\n    function _quoteDispatch(\n        uint32 _destinationDomain,\n        bytes memory _messageBody\n    ) internal view virtual returns (uint256) {\n        bytes32 _router = _mustHaveRemoteRouter(_destinationDomain);\n        return super._quoteDispatch(_destinationDomain, _router, _messageBody);\n    }\n}\n"
      },
      "contracts/hooks/aggregation/ERC5164Hook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {IMessageDispatcher} from \"../../interfaces/hooks/IMessageDispatcher.sol\";\nimport {AbstractMessageIdAuthHook} from \"../libs/AbstractMessageIdAuthHook.sol\";\n\n// ============ External Imports ============\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\n/**\n * @title 5164MessageHook\n * @notice Message hook to inform the 5164 ISM of messages published through\n * any of the 5164 adapters.\n */\ncontract ERC5164Hook is AbstractMessageIdAuthHook {\n    IMessageDispatcher public immutable dispatcher;\n\n    constructor(\n        address _mailbox,\n        uint32 _destinationDomain,\n        bytes32 _ism,\n        address _dispatcher\n    ) AbstractMessageIdAuthHook(_mailbox, _destinationDomain, _ism) {\n        require(\n            Address.isContract(_dispatcher),\n            \"ERC5164Hook: invalid dispatcher\"\n        );\n        dispatcher = IMessageDispatcher(_dispatcher);\n    }\n\n    // ============ Internal Functions ============\n\n    function _quoteDispatch(\n        bytes calldata,\n        bytes calldata\n    ) internal pure override returns (uint256) {\n        return 0; // EIP-5164 doesn't enforce a gas abstraction\n    }\n\n    function _sendMessageId(\n        bytes calldata,\n        /* metadata */\n        bytes memory payload\n    ) internal override {\n        require(msg.value == 0, \"ERC5164Hook: no value allowed\");\n        dispatcher.dispatchMessage(\n            destinationDomain,\n            TypeCasts.bytes32ToAddress(ism),\n            payload\n        );\n    }\n}\n"
      },
      "contracts/hooks/aggregation/StaticAggregationHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\nimport {AbstractPostDispatchHook} from \"../libs/AbstractPostDispatchHook.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {MetaProxy} from \"../../libs/MetaProxy.sol\";\n\ncontract StaticAggregationHook is AbstractPostDispatchHook {\n    // ============ External functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.AGGREGATION);\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal override {\n        address[] memory _hooks = hooks(message);\n        uint256 count = _hooks.length;\n        for (uint256 i = 0; i < count; i++) {\n            uint256 quote = IPostDispatchHook(_hooks[i]).quoteDispatch(\n                metadata,\n                message\n            );\n\n            IPostDispatchHook(_hooks[i]).postDispatch{value: quote}(\n                metadata,\n                message\n            );\n        }\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal view override returns (uint256) {\n        address[] memory _hooks = hooks(message);\n        uint256 count = _hooks.length;\n        uint256 total = 0;\n        for (uint256 i = 0; i < count; i++) {\n            total += IPostDispatchHook(_hooks[i]).quoteDispatch(\n                metadata,\n                message\n            );\n        }\n        return total;\n    }\n\n    function hooks(bytes calldata) public pure returns (address[] memory) {\n        return abi.decode(MetaProxy.metadata(), (address[]));\n    }\n}\n"
      },
      "contracts/hooks/aggregation/StaticAggregationHookFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {StaticAggregationHook} from \"./StaticAggregationHook.sol\";\nimport {StaticAddressSetFactory} from \"../../libs/StaticAddressSetFactory.sol\";\n\ncontract StaticAggregationHookFactory is StaticAddressSetFactory {\n    function _deployImplementation()\n        internal\n        virtual\n        override\n        returns (address)\n    {\n        return address(new StaticAggregationHook());\n    }\n}\n"
      },
      "contracts/hooks/igp/InterchainGasPaymaster.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {Message} from \"../../libs/Message.sol\";\nimport {StandardHookMetadata} from \"../libs/StandardHookMetadata.sol\";\nimport {IGasOracle} from \"../../interfaces/IGasOracle.sol\";\nimport {IInterchainGasPaymaster} from \"../../interfaces/IInterchainGasPaymaster.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {AbstractPostDispatchHook} from \"../libs/AbstractPostDispatchHook.sol\";\nimport {Indexed} from \"../../libs/Indexed.sol\";\n\n// ============ External Imports ============\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\n/**\n * @title InterchainGasPaymaster\n * @notice Manages payments on a source chain to cover gas costs of relaying\n * messages to destination chains and includes the gas overhead per destination\n * @dev The intended use of this contract is to store overhead gas amounts for destination\n * domains, e.g. Mailbox and ISM gas usage, such that users of this IGP are only required\n * to specify the gas amount used by their own applications.\n */\ncontract InterchainGasPaymaster is\n    IInterchainGasPaymaster,\n    AbstractPostDispatchHook,\n    IGasOracle,\n    Indexed,\n    OwnableUpgradeable\n{\n    using Address for address payable;\n    using Message for bytes;\n    using StandardHookMetadata for bytes;\n    // ============ Constants ============\n\n    /// @notice The scale of gas oracle token exchange rates.\n    uint256 internal constant TOKEN_EXCHANGE_RATE_SCALE = 1e10;\n    /// @notice default for user call if metadata not provided\n    uint256 internal immutable DEFAULT_GAS_USAGE = 50_000;\n\n    // ============ Public Storage ============\n\n    /// @notice Destination domain => gas oracle and overhead gas amount.\n    mapping(uint32 => DomainGasConfig) public destinationGasConfigs;\n\n    /// @notice The benficiary that can receive native tokens paid into this contract.\n    address public beneficiary;\n\n    // ============ Events ============\n\n    /**\n     * @notice Emitted when the gas oracle for a remote domain is set.\n     * @param remoteDomain The remote domain.\n     * @param gasOracle The gas oracle.\n     * @param gasOverhead The destination gas overhead.\n     */\n    event DestinationGasConfigSet(\n        uint32 remoteDomain,\n        address gasOracle,\n        uint96 gasOverhead\n    );\n\n    /**\n     * @notice Emitted when the beneficiary is set.\n     * @param beneficiary The new beneficiary.\n     */\n    event BeneficiarySet(address beneficiary);\n\n    struct DomainGasConfig {\n        IGasOracle gasOracle;\n        uint96 gasOverhead;\n    }\n\n    struct GasParam {\n        uint32 remoteDomain;\n        DomainGasConfig config;\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.INTERCHAIN_GAS_PAYMASTER);\n    }\n\n    /**\n     * @param _owner The owner of the contract.\n     * @param _beneficiary The beneficiary.\n     */\n    function initialize(\n        address _owner,\n        address _beneficiary\n    ) public initializer {\n        __Ownable_init();\n        _transferOwnership(_owner);\n        _setBeneficiary(_beneficiary);\n    }\n\n    /**\n     * @notice Transfers the entire native token balance to the beneficiary.\n     * @dev The beneficiary must be able to receive native tokens.\n     */\n    function claim() external {\n        // Transfer the entire balance to the beneficiary.\n        (bool success, ) = beneficiary.call{value: address(this).balance}(\"\");\n        require(success, \"IGP: claim failed\");\n    }\n\n    /**\n     * @notice Sets the gas oracles for remote domains specified in the config array.\n     * @param _configs An array of configs including the remote domain and gas oracles to set.\n     */\n    function setDestinationGasConfigs(\n        GasParam[] calldata _configs\n    ) external onlyOwner {\n        uint256 _len = _configs.length;\n        for (uint256 i = 0; i < _len; i++) {\n            _setDestinationGasConfig(\n                _configs[i].remoteDomain,\n                _configs[i].config.gasOracle,\n                _configs[i].config.gasOverhead\n            );\n        }\n    }\n\n    /**\n     * @notice Sets the beneficiary.\n     * @param _beneficiary The new beneficiary.\n     */\n    function setBeneficiary(address _beneficiary) external onlyOwner {\n        _setBeneficiary(_beneficiary);\n    }\n\n    // ============ Public Functions ============\n\n    /**\n     * @notice Deposits msg.value as a payment for the relaying of a message\n     * to its destination chain.\n     * @dev Overpayment will result in a refund of native tokens to the _refundAddress.\n     * Callers should be aware that this may present reentrancy issues.\n     * @param _messageId The ID of the message to pay for.\n     * @param _destinationDomain The domain of the message's destination chain.\n     * @param _gasLimit The amount of destination gas to pay for.\n     * @param _refundAddress The address to refund any overpayment to.\n     */\n    function payForGas(\n        bytes32 _messageId,\n        uint32 _destinationDomain,\n        uint256 _gasLimit,\n        address _refundAddress\n    ) public payable override {\n        uint256 _requiredPayment = quoteGasPayment(\n            _destinationDomain,\n            _gasLimit\n        );\n        require(\n            msg.value >= _requiredPayment,\n            \"IGP: insufficient interchain gas payment\"\n        );\n        uint256 _overpayment = msg.value - _requiredPayment;\n        if (_overpayment > 0) {\n            require(_refundAddress != address(0), \"no refund address\");\n            payable(_refundAddress).sendValue(_overpayment);\n        }\n\n        emit GasPayment(\n            _messageId,\n            _destinationDomain,\n            _gasLimit,\n            _requiredPayment\n        );\n    }\n\n    /**\n     * @notice Quotes the amount of native tokens to pay for interchain gas.\n     * @param _destinationDomain The domain of the message's destination chain.\n     * @param _gasLimit The amount of destination gas to pay for.\n     * @return The amount of native tokens required to pay for interchain gas.\n     */\n    function quoteGasPayment(\n        uint32 _destinationDomain,\n        uint256 _gasLimit\n    ) public view virtual override returns (uint256) {\n        // Get the gas data for the destination domain.\n        (\n            uint128 _tokenExchangeRate,\n            uint128 _gasPrice\n        ) = getExchangeRateAndGasPrice(_destinationDomain);\n\n        // The total cost quoted in destination chain's native token.\n        uint256 _destinationGasCost = _gasLimit * uint256(_gasPrice);\n\n        // Convert to the local native token.\n        return\n            (_destinationGasCost * _tokenExchangeRate) /\n            TOKEN_EXCHANGE_RATE_SCALE;\n    }\n\n    /**\n     * @notice Gets the token exchange rate and gas price from the configured gas oracle\n     * for a given destination domain.\n     * @param _destinationDomain The destination domain.\n     * @return tokenExchangeRate The exchange rate of the remote native token quoted in the local native token.\n     * @return gasPrice The gas price on the remote chain.\n     */\n    function getExchangeRateAndGasPrice(\n        uint32 _destinationDomain\n    )\n        public\n        view\n        override\n        returns (uint128 tokenExchangeRate, uint128 gasPrice)\n    {\n        IGasOracle _gasOracle = destinationGasConfigs[_destinationDomain]\n            .gasOracle;\n\n        require(\n            address(_gasOracle) != address(0),\n            string.concat(\n                \"Configured IGP doesn't support domain \",\n                Strings.toString(_destinationDomain)\n            )\n        );\n\n        return _gasOracle.getExchangeRateAndGasPrice(_destinationDomain);\n    }\n\n    /**\n     * @notice Returns the stored destinationGasOverhead added to the _gasLimit.\n     * @dev If there is no stored destinationGasOverhead, 0 is used. This is useful in the case\n     *      the ISM deployer wants to subsidize the overhead gas cost. Then, can specify the gas oracle\n     *      they want to use with the destination domain, but set the overhead to 0.\n     * @param _destinationDomain The domain of the message's destination chain.\n     * @param _gasLimit The amount of destination gas to pay for. This is only for application gas usage as\n     *      the gas usage for the mailbox and the ISM is already accounted in the DomainGasConfig.gasOverhead\n     */\n    function destinationGasLimit(\n        uint32 _destinationDomain,\n        uint256 _gasLimit\n    ) public view returns (uint256) {\n        return\n            uint256(destinationGasConfigs[_destinationDomain].gasOverhead) +\n            _gasLimit;\n    }\n\n    // ============ Internal Functions ============\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal override {\n        payForGas(\n            message.id(),\n            message.destination(),\n            destinationGasLimit(\n                message.destination(),\n                metadata.gasLimit(DEFAULT_GAS_USAGE)\n            ),\n            metadata.refundAddress(message.senderAddress())\n        );\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal view override returns (uint256) {\n        return\n            quoteGasPayment(\n                message.destination(),\n                destinationGasLimit(\n                    message.destination(),\n                    metadata.gasLimit(DEFAULT_GAS_USAGE)\n                )\n            );\n    }\n\n    /**\n     * @notice Sets the beneficiary.\n     * @param _beneficiary The new beneficiary.\n     */\n    function _setBeneficiary(address _beneficiary) internal {\n        beneficiary = _beneficiary;\n        emit BeneficiarySet(_beneficiary);\n    }\n\n    /**\n     * @notice Sets the gas oracle and destination gas overhead for a remote domain.\n     * @param _remoteDomain The remote domain.\n     * @param _gasOracle The gas oracle.\n     * @param _gasOverhead The destination gas overhead.\n     */\n    function _setDestinationGasConfig(\n        uint32 _remoteDomain,\n        IGasOracle _gasOracle,\n        uint96 _gasOverhead\n    ) internal {\n        destinationGasConfigs[_remoteDomain] = DomainGasConfig(\n            _gasOracle,\n            _gasOverhead\n        );\n        emit DestinationGasConfigSet(\n            _remoteDomain,\n            address(_gasOracle),\n            _gasOverhead\n        );\n    }\n}\n"
      },
      "contracts/hooks/igp/StorageGasOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {IGasOracle} from \"../../interfaces/IGasOracle.sol\";\n\n// ============ External Imports ============\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @notice A gas oracle that uses data stored within the contract.\n * @dev This contract is intended to be owned by an address that will\n * update the stored remote gas data.\n */\ncontract StorageGasOracle is IGasOracle, Ownable {\n    // ============ Public Storage ============\n\n    /// @notice Keyed by remote domain, gas data on that remote domain.\n    mapping(uint32 => IGasOracle.RemoteGasData) public remoteGasData;\n\n    // ============ Events ============\n\n    /**\n     * @notice Emitted when an entry in `remoteGasData` is set.\n     * @param remoteDomain The remote domain in which the gas data was set for.\n     * @param tokenExchangeRate The exchange rate of the remote native token quoted in the local native token.\n     * @param gasPrice The gas price on the remote chain.\n     */\n    event RemoteGasDataSet(\n        uint32 indexed remoteDomain,\n        uint128 tokenExchangeRate,\n        uint128 gasPrice\n    );\n\n    struct RemoteGasDataConfig {\n        uint32 remoteDomain;\n        uint128 tokenExchangeRate;\n        uint128 gasPrice;\n    }\n\n    // ============ External Functions ============\n\n    /**\n     * @notice Returns the stored `remoteGasData` for the `_destinationDomain`.\n     * @param _destinationDomain The destination domain.\n     * @return tokenExchangeRate The exchange rate of the remote native token quoted in the local native token.\n     * @return gasPrice The gas price on the remote chain.\n     */\n    function getExchangeRateAndGasPrice(\n        uint32 _destinationDomain\n    )\n        external\n        view\n        override\n        returns (uint128 tokenExchangeRate, uint128 gasPrice)\n    {\n        // Intentionally allow unset / zero values\n        IGasOracle.RemoteGasData memory _data = remoteGasData[\n            _destinationDomain\n        ];\n        return (_data.tokenExchangeRate, _data.gasPrice);\n    }\n\n    /**\n     * @notice Sets the remote gas data for many remotes at a time.\n     * @param _configs The configs to use when setting the remote gas data.\n     */\n    function setRemoteGasDataConfigs(\n        RemoteGasDataConfig[] calldata _configs\n    ) external onlyOwner {\n        uint256 _len = _configs.length;\n        for (uint256 i = 0; i < _len; i++) {\n            _setRemoteGasData(_configs[i]);\n        }\n    }\n\n    /**\n     * @notice Sets the remote gas data using the values in `_config`.\n     * @param _config The config to use when setting the remote gas data.\n     */\n    function setRemoteGasData(\n        RemoteGasDataConfig calldata _config\n    ) external onlyOwner {\n        _setRemoteGasData(_config);\n    }\n\n    // ============ Internal functions ============\n\n    /**\n     * @notice Sets the remote gas data using the values in `_config`.\n     * @param _config The config to use when setting the remote gas data.\n     */\n    function _setRemoteGasData(RemoteGasDataConfig calldata _config) internal {\n        remoteGasData[_config.remoteDomain] = IGasOracle.RemoteGasData({\n            tokenExchangeRate: _config.tokenExchangeRate,\n            gasPrice: _config.gasPrice\n        });\n\n        emit RemoteGasDataSet(\n            _config.remoteDomain,\n            _config.tokenExchangeRate,\n            _config.gasPrice\n        );\n    }\n}\n"
      },
      "contracts/hooks/layer-zero/LayerZeroV1Hook.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\nimport {ILayerZeroEndpoint} from \"@layerzerolabs/lz-evm-v1-0.7/contracts/interfaces/ILayerZeroEndpoint.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {MailboxClient} from \"../../client/MailboxClient.sol\";\nimport {Indexed} from \"../../libs/Indexed.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {AbstractPostDispatchHook} from \"../libs/AbstractPostDispatchHook.sol\";\nimport {StandardHookMetadata} from \"../libs/StandardHookMetadata.sol\";\n\nstruct LayerZeroMetadata {\n    /// @dev the destination chain identifier\n    uint16 dstChainId;\n    /// @dev the user app address on this EVM chain. Contract address that calls Endpoint.send(). Used for LZ user app config lookup\n    address userApplication;\n    /// @dev if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address\n    address refundAddress;\n    /// @dev the custom message to send over LayerZero\n    bytes payload;\n    /// @dev the address on destination chain (in bytes). A 40 length byte with remote and local addresses concatenated.\n    bytes destination;\n    /// @dev  parameters for the adapter service, e.g. send some dust native token to dstChain\n    bytes adapterParam;\n}\n\ncontract LayerZeroV1Hook is AbstractPostDispatchHook, MailboxClient {\n    using StandardHookMetadata for bytes;\n    using Message for bytes;\n    using TypeCasts for bytes32;\n\n    ILayerZeroEndpoint public immutable lZEndpoint;\n\n    constructor(address _mailbox, address _lZEndpoint) MailboxClient(_mailbox) {\n        lZEndpoint = ILayerZeroEndpoint(_lZEndpoint);\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.LAYER_ZERO_V1);\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal virtual override {\n        // ensure hook only dispatches messages that are dispatched by the mailbox\n        bytes32 id = message.id();\n        require(_isLatestDispatched(id), \"message not dispatched by mailbox\");\n\n        bytes calldata lZMetadata = metadata.getCustomMetadata();\n        LayerZeroMetadata memory layerZeroMetadata = parseLzMetadata(\n            lZMetadata\n        );\n        lZEndpoint.send{value: msg.value}(\n            layerZeroMetadata.dstChainId,\n            layerZeroMetadata.destination,\n            layerZeroMetadata.payload,\n            payable(layerZeroMetadata.refundAddress),\n            address(0), // _zroPaymentAddress is hardcoded to addr(0) because zro tokens should not be directly accepted\n            layerZeroMetadata.adapterParam\n        );\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata\n    ) internal view virtual override returns (uint256 nativeFee) {\n        bytes calldata lZMetadata = metadata.getCustomMetadata();\n        LayerZeroMetadata memory layerZeroMetadata = parseLzMetadata(\n            lZMetadata\n        );\n        (nativeFee, ) = lZEndpoint.estimateFees(\n            layerZeroMetadata.dstChainId,\n            layerZeroMetadata.userApplication,\n            layerZeroMetadata.payload,\n            false, // _payInZRO is hardcoded to false because zro tokens should not be directly accepted\n            layerZeroMetadata.adapterParam\n        );\n    }\n\n    /**\n     * @notice Formats LayerZero metadata using default abi encoding\n     * @param layerZeroMetadata LayerZero specific metadata\n     * @return ABI encoded metadata\n     */\n    function formatLzMetadata(\n        LayerZeroMetadata calldata layerZeroMetadata\n    ) public pure returns (bytes memory) {\n        return abi.encode(layerZeroMetadata);\n    }\n\n    /**\n     * @notice Decodes LayerZero metadata. Should be used after formatLzMetadata()\n     * @param lZMetadata ABI encoded metadata\n     */\n    function parseLzMetadata(\n        bytes calldata lZMetadata\n    ) public pure returns (LayerZeroMetadata memory parsedLayerZeroMetadata) {\n        (parsedLayerZeroMetadata) = abi.decode(lZMetadata, (LayerZeroMetadata));\n    }\n}\n"
      },
      "contracts/hooks/layer-zero/LayerZeroV2Hook.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\nimport {MessagingParams, MessagingFee, ILayerZeroEndpointV2} from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {Indexed} from \"../../libs/Indexed.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {AbstractMessageIdAuthHook} from \"../libs/AbstractMessageIdAuthHook.sol\";\nimport {StandardHookMetadata} from \"../libs/StandardHookMetadata.sol\";\n\nstruct LayerZeroV2Metadata {\n    /// @dev the endpoint Id. prev dstChainId\n    uint32 eid;\n    /// @dev if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address\n    address refundAddress;\n    /// @dev  parameters for the adapter service, e.g. send some dust native token to dstChain. prev adapterParam\n    bytes options;\n}\n\ncontract LayerZeroV2Hook is AbstractMessageIdAuthHook {\n    using StandardHookMetadata for bytes;\n    using Message for bytes;\n    using TypeCasts for bytes32;\n\n    ILayerZeroEndpointV2 public immutable lZEndpoint;\n\n    /// @dev offset for Layer Zero metadata parsing\n    uint8 constant EID_OFFSET = 0;\n    uint8 constant REFUND_ADDRESS_OFFSET = 4;\n    uint8 constant OPTIONS_OFFSET = 24;\n\n    constructor(\n        address _mailbox,\n        uint32 _destinationDomain,\n        bytes32 _ism,\n        address _lZEndpoint\n    ) AbstractMessageIdAuthHook(_mailbox, _destinationDomain, _ism) {\n        lZEndpoint = ILayerZeroEndpointV2(_lZEndpoint);\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc AbstractMessageIdAuthHook\n    function _sendMessageId(\n        bytes calldata metadata,\n        bytes memory payload\n    ) internal override {\n        bytes calldata lZMetadata = metadata.getCustomMetadata();\n        (\n            uint32 eid,\n            address refundAddress,\n            bytes memory options\n        ) = parseLzMetadata(lZMetadata);\n\n        // Build and send message\n        MessagingParams memory msgParams = MessagingParams(\n            eid,\n            ism,\n            payload,\n            options,\n            false // payInLzToken\n        );\n        lZEndpoint.send{value: msg.value}(msgParams, refundAddress);\n    }\n\n    /// @dev payInZRO is hardcoded to false because zro tokens should not be directly accepted\n    function _quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal view virtual override returns (uint256) {\n        bytes calldata lZMetadata = metadata.getCustomMetadata();\n        (uint32 eid, , bytes memory options) = parseLzMetadata(lZMetadata);\n\n        // Build and quote message\n        MessagingParams memory msgParams = MessagingParams(\n            eid,\n            message.recipient(),\n            message.body(),\n            options,\n            false // payInLzToken\n        );\n        MessagingFee memory msgFee = lZEndpoint.quote(\n            msgParams,\n            message.senderAddress()\n        );\n\n        return msgFee.nativeFee;\n    }\n\n    /**\n     * @notice Formats LayerZero metadata using default abi encoding\n     * @param layerZeroMetadata LayerZero specific metadata\n     * @return ABI encoded metadata\n     */\n    function formatLzMetadata(\n        LayerZeroV2Metadata calldata layerZeroMetadata\n    ) public pure returns (bytes memory) {\n        return\n            abi.encodePacked(\n                layerZeroMetadata.eid,\n                layerZeroMetadata.refundAddress,\n                layerZeroMetadata.options\n            );\n    }\n\n    /**\n     * @notice Decodes LayerZero metadata. Should be used after formatLzMetadata()\n     * @param lZMetadata ABI encoded metadata\n     */\n    function parseLzMetadata(\n        bytes calldata lZMetadata\n    )\n        public\n        pure\n        returns (uint32 eid, address refundAddress, bytes memory options)\n    {\n        eid = uint32(bytes4(lZMetadata[EID_OFFSET:REFUND_ADDRESS_OFFSET]));\n        refundAddress = address(\n            bytes20(lZMetadata[REFUND_ADDRESS_OFFSET:OPTIONS_OFFSET])\n        );\n        options = lZMetadata[OPTIONS_OFFSET:];\n    }\n}\n"
      },
      "contracts/hooks/libs/AbstractMessageIdAuthHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {AbstractPostDispatchHook} from \"./AbstractPostDispatchHook.sol\";\nimport {AbstractMessageIdAuthorizedIsm} from \"../../isms/hook/AbstractMessageIdAuthorizedIsm.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {StandardHookMetadata} from \"./StandardHookMetadata.sol\";\nimport {MailboxClient} from \"../../client/MailboxClient.sol\";\n\n/**\n * @title AbstractMessageIdAuthHook\n * @notice Message hook to inform an Abstract Message ID ISM of messages published through\n * a third-party bridge.\n */\nabstract contract AbstractMessageIdAuthHook is\n    AbstractPostDispatchHook,\n    MailboxClient\n{\n    using StandardHookMetadata for bytes;\n    using Message for bytes;\n\n    // ============ Constants ============\n\n    // left-padded address for ISM to verify messages\n    bytes32 public immutable ism;\n    // Domain of chain on which the ISM is deployed\n    uint32 public immutable destinationDomain;\n\n    // ============ Constructor ============\n\n    constructor(\n        address _mailbox,\n        uint32 _destinationDomain,\n        bytes32 _ism\n    ) MailboxClient(_mailbox) {\n        require(_ism != bytes32(0), \"AbstractMessageIdAuthHook: invalid ISM\");\n        require(\n            _destinationDomain != 0,\n            \"AbstractMessageIdAuthHook: invalid destination domain\"\n        );\n        ism = _ism;\n        destinationDomain = _destinationDomain;\n    }\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure returns (uint8) {\n        return uint8(IPostDispatchHook.Types.ID_AUTH_ISM);\n    }\n\n    // ============ Internal functions ============\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal override {\n        bytes32 id = message.id();\n        require(\n            _isLatestDispatched(id),\n            \"AbstractMessageIdAuthHook: message not latest dispatched\"\n        );\n        require(\n            message.destination() == destinationDomain,\n            \"AbstractMessageIdAuthHook: invalid destination domain\"\n        );\n        require(\n            metadata.msgValue(0) < 2 ** 255,\n            \"AbstractMessageIdAuthHook: msgValue must be less than 2 ** 255\"\n        );\n        bytes memory payload = abi.encodeCall(\n            AbstractMessageIdAuthorizedIsm.verifyMessageId,\n            id\n        );\n        _sendMessageId(metadata, payload);\n    }\n\n    /**\n     * @notice Send a message to the ISM.\n     * @param metadata The metadata for the hook caller\n     * @param payload The payload for call to the ISM\n     */\n    function _sendMessageId(\n        bytes calldata metadata,\n        bytes memory payload\n    ) internal virtual;\n}\n"
      },
      "contracts/hooks/libs/AbstractPostDispatchHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {StandardHookMetadata} from \"./StandardHookMetadata.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\n\n/**\n * @title AbstractPostDispatch\n * @notice Abstract post dispatch hook supporting the current global hook metadata variant.\n */\nabstract contract AbstractPostDispatchHook is IPostDispatchHook {\n    using StandardHookMetadata for bytes;\n\n    // ============ External functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function supportsMetadata(\n        bytes calldata metadata\n    ) public pure virtual override returns (bool) {\n        return\n            metadata.length == 0 ||\n            metadata.variant() == StandardHookMetadata.VARIANT;\n    }\n\n    /// @inheritdoc IPostDispatchHook\n    function postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) external payable override {\n        require(\n            supportsMetadata(metadata),\n            \"AbstractPostDispatchHook: invalid metadata variant\"\n        );\n        _postDispatch(metadata, message);\n    }\n\n    /// @inheritdoc IPostDispatchHook\n    function quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) public view override returns (uint256) {\n        require(\n            supportsMetadata(metadata),\n            \"AbstractPostDispatchHook: invalid metadata variant\"\n        );\n        return _quoteDispatch(metadata, message);\n    }\n\n    // ============ Internal functions ============\n\n    /**\n     * @notice Post dispatch hook implementation.\n     * @param metadata The metadata of the message being dispatched.\n     * @param message The message being dispatched.\n     */\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal virtual;\n\n    /**\n     * @notice Quote dispatch hook implementation.\n     * @param metadata The metadata of the message being dispatched.\n     * @param message The message being dispatched.\n     * @return The quote for the dispatch.\n     */\n    function _quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal view virtual returns (uint256);\n}\n"
      },
      "contracts/hooks/libs/StandardHookMetadata.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n/**\n * Format of metadata:\n *\n * [0:2] variant\n * [2:34] msg.value\n * [34:66] Gas limit for message (IGP)\n * [66:86] Refund address for message (IGP)\n * [86:] Custom metadata\n */\nlibrary StandardHookMetadata {\n    struct Metadata {\n        uint16 variant;\n        uint256 msgValue;\n        uint256 gasLimit;\n        address refundAddress;\n    }\n\n    uint8 private constant VARIANT_OFFSET = 0;\n    uint8 private constant MSG_VALUE_OFFSET = 2;\n    uint8 private constant GAS_LIMIT_OFFSET = 34;\n    uint8 private constant REFUND_ADDRESS_OFFSET = 66;\n    uint256 private constant MIN_METADATA_LENGTH = 86;\n\n    uint16 public constant VARIANT = 1;\n\n    /**\n     * @notice Returns the variant of the metadata.\n     * @param _metadata ABI encoded standard hook metadata.\n     * @return variant of the metadata as uint8.\n     */\n    function variant(bytes calldata _metadata) internal pure returns (uint16) {\n        if (_metadata.length < VARIANT_OFFSET + 2) return 0;\n        return uint16(bytes2(_metadata[VARIANT_OFFSET:VARIANT_OFFSET + 2]));\n    }\n\n    /**\n     * @notice Returns the specified value for the message.\n     * @param _metadata ABI encoded standard hook metadata.\n     * @param _default Default fallback value.\n     * @return Value for the message as uint256.\n     */\n    function msgValue(\n        bytes calldata _metadata,\n        uint256 _default\n    ) internal pure returns (uint256) {\n        if (_metadata.length < MSG_VALUE_OFFSET + 32) return _default;\n        return\n            uint256(bytes32(_metadata[MSG_VALUE_OFFSET:MSG_VALUE_OFFSET + 32]));\n    }\n\n    /**\n     * @notice Returns the specified gas limit for the message.\n     * @param _metadata ABI encoded standard hook metadata.\n     * @param _default Default fallback gas limit.\n     * @return Gas limit for the message as uint256.\n     */\n    function gasLimit(\n        bytes calldata _metadata,\n        uint256 _default\n    ) internal pure returns (uint256) {\n        if (_metadata.length < GAS_LIMIT_OFFSET + 32) return _default;\n        return\n            uint256(bytes32(_metadata[GAS_LIMIT_OFFSET:GAS_LIMIT_OFFSET + 32]));\n    }\n\n    /**\n     * @notice Returns the specified refund address for the message.\n     * @param _metadata ABI encoded standard hook metadata.\n     * @param _default Default fallback refund address.\n     * @return Refund address for the message as address.\n     */\n    function refundAddress(\n        bytes calldata _metadata,\n        address _default\n    ) internal pure returns (address) {\n        if (_metadata.length < REFUND_ADDRESS_OFFSET + 20) return _default;\n        return\n            address(\n                bytes20(\n                    _metadata[REFUND_ADDRESS_OFFSET:REFUND_ADDRESS_OFFSET + 20]\n                )\n            );\n    }\n\n    /**\n     * @notice Returns any custom metadata.\n     * @param _metadata ABI encoded standard hook metadata.\n     * @return Custom metadata.\n     */\n    function getCustomMetadata(\n        bytes calldata _metadata\n    ) internal pure returns (bytes calldata) {\n        if (_metadata.length < MIN_METADATA_LENGTH) return _metadata[0:0];\n        return _metadata[MIN_METADATA_LENGTH:];\n    }\n\n    /**\n     * @notice Formats the specified gas limit and refund address into standard hook metadata.\n     * @param _msgValue msg.value for the message.\n     * @param _gasLimit Gas limit for the message.\n     * @param _refundAddress Refund address for the message.\n     * @param _customMetadata Additional metadata to include in the standard hook metadata.\n     * @return ABI encoded standard hook metadata.\n     */\n    function formatMetadata(\n        uint256 _msgValue,\n        uint256 _gasLimit,\n        address _refundAddress,\n        bytes memory _customMetadata\n    ) internal pure returns (bytes memory) {\n        return\n            abi.encodePacked(\n                VARIANT,\n                _msgValue,\n                _gasLimit,\n                _refundAddress,\n                _customMetadata\n            );\n    }\n\n    /**\n     * @notice Formats the specified gas limit and refund address into standard hook metadata.\n     * @param _msgValue msg.value for the message.\n     * @return ABI encoded standard hook metadata.\n     */\n    function overrideMsgValue(\n        uint256 _msgValue\n    ) internal view returns (bytes memory) {\n        return formatMetadata(_msgValue, uint256(0), msg.sender, \"\");\n    }\n\n    /**\n     * @notice Formats the specified gas limit and refund address into standard hook metadata.\n     * @param _gasLimit Gas limit for the message.\n     * @return ABI encoded standard hook metadata.\n     */\n    function overrideGasLimit(\n        uint256 _gasLimit\n    ) internal view returns (bytes memory) {\n        return formatMetadata(uint256(0), _gasLimit, msg.sender, \"\");\n    }\n\n    /**\n     * @notice Formats the specified refund address into standard hook metadata.\n     * @param _refundAddress Refund address for the message.\n     * @return ABI encoded standard hook metadata.\n     */\n    function overrideRefundAddress(\n        address _refundAddress\n    ) internal pure returns (bytes memory) {\n        return formatMetadata(uint256(0), uint256(0), _refundAddress, \"\");\n    }\n}\n"
      },
      "contracts/hooks/MerkleTreeHook.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\nimport {MerkleLib} from \"../libs/Merkle.sol\";\nimport {Message} from \"../libs/Message.sol\";\nimport {MailboxClient} from \"../client/MailboxClient.sol\";\nimport {Indexed} from \"../libs/Indexed.sol\";\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\nimport {AbstractPostDispatchHook} from \"./libs/AbstractPostDispatchHook.sol\";\nimport {StandardHookMetadata} from \"./libs/StandardHookMetadata.sol\";\n\ncontract MerkleTreeHook is AbstractPostDispatchHook, MailboxClient, Indexed {\n    using Message for bytes;\n    using MerkleLib for MerkleLib.Tree;\n    using StandardHookMetadata for bytes;\n\n    // An incremental merkle tree used to store outbound message IDs.\n    MerkleLib.Tree internal _tree;\n\n    event InsertedIntoTree(bytes32 messageId, uint32 index);\n\n    constructor(address _mailbox) MailboxClient(_mailbox) {}\n\n    // count cannot exceed 2**TREE_DEPTH, see MerkleLib.sol\n    function count() public view returns (uint32) {\n        return uint32(_tree.count);\n    }\n\n    function root() public view returns (bytes32) {\n        return _tree.root();\n    }\n\n    function tree() public view returns (MerkleLib.Tree memory) {\n        return _tree;\n    }\n\n    function latestCheckpoint() external view returns (bytes32, uint32) {\n        return (root(), count() - 1);\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.MERKLE_TREE);\n    }\n\n    // ============ Internal Functions ============\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata,\n        /*metadata*/\n        bytes calldata message\n    ) internal override {\n        require(msg.value == 0, \"MerkleTreeHook: no value expected\");\n\n        // ensure messages which were not dispatched are not inserted into the tree\n        bytes32 id = message.id();\n        require(_isLatestDispatched(id), \"message not dispatching\");\n\n        uint32 index = count();\n        _tree.insert(id);\n        emit InsertedIntoTree(id, index);\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _quoteDispatch(\n        bytes calldata,\n        /*metadata*/\n        bytes calldata /*message*/\n    ) internal pure override returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "contracts/hooks/OPStackHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {AbstractMessageIdAuthHook} from \"./libs/AbstractMessageIdAuthHook.sol\";\nimport {StandardHookMetadata} from \"./libs/StandardHookMetadata.sol\";\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\nimport {Message} from \"../libs/Message.sol\";\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\n\n// ============ External Imports ============\nimport {ICrossDomainMessenger} from \"../interfaces/optimism/ICrossDomainMessenger.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\n/**\n * @title OPStackHook\n * @notice Message hook to inform the OPStackIsm of messages published through\n * the native OPStack bridge.\n * @notice This works only for L1 -> L2 messages.\n */\ncontract OPStackHook is AbstractMessageIdAuthHook {\n    using StandardHookMetadata for bytes;\n\n    // ============ Constants ============\n\n    /// @notice messenger contract specified by the rollup\n    ICrossDomainMessenger public immutable l1Messenger;\n\n    // Gas limit for sending messages to L2\n    // First 1.92e6 gas is provided by Optimism, see more here:\n    // https://community.optimism.io/docs/developers/bridge/messaging/#for-l1-%E2%87%92-l2-transactions\n    uint32 internal constant GAS_LIMIT = 1_920_000;\n\n    // ============ Constructor ============\n\n    constructor(\n        address _mailbox,\n        uint32 _destinationDomain,\n        bytes32 _ism,\n        address _l1Messenger\n    ) AbstractMessageIdAuthHook(_mailbox, _destinationDomain, _ism) {\n        require(\n            Address.isContract(_l1Messenger),\n            \"OPStackHook: invalid messenger\"\n        );\n        l1Messenger = ICrossDomainMessenger(_l1Messenger);\n    }\n\n    // ============ Internal functions ============\n    function _quoteDispatch(\n        bytes calldata,\n        bytes calldata\n    ) internal pure override returns (uint256) {\n        return 0; // gas subsidized by the L2\n    }\n\n    /// @inheritdoc AbstractMessageIdAuthHook\n    function _sendMessageId(\n        bytes calldata metadata,\n        bytes memory payload\n    ) internal override {\n        require(\n            metadata.msgValue(0) < 2 ** 255,\n            \"OPStackHook: msgValue must be less than 2 ** 255\"\n        );\n        l1Messenger.sendMessage{value: metadata.msgValue(0)}(\n            TypeCasts.bytes32ToAddress(ism),\n            payload,\n            GAS_LIMIT\n        );\n    }\n}\n"
      },
      "contracts/hooks/PausableHook.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\nimport {AbstractPostDispatchHook} from \"./libs/AbstractPostDispatchHook.sol\";\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {Pausable} from \"@openzeppelin/contracts/security/Pausable.sol\";\n\ncontract PausableHook is AbstractPostDispatchHook, Ownable, Pausable {\n    // ============ External functions ============\n\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.PAUSABLE);\n    }\n\n    // ============ Internal functions ============\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal override whenNotPaused {}\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _quoteDispatch(\n        bytes calldata,\n        bytes calldata\n    ) internal pure override returns (uint256) {\n        return 0;\n    }\n}\n"
      },
      "contracts/hooks/ProtocolFee.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {Message} from \"../libs/Message.sol\";\nimport {StandardHookMetadata} from \"./libs/StandardHookMetadata.sol\";\nimport {AbstractPostDispatchHook} from \"./libs/AbstractPostDispatchHook.sol\";\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\n\n// ============ External Imports ============\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\n/**\n * @title ProtocolFee\n * @notice Collects a static protocol fee from the sender.\n */\ncontract ProtocolFee is AbstractPostDispatchHook, Ownable {\n    using StandardHookMetadata for bytes;\n    using Address for address payable;\n    using Message for bytes;\n\n    // ============ Constants ============\n\n    /// @notice The maximum protocol fee that can be set.\n    uint256 public immutable MAX_PROTOCOL_FEE;\n\n    // ============ Public Storage ============\n\n    /// @notice The current protocol fee.\n    uint256 public protocolFee;\n    /// @notice The beneficiary of protocol fees.\n    address public beneficiary;\n\n    // ============ Constructor ============\n\n    constructor(\n        uint256 _maxProtocolFee,\n        uint256 _protocolFee,\n        address _beneficiary,\n        address _owner\n    ) {\n        MAX_PROTOCOL_FEE = _maxProtocolFee;\n        _setProtocolFee(_protocolFee);\n        _setBeneficiary(_beneficiary);\n        _transferOwnership(_owner);\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.PROTOCOL_FEE);\n    }\n\n    /**\n     * @notice Sets the protocol fee.\n     * @param _protocolFee The new protocol fee.\n     */\n    function setProtocolFee(uint256 _protocolFee) external onlyOwner {\n        _setProtocolFee(_protocolFee);\n    }\n\n    /**\n     * @notice Sets the beneficiary of protocol fees.\n     * @param _beneficiary The new beneficiary.\n     */\n    function setBeneficiary(address _beneficiary) external onlyOwner {\n        _setBeneficiary(_beneficiary);\n    }\n\n    /**\n     * @notice Collects protocol fees from the contract.\n     */\n    function collectProtocolFees() external {\n        payable(beneficiary).sendValue(address(this).balance);\n    }\n\n    // ============ Internal Functions ============\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal override {\n        require(\n            msg.value >= protocolFee,\n            \"ProtocolFee: insufficient protocol fee\"\n        );\n\n        uint256 refund = msg.value - protocolFee;\n        if (refund > 0) {\n            payable(metadata.refundAddress(message.senderAddress())).sendValue(\n                refund\n            );\n        }\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _quoteDispatch(\n        bytes calldata,\n        bytes calldata\n    ) internal view override returns (uint256) {\n        return protocolFee;\n    }\n\n    /**\n     * @notice Sets the protocol fee.\n     * @param _protocolFee The new protocol fee.\n     */\n    function _setProtocolFee(uint256 _protocolFee) internal {\n        require(\n            _protocolFee <= MAX_PROTOCOL_FEE,\n            \"ProtocolFee: exceeds max protocol fee\"\n        );\n        protocolFee = _protocolFee;\n    }\n\n    /**\n     * @notice Sets the beneficiary of protocol fees.\n     * @param _beneficiary The new beneficiary.\n     */\n    function _setBeneficiary(address _beneficiary) internal {\n        require(_beneficiary != address(0), \"ProtocolFee: invalid beneficiary\");\n        beneficiary = _beneficiary;\n    }\n}\n"
      },
      "contracts/hooks/routing/DestinationRecipientRoutingHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\nimport {Message} from \"../../libs/Message.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {DomainRoutingHook} from \"./DomainRoutingHook.sol\";\n\ncontract DestinationRecipientRoutingHook is DomainRoutingHook {\n    using Message for bytes;\n\n    /// @notice destination => recipient =>custom hook\n    mapping(uint32 => mapping(bytes32 => address)) public customHooks;\n\n    constructor(\n        address mailbox,\n        address owner\n    ) DomainRoutingHook(mailbox, owner) {}\n\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal override {\n        address customHookPreset = customHooks[message.destination()][\n            message.recipient()\n        ];\n        if (customHookPreset != address(0)) {\n            IPostDispatchHook(customHookPreset).postDispatch{value: msg.value}(\n                metadata,\n                message\n            );\n        } else {\n            super._postDispatch(metadata, message);\n        }\n    }\n\n    function configCustomHook(\n        uint32 destinationDomain,\n        bytes32 recipient,\n        address hook\n    ) external onlyOwner {\n        customHooks[destinationDomain][recipient] = hook;\n    }\n}\n"
      },
      "contracts/hooks/routing/DomainRoutingHook.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {AbstractPostDispatchHook} from \"../libs/AbstractPostDispatchHook.sol\";\nimport {MailboxClient} from \"../../client/MailboxClient.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\n\n// ============ External Imports ============\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\n\n/**\n * @title DomainRoutingHook\n * @notice Delegates to a hook based on the destination domain of the message.\n */\ncontract DomainRoutingHook is AbstractPostDispatchHook, MailboxClient {\n    using Strings for uint32;\n    using Message for bytes;\n\n    struct HookConfig {\n        uint32 destination;\n        address hook;\n    }\n\n    mapping(uint32 => IPostDispatchHook) public hooks;\n\n    constructor(address _mailbox, address _owner) MailboxClient(_mailbox) {\n        _transferOwnership(_owner);\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure virtual override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.ROUTING);\n    }\n\n    function setHook(uint32 _destination, address _hook) public onlyOwner {\n        hooks[_destination] = IPostDispatchHook(_hook);\n    }\n\n    function setHooks(HookConfig[] calldata configs) external onlyOwner {\n        for (uint256 i = 0; i < configs.length; i++) {\n            setHook(configs[i].destination, configs[i].hook);\n        }\n    }\n\n    function supportsMetadata(\n        bytes calldata\n    ) public pure virtual override returns (bool) {\n        // routing hook does not care about metadata shape\n        return true;\n    }\n\n    // ============ Internal Functions ============\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal virtual override {\n        _getConfiguredHook(message).postDispatch{value: msg.value}(\n            metadata,\n            message\n        );\n    }\n\n    /// @inheritdoc AbstractPostDispatchHook\n    function _quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) internal view virtual override returns (uint256) {\n        return _getConfiguredHook(message).quoteDispatch(metadata, message);\n    }\n\n    function _getConfiguredHook(\n        bytes calldata message\n    ) internal view virtual returns (IPostDispatchHook hook) {\n        hook = hooks[message.destination()];\n        require(\n            address(hook) != address(0),\n            string.concat(\n                \"No hook configured for destination: \",\n                message.destination().toString()\n            )\n        );\n    }\n}\n"
      },
      "contracts/hooks/routing/FallbackDomainRoutingHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\nimport {IPostDispatchHook} from \"../../interfaces/hooks/IPostDispatchHook.sol\";\nimport {IMailbox} from \"../../interfaces/IMailbox.sol\";\nimport {DomainRoutingHook} from \"./DomainRoutingHook.sol\";\nimport {Message} from \"../../libs/Message.sol\";\n\n/**\n * @title FallbackDomainRoutingHook\n * @notice Delegates to a hook based on the destination domain of the message.\n * If no hook is configured for the destination domain, delegates to a fallback hook.\n */\ncontract FallbackDomainRoutingHook is DomainRoutingHook {\n    using Message for bytes;\n\n    IPostDispatchHook public immutable fallbackHook;\n\n    constructor(\n        address _mailbox,\n        address _owner,\n        address _fallback\n    ) DomainRoutingHook(_mailbox, _owner) {\n        fallbackHook = IPostDispatchHook(_fallback);\n    }\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.FALLBACK_ROUTING);\n    }\n\n    // ============ Internal Functions ============\n\n    function _getConfiguredHook(\n        bytes calldata message\n    ) internal view override returns (IPostDispatchHook) {\n        IPostDispatchHook _hook = hooks[message.destination()];\n        if (address(_hook) == address(0)) {\n            _hook = fallbackHook;\n        }\n        return _hook;\n    }\n}\n"
      },
      "contracts/interfaces/hooks/IMessageDispatcher.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * @title ERC-5164: Cross-Chain Execution Standard\n * @dev See https://eips.ethereum.org/EIPS/eip-5164\n */\ninterface IMessageDispatcher {\n    /**\n     * @notice Emitted when a message has successfully been dispatched to the executor chain.\n     * @param messageId ID uniquely identifying the message\n     * @param from Address that dispatched the message\n     * @param toChainId ID of the chain receiving the message\n     * @param to Address that will receive the message\n     * @param data Data that was dispatched\n     */\n    event MessageDispatched(\n        bytes32 indexed messageId,\n        address indexed from,\n        uint256 indexed toChainId,\n        address to,\n        bytes data\n    );\n\n    function dispatchMessage(\n        uint256 toChainId,\n        address to,\n        bytes calldata data\n    ) external returns (bytes32);\n}\n"
      },
      "contracts/interfaces/hooks/IPostDispatchHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\ninterface IPostDispatchHook {\n    enum Types {\n        UNUSED,\n        ROUTING,\n        AGGREGATION,\n        MERKLE_TREE,\n        INTERCHAIN_GAS_PAYMASTER,\n        FALLBACK_ROUTING,\n        ID_AUTH_ISM,\n        PAUSABLE,\n        PROTOCOL_FEE,\n        LAYER_ZERO_V1\n    }\n\n    /**\n     * @notice Returns an enum that represents the type of hook\n     */\n    function hookType() external view returns (uint8);\n\n    /**\n     * @notice Returns whether the hook supports metadata\n     * @param metadata metadata\n     * @return Whether the hook supports metadata\n     */\n    function supportsMetadata(\n        bytes calldata metadata\n    ) external view returns (bool);\n\n    /**\n     * @notice Post action after a message is dispatched via the Mailbox\n     * @param metadata The metadata required for the hook\n     * @param message The message passed from the Mailbox.dispatch() call\n     */\n    function postDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) external payable;\n\n    /**\n     * @notice Compute the payment required by the postDispatch call\n     * @param metadata The metadata required for the hook\n     * @param message The message passed from the Mailbox.dispatch() call\n     * @return Quoted payment for the postDispatch call\n     */\n    function quoteDispatch(\n        bytes calldata metadata,\n        bytes calldata message\n    ) external view returns (uint256);\n}\n"
      },
      "contracts/interfaces/IGasOracle.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\ninterface IGasOracle {\n    struct RemoteGasData {\n        // The exchange rate of the remote native token quoted in the local native token.\n        // Scaled with 10 decimals, i.e. 1e10 is \"one\".\n        uint128 tokenExchangeRate;\n        uint128 gasPrice;\n    }\n\n    function getExchangeRateAndGasPrice(\n        uint32 _destinationDomain\n    ) external view returns (uint128 tokenExchangeRate, uint128 gasPrice);\n}\n"
      },
      "contracts/interfaces/IInterchainGasPaymaster.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\n/**\n * @title IInterchainGasPaymaster\n * @notice Manages payments on a source chain to cover gas costs of relaying\n * messages to destination chains.\n */\ninterface IInterchainGasPaymaster {\n    /**\n     * @notice Emitted when a payment is made for a message's gas costs.\n     * @param messageId The ID of the message to pay for.\n     * @param destinationDomain The domain of the destination chain.\n     * @param gasAmount The amount of destination gas paid for.\n     * @param payment The amount of native tokens paid.\n     */\n    event GasPayment(\n        bytes32 indexed messageId,\n        uint32 indexed destinationDomain,\n        uint256 gasAmount,\n        uint256 payment\n    );\n\n    function payForGas(\n        bytes32 _messageId,\n        uint32 _destinationDomain,\n        uint256 _gasAmount,\n        address _refundAddress\n    ) external payable;\n\n    function quoteGasPayment(\n        uint32 _destinationDomain,\n        uint256 _gasAmount\n    ) external view returns (uint256);\n}\n"
      },
      "contracts/interfaces/IInterchainSecurityModule.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\ninterface IInterchainSecurityModule {\n    enum Types {\n        UNUSED,\n        ROUTING,\n        AGGREGATION,\n        LEGACY_MULTISIG,\n        MERKLE_ROOT_MULTISIG,\n        MESSAGE_ID_MULTISIG,\n        NULL, // used with relayer carrying no metadata\n        CCIP_READ\n    }\n\n    /**\n     * @notice Returns an enum that represents the type of security model\n     * encoded by this ISM.\n     * @dev Relayers infer how to fetch and format metadata.\n     */\n    function moduleType() external view returns (uint8);\n\n    /**\n     * @notice Defines a security model responsible for verifying interchain\n     * messages based on the provided metadata.\n     * @param _metadata Off-chain metadata provided by a relayer, specific to\n     * the security model encoded by the module (e.g. validator signatures)\n     * @param _message Hyperlane encoded interchain message\n     * @return True if the message was verified\n     */\n    function verify(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) external returns (bool);\n}\n\ninterface ISpecifiesInterchainSecurityModule {\n    function interchainSecurityModule()\n        external\n        view\n        returns (IInterchainSecurityModule);\n}\n"
      },
      "contracts/interfaces/ILiquidityLayerMessageRecipient.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\ninterface ILiquidityLayerMessageRecipient {\n    function handleWithTokens(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message,\n        address _token,\n        uint256 _amount\n    ) external;\n}\n"
      },
      "contracts/interfaces/ILiquidityLayerRouter.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\ninterface ILiquidityLayerRouter {\n    function dispatchWithTokens(\n        uint32 _destinationDomain,\n        bytes32 _recipientAddress,\n        address _token,\n        uint256 _amount,\n        string calldata _bridge,\n        bytes calldata _messageBody\n    ) external returns (bytes32);\n}\n"
      },
      "contracts/interfaces/IMailbox.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {IInterchainSecurityModule} from \"./IInterchainSecurityModule.sol\";\nimport {IPostDispatchHook} from \"./hooks/IPostDispatchHook.sol\";\n\ninterface IMailbox {\n    // ============ Events ============\n    /**\n     * @notice Emitted when a new message is dispatched via Hyperlane\n     * @param sender The address that dispatched the message\n     * @param destination The destination domain of the message\n     * @param recipient The message recipient address on `destination`\n     * @param message Raw bytes of message\n     */\n    event Dispatch(\n        address indexed sender,\n        uint32 indexed destination,\n        bytes32 indexed recipient,\n        bytes message\n    );\n\n    /**\n     * @notice Emitted when a new message is dispatched via Hyperlane\n     * @param messageId The unique message identifier\n     */\n    event DispatchId(bytes32 indexed messageId);\n\n    /**\n     * @notice Emitted when a Hyperlane message is processed\n     * @param messageId The unique message identifier\n     */\n    event ProcessId(bytes32 indexed messageId);\n\n    /**\n     * @notice Emitted when a Hyperlane message is delivered\n     * @param origin The origin domain of the message\n     * @param sender The message sender address on `origin`\n     * @param recipient The address that handled the message\n     */\n    event Process(\n        uint32 indexed origin,\n        bytes32 indexed sender,\n        address indexed recipient\n    );\n\n    function localDomain() external view returns (uint32);\n\n    function delivered(bytes32 messageId) external view returns (bool);\n\n    function defaultIsm() external view returns (IInterchainSecurityModule);\n\n    function defaultHook() external view returns (IPostDispatchHook);\n\n    function requiredHook() external view returns (IPostDispatchHook);\n\n    function latestDispatchedId() external view returns (bytes32);\n\n    function dispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody\n    ) external payable returns (bytes32 messageId);\n\n    function quoteDispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody\n    ) external view returns (uint256 fee);\n\n    function dispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata body,\n        bytes calldata defaultHookMetadata\n    ) external payable returns (bytes32 messageId);\n\n    function quoteDispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody,\n        bytes calldata defaultHookMetadata\n    ) external view returns (uint256 fee);\n\n    function dispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata body,\n        bytes calldata customHookMetadata,\n        IPostDispatchHook customHook\n    ) external payable returns (bytes32 messageId);\n\n    function quoteDispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody,\n        bytes calldata customHookMetadata,\n        IPostDispatchHook customHook\n    ) external view returns (uint256 fee);\n\n    function process(\n        bytes calldata metadata,\n        bytes calldata message\n    ) external payable;\n\n    function recipientIsm(\n        address recipient\n    ) external view returns (IInterchainSecurityModule module);\n}\n"
      },
      "contracts/interfaces/IMessageRecipient.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\ninterface IMessageRecipient {\n    function handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message\n    ) external payable;\n}\n"
      },
      "contracts/interfaces/IRouter.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\ninterface IRouter {\n    function domains() external view returns (uint32[] memory);\n\n    function routers(uint32 _domain) external view returns (bytes32);\n\n    function enrollRemoteRouter(uint32 _domain, bytes32 _router) external;\n\n    function enrollRemoteRouters(\n        uint32[] calldata _domains,\n        bytes32[] calldata _routers\n    ) external;\n}\n"
      },
      "contracts/interfaces/isms/IAggregationIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport {IInterchainSecurityModule} from \"../IInterchainSecurityModule.sol\";\n\ninterface IAggregationIsm is IInterchainSecurityModule {\n    /**\n     * @notice Returns the set of modules responsible for verifying _message\n     * and the number of modules that must verify\n     * @dev Can change based on the content of _message\n     * @param _message Hyperlane formatted interchain message\n     * @return modules The array of ISM addresses\n     * @return threshold The number of modules needed to verify\n     */\n    function modulesAndThreshold(\n        bytes calldata _message\n    ) external view returns (address[] memory modules, uint8 threshold);\n}\n"
      },
      "contracts/interfaces/isms/ICcipReadIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {IInterchainSecurityModule} from \"../IInterchainSecurityModule.sol\";\n\ninterface ICcipReadIsm is IInterchainSecurityModule {\n    /// @dev https://eips.ethereum.org/EIPS/eip-3668\n    /// @param sender the address of the contract making the call, usually address(this)\n    /// @param urls the URLs to query for offchain data\n    /// @param callData context needed for offchain service to service request\n    /// @param callbackFunction function selector to call with offchain information\n    /// @param extraData additional passthrough information to call callbackFunction with\n    error OffchainLookup(\n        address sender,\n        string[] urls,\n        bytes callData,\n        bytes4 callbackFunction,\n        bytes extraData\n    );\n\n    /**\n     * @notice Reverts with the data needed to query information offchain\n     * and be submitted via the origin mailbox\n     * @dev See https://eips.ethereum.org/EIPS/eip-3668 for more information\n     * @param _message data that will help construct the offchain query\n     */\n    function getOffchainVerifyInfo(bytes calldata _message) external view;\n}\n"
      },
      "contracts/interfaces/isms/IMultisigIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport {IInterchainSecurityModule} from \"../IInterchainSecurityModule.sol\";\n\ninterface IMultisigIsm is IInterchainSecurityModule {\n    /**\n     * @notice Returns the set of validators responsible for verifying _message\n     * and the number of signatures required\n     * @dev Can change based on the content of _message\n     * @param _message Hyperlane formatted interchain message\n     * @return validators The array of validator addresses\n     * @return threshold The number of validator signatures needed\n     */\n    function validatorsAndThreshold(\n        bytes calldata _message\n    ) external view returns (address[] memory validators, uint8 threshold);\n}\n"
      },
      "contracts/interfaces/isms/IRoutingIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {IInterchainSecurityModule} from \"../IInterchainSecurityModule.sol\";\n\ninterface IRoutingIsm is IInterchainSecurityModule {\n    /**\n     * @notice Returns the ISM responsible for verifying _message\n     * @dev Can change based on the content of _message\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     * @return module The ISM to use to verify _message\n     */\n    function route(\n        bytes calldata _message\n    ) external view returns (IInterchainSecurityModule);\n}\n"
      },
      "contracts/interfaces/IValidatorAnnounce.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\ninterface IValidatorAnnounce {\n    /// @notice Returns a list of validators that have made announcements\n    function getAnnouncedValidators() external view returns (address[] memory);\n\n    /**\n     * @notice Returns a list of all announced storage locations for `validators`\n     * @param _validators The list of validators to get storage locations for\n     * @return A list of announced storage locations\n     */\n    function getAnnouncedStorageLocations(\n        address[] calldata _validators\n    ) external view returns (string[][] memory);\n\n    /**\n     * @notice Announces a validator signature storage location\n     * @param _storageLocation Information encoding the location of signed\n     * checkpoints\n     * @param _signature The signed validator announcement\n     * @return True upon success\n     */\n    function announce(\n        address _validator,\n        string calldata _storageLocation,\n        bytes calldata _signature\n    ) external returns (bool);\n}\n"
      },
      "contracts/interfaces/optimism/ICrossDomainMessenger.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0;\n\n/**\n * @title ICrossDomainMessenger interface for bedrock update\n * @dev eth-optimism's version uses strict 0.8.15 which we don't want to restrict to\n */\ninterface ICrossDomainMessenger {\n    /**\n     * Sends a cross domain message to the target messenger.\n     * @param _target Target contract address.\n     * @param _message Message to send to the target.\n     * @param _gasLimit Gas limit for the provided message.\n     */\n    function sendMessage(\n        address _target,\n        bytes calldata _message,\n        uint32 _gasLimit\n    ) external payable;\n\n    function relayMessage(\n        uint256 _nonce,\n        address _sender,\n        address _target,\n        uint256 _value,\n        uint256 _minGasLimit,\n        bytes calldata _message\n    ) external payable;\n\n    function xDomainMessageSender() external view returns (address);\n\n    function OTHER_MESSENGER() external view returns (address);\n}\n\ninterface IL1CrossDomainMessenger is ICrossDomainMessenger {}\n\ninterface IL2CrossDomainMessenger is ICrossDomainMessenger {\n    function messageNonce() external view returns (uint256);\n}\n"
      },
      "contracts/isms/aggregation/AbstractAggregationIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ External Imports ============\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\n// ============ Internal Imports ============\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {IAggregationIsm} from \"../../interfaces/isms/IAggregationIsm.sol\";\nimport {AggregationIsmMetadata} from \"../../isms/libs/AggregationIsmMetadata.sol\";\n\n/**\n * @title AggregationIsm\n * @notice Manages per-domain m-of-n ISM sets that are used to verify\n * interchain messages.\n */\nabstract contract AbstractAggregationIsm is IAggregationIsm {\n    // ============ Constants ============\n\n    // solhint-disable-next-line const-name-snakecase\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.AGGREGATION);\n\n    // ============ Virtual Functions ============\n    // ======= OVERRIDE THESE TO IMPLEMENT =======\n\n    /**\n     * @notice Returns the set of ISMs responsible for verifying _message\n     * and the number of ISMs that must verify\n     * @dev Can change based on the content of _message\n     * @param _message Hyperlane formatted interchain message\n     * @return modules The array of ISM addresses\n     * @return threshold The number of ISMs needed to verify\n     */\n    function modulesAndThreshold(\n        bytes calldata _message\n    ) public view virtual returns (address[] memory, uint8);\n\n    // ============ Public Functions ============\n\n    /**\n     * @notice Requires that m-of-n ISMs verify the provided interchain message.\n     * @param _metadata ABI encoded module metadata (see AggregationIsmMetadata.sol)\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     */\n    function verify(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) public returns (bool) {\n        (address[] memory _isms, uint8 _threshold) = modulesAndThreshold(\n            _message\n        );\n        uint256 _count = _isms.length;\n        for (uint8 i = 0; i < _count; i++) {\n            if (!AggregationIsmMetadata.hasMetadata(_metadata, i)) continue;\n            IInterchainSecurityModule _ism = IInterchainSecurityModule(\n                _isms[i]\n            );\n            require(\n                _ism.verify(\n                    AggregationIsmMetadata.metadataAt(_metadata, i),\n                    _message\n                ),\n                \"!verify\"\n            );\n            _threshold -= 1;\n        }\n        require(_threshold == 0, \"!threshold\");\n        return true;\n    }\n}\n"
      },
      "contracts/isms/aggregation/StaticAggregationIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {AbstractAggregationIsm} from \"./AbstractAggregationIsm.sol\";\nimport {AggregationIsmMetadata} from \"../../isms/libs/AggregationIsmMetadata.sol\";\nimport {MetaProxy} from \"../../libs/MetaProxy.sol\";\n\n/**\n * @title StaticAggregationIsm\n * @notice Manages per-domain m-of-n ISM sets that are used to verify\n * interchain messages.\n */\ncontract StaticAggregationIsm is AbstractAggregationIsm {\n    // ============ Public Functions ============\n\n    /**\n     * @notice Returns the set of ISMs responsible for verifying _message\n     * and the number of ISMs that must verify\n     * @dev Can change based on the content of _message\n     * @return modules The array of ISM addresses\n     * @return threshold The number of ISMs needed to verify\n     */\n    function modulesAndThreshold(\n        bytes calldata\n    ) public view virtual override returns (address[] memory, uint8) {\n        return abi.decode(MetaProxy.metadata(), (address[], uint8));\n    }\n}\n"
      },
      "contracts/isms/aggregation/StaticAggregationIsmFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n// ============ Internal Imports ============\nimport {StaticAggregationIsm} from \"./StaticAggregationIsm.sol\";\nimport {StaticThresholdAddressSetFactory} from \"../../libs/StaticAddressSetFactory.sol\";\n\ncontract StaticAggregationIsmFactory is StaticThresholdAddressSetFactory {\n    function _deployImplementation()\n        internal\n        virtual\n        override\n        returns (address)\n    {\n        return address(new StaticAggregationIsm());\n    }\n}\n"
      },
      "contracts/isms/ccip-read/AbstractCcipReadIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {ICcipReadIsm} from \"../../interfaces/isms/ICcipReadIsm.sol\";\nimport {IMailbox} from \"../../interfaces/IMailbox.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {AbstractMultisigIsm} from \"../multisig/AbstractMultisigIsm.sol\";\n\n/**\n * @title AbstractCcipReadIsm\n * @notice An ISM that allows arbitrary payloads to be submitted and verified on chain\n * @dev https://eips.ethereum.org/EIPS/eip-3668\n * @dev The AbstractCcipReadIsm provided by Hyperlane is left intentionally minimalist as\n * the range of applications that could be supported by a CcipReadIsm are so broad. However\n * there are few things to note when building a custom CcipReadIsm.\n *\n * 1. `getOffchainVerifyInfo` should revert with a `OffchainLookup` error, which encodes\n *    the data necessary to query for offchain information\n * 2. For full CCIP Read specification compatibility, CcipReadIsm's should expose a function\n *    that in turn calls `process` on the configured Mailbox with the provided metadata and\n *    message. This functions selector should be provided as the `callbackFunction` payload\n *    for the OffchainLookup error\n */\nabstract contract AbstractCcipReadIsm is ICcipReadIsm {\n    // ============ Constants ============\n\n    // solhint-disable-next-line const-name-snakecase\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.CCIP_READ);\n}\n"
      },
      "contracts/isms/hook/AbstractMessageIdAuthorizedIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\n\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {LibBit} from \"../../libs/LibBit.sol\";\nimport {Message} from \"../../libs/Message.sol\";\n\n// ============ External Imports ============\n\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {Initializable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @title AbstractMessageIdAuthorizedIsm\n * @notice Uses external verification options to verify interchain messages which need a authorized caller\n */\nabstract contract AbstractMessageIdAuthorizedIsm is\n    IInterchainSecurityModule,\n    Initializable\n{\n    using Address for address payable;\n    using LibBit for uint256;\n    using Message for bytes;\n    // ============ Public Storage ============\n\n    /// @notice Maps messageId to whether or not the message has been verified\n    /// first bit is boolean for verification\n    /// rest of bits is the amount to send to the recipient\n    /// @dev bc of the bit packing, we can only send up to 2^255 wei\n    /// @dev the first bit is reserved for verification and the rest 255 bits are for the msg.value\n    mapping(bytes32 => uint256) public verifiedMessages;\n    /// @notice Index of verification bit in verifiedMessages\n    uint256 public constant VERIFIED_MASK_INDEX = 255;\n    /// @notice address for the authorized hook\n    bytes32 public authorizedHook;\n\n    // ============ Events ============\n\n    /// @notice Emitted when a message is received from the external bridge\n    event ReceivedMessage(bytes32 indexed messageId);\n\n    // ============ Initializer ============\n\n    function setAuthorizedHook(bytes32 _hook) external initializer {\n        require(\n            _hook != bytes32(0),\n            \"AbstractMessageIdAuthorizedIsm: invalid authorized hook\"\n        );\n        authorizedHook = _hook;\n    }\n\n    // ============ External Functions ============\n\n    /**\n     * @notice Verify a message was received by ISM.\n     * @param message Message to verify.\n     */\n    function verify(\n        bytes calldata,\n        /*_metadata*/\n        bytes calldata message\n    ) external returns (bool) {\n        bytes32 messageId = message.id();\n\n        // check for the first bit (used for verification)\n        bool verified = verifiedMessages[messageId].isBitSet(\n            VERIFIED_MASK_INDEX\n        );\n        // rest 255 bits contains the msg.value passed from the hook\n        if (verified) {\n            uint256 _msgValue = verifiedMessages[messageId].clearBit(\n                VERIFIED_MASK_INDEX\n            );\n            if (_msgValue > 0) {\n                verifiedMessages[messageId] -= _msgValue;\n                payable(message.recipientAddress()).sendValue(_msgValue);\n            }\n        }\n        return verified;\n    }\n\n    /**\n     * @notice Receive a message from the AbstractMessageIdAuthHook\n     * @dev Only callable by the authorized hook.\n     * @param messageId Hyperlane Id of the message.\n     */\n    function verifyMessageId(bytes32 messageId) public payable virtual {\n        require(\n            _isAuthorized(),\n            \"AbstractMessageIdAuthorizedIsm: sender is not the hook\"\n        );\n        require(\n            msg.value < 2 ** VERIFIED_MASK_INDEX,\n            \"AbstractMessageIdAuthorizedIsm: msg.value must be less than 2^255\"\n        );\n\n        verifiedMessages[messageId] = msg.value.setBit(VERIFIED_MASK_INDEX);\n        emit ReceivedMessage(messageId);\n    }\n\n    function _isAuthorized() internal view virtual returns (bool);\n}\n"
      },
      "contracts/isms/hook/ERC5164Ism.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\n\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {AbstractMessageIdAuthorizedIsm} from \"./AbstractMessageIdAuthorizedIsm.sol\";\n\n// ============ External Imports ============\n\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\n/**\n * @title ERC5164Ism\n * @notice Uses the generic eip-5164 standard to verify interchain messages.\n */\ncontract ERC5164Ism is AbstractMessageIdAuthorizedIsm {\n    // ============ Constants ============\n\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.NULL);\n    // corresponding 5164 executor address\n    address public immutable executor;\n\n    // ============ Constructor ============\n\n    constructor(address _executor) {\n        require(Address.isContract(_executor), \"ERC5164Ism: invalid executor\");\n        executor = _executor;\n    }\n\n    /**\n     * @notice Check if sender is authorized to message `verifyMessageId`.\n     */\n    function _isAuthorized() internal view override returns (bool) {\n        return msg.sender == executor;\n    }\n}\n"
      },
      "contracts/isms/hook/layer-zero/LayerZeroV2Ism.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\n\nimport {IInterchainSecurityModule} from \"../../../interfaces/IInterchainSecurityModule.sol\";\nimport {Message} from \"../../../libs/Message.sol\";\nimport {TypeCasts} from \"../../../libs/TypeCasts.sol\";\nimport {AbstractMessageIdAuthorizedIsm} from \"../AbstractMessageIdAuthorizedIsm.sol\";\n\n// ============ External Imports ============\nimport {Origin} from \"@layerzerolabs/lz-evm-protocol-v2/contracts/interfaces/ILayerZeroEndpointV2.sol\";\n\n/**\n * @title LayerZeroV2Ism\n * @notice Uses LayerZero V2 deliver and verify a messages Id\n */\ncontract LayerZeroV2Ism is AbstractMessageIdAuthorizedIsm {\n    using Message for bytes;\n    using TypeCasts for bytes32;\n\n    // Layerzero endpoint address\n    address public immutable endpoint;\n\n    // ============ Constants ============\n\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.NULL);\n\n    // @dev the offset of msg.data where the function parameters (as bytes) begins. 4 bytes is always used when encoding the function selector\n    uint8 constant FUNC_SELECTOR_OFFSET = 4;\n\n    // @dev the offset of msg.data where Origin.sender begins. 32 is always used since calldata comes in 32 bytes.\n    uint8 constant ORIGIN_SENDER_OFFSET = FUNC_SELECTOR_OFFSET + 32;\n\n    // ============ Constructor ============\n    constructor(address _endpoint) {\n        require(\n            _endpoint != address(0),\n            \"LayerZeroV2Ism: invalid authorized endpoint\"\n        );\n        endpoint = _endpoint;\n    }\n\n    /**\n     * @notice Entry point for receiving msg/packet from the LayerZero endpoint.\n     * @param _lzMessage The payload of the received message.\n     * @dev Authorization verification is done within verifyMessageId() -> _isAuthorized()\n     */\n    function lzReceive(\n        Origin calldata,\n        bytes32,\n        bytes calldata _lzMessage,\n        address,\n        bytes calldata\n    ) external payable {\n        verifyMessageId(_messageId(_lzMessage));\n    }\n\n    // ============ Internal function ============\n\n    /**\n     * @notice Slices the messageId from the message delivered from LayerZeroV2Hook\n     * @dev message is created as abi.encodeCall(AbstractMessageIdAuthorizedIsm.verifyMessageId, id)\n     * @dev _message will be 36 bytes (4 bytes for function selector, and 32 bytes for messageId)\n     */\n    function _messageId(\n        bytes calldata _message\n    ) internal pure returns (bytes32) {\n        return bytes32(_message[FUNC_SELECTOR_OFFSET:]);\n    }\n\n    /**\n     * @notice Validates criteria to verify a message\n     * @dev this is called by AbstractMessageIdAuthorizedIsm.verifyMessageId\n     * @dev parses msg.value to get parameters from lzReceive()\n     */\n    function _isAuthorized() internal view override returns (bool) {\n        require(_isAuthorizedHook(), \"LayerZeroV2Ism: hook is not authorized\");\n\n        require(\n            _isAuthorizedEndPoint(),\n            \"LayerZeroV2Ism: endpoint is not authorized\"\n        );\n\n        return true;\n    }\n\n    /**\n     * @notice check if origin.sender is the authorized hook\n     */\n    function _isAuthorizedHook() internal view returns (bool) {\n        return bytes32(msg.data[ORIGIN_SENDER_OFFSET:]) == authorizedHook;\n    }\n\n    /**\n     * @notice check if LayerZero endpoint is authorized\n     */\n    function _isAuthorizedEndPoint() internal view returns (bool) {\n        return msg.sender == endpoint;\n    }\n}\n"
      },
      "contracts/isms/hook/OPStackIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\n\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {AbstractMessageIdAuthorizedIsm} from \"./AbstractMessageIdAuthorizedIsm.sol\";\n\n// ============ External Imports ============\nimport {CrossChainEnabledOptimism} from \"@openzeppelin/contracts/crosschain/optimism/CrossChainEnabledOptimism.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\n/**\n * @title OPStackIsm\n * @notice Uses the native Optimism bridge to verify interchain messages.\n */\ncontract OPStackIsm is\n    CrossChainEnabledOptimism,\n    AbstractMessageIdAuthorizedIsm\n{\n    // ============ Constants ============\n\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.NULL);\n\n    // ============ Constructor ============\n\n    constructor(address _l2Messenger) CrossChainEnabledOptimism(_l2Messenger) {\n        require(\n            Address.isContract(_l2Messenger),\n            \"OPStackIsm: invalid L2Messenger\"\n        );\n    }\n\n    // ============ Internal function ============\n\n    /**\n     * @notice Check if sender is authorized to message `verifyMessageId`.\n     */\n    function _isAuthorized() internal view override returns (bool) {\n        return\n            _crossChainSender() == TypeCasts.bytes32ToAddress(authorizedHook);\n    }\n}\n"
      },
      "contracts/isms/libs/AggregationIsmMetadata.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * Format of metadata:\n *\n * [????:????] Metadata start/end uint32 ranges, packed as uint64\n * [????:????] ISM metadata, packed encoding\n */\nlibrary AggregationIsmMetadata {\n    uint256 private constant RANGE_SIZE = 4;\n\n    /**\n     * @notice Returns whether or not metadata was provided for the ISM at\n     * `_index`\n     * @dev Callers must ensure _index is less than the number of metadatas\n     * provided\n     * @param _metadata Encoded Aggregation ISM metadata\n     * @param _index The index of the ISM to check for metadata for\n     * @return Whether or not metadata was provided for the ISM at `_index`\n     */\n    function hasMetadata(\n        bytes calldata _metadata,\n        uint8 _index\n    ) internal pure returns (bool) {\n        (uint32 _start, ) = _metadataRange(_metadata, _index);\n        return _start > 0;\n    }\n\n    /**\n     * @notice Returns the metadata provided for the ISM at `_index`\n     * @dev Callers must ensure _index is less than the number of metadatas\n     * provided\n     * @dev Callers must ensure `hasMetadata(_metadata, _index)`\n     * @param _metadata Encoded Aggregation ISM metadata\n     * @param _index The index of the ISM to return metadata for\n     * @return The metadata provided for the ISM at `_index`\n     */\n    function metadataAt(\n        bytes calldata _metadata,\n        uint8 _index\n    ) internal pure returns (bytes calldata) {\n        (uint32 _start, uint32 _end) = _metadataRange(_metadata, _index);\n        return _metadata[_start:_end];\n    }\n\n    /**\n     * @notice Returns the range of the metadata provided for the ISM at\n     * `_index`, or zeroes if not provided\n     * @dev Callers must ensure _index is less than the number of metadatas\n     * provided\n     * @param _metadata Encoded Aggregation ISM metadata\n     * @param _index The index of the ISM to return metadata range for\n     * @return The range of the metadata provided for the ISM at `_index`, or\n     * zeroes if not provided\n     */\n    function _metadataRange(\n        bytes calldata _metadata,\n        uint8 _index\n    ) private pure returns (uint32, uint32) {\n        uint256 _start = (uint32(_index) * RANGE_SIZE * 2);\n        uint256 _mid = _start + RANGE_SIZE;\n        uint256 _end = _mid + RANGE_SIZE;\n        return (\n            uint32(bytes4(_metadata[_start:_mid])),\n            uint32(bytes4(_metadata[_mid:_end]))\n        );\n    }\n}\n"
      },
      "contracts/isms/libs/MerkleRootMultisigIsmMetadata.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * Format of metadata:\n * [   0:  32] Origin merkle tree address\n * [  32:  36] Index of message ID in merkle tree\n * [  36:  68] Signed checkpoint message ID\n * [  68:1092] Merkle proof\n * [1092:1096] Signed checkpoint index (computed from proof and index)\n * [1096:????] Validator signatures (length := threshold * 65)\n */\nlibrary MerkleRootMultisigIsmMetadata {\n    uint8 private constant ORIGIN_MERKLE_TREE_OFFSET = 0;\n    uint8 private constant MESSAGE_INDEX_OFFSET = 32;\n    uint8 private constant MESSAGE_ID_OFFSET = 36;\n    uint8 private constant MERKLE_PROOF_OFFSET = 68;\n    uint16 private constant MERKLE_PROOF_LENGTH = 32 * 32;\n    uint16 private constant SIGNED_INDEX_OFFSET = 1092;\n    uint16 private constant SIGNATURES_OFFSET = 1096;\n    uint8 private constant SIGNATURE_LENGTH = 65;\n\n    /**\n     * @notice Returns the origin merkle tree hook of the signed checkpoint as bytes32.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Origin merkle tree hook of the signed checkpoint as bytes32\n     */\n    function originMerkleTreeHook(\n        bytes calldata _metadata\n    ) internal pure returns (bytes32) {\n        return\n            bytes32(\n                _metadata[ORIGIN_MERKLE_TREE_OFFSET:ORIGIN_MERKLE_TREE_OFFSET +\n                    32]\n            );\n    }\n\n    /**\n     * @notice Returns the index of the message being proven.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Index of the target message in the merkle tree.\n     */\n    function messageIndex(\n        bytes calldata _metadata\n    ) internal pure returns (uint32) {\n        return\n            uint32(\n                bytes4(_metadata[MESSAGE_INDEX_OFFSET:MESSAGE_INDEX_OFFSET + 4])\n            );\n    }\n\n    /**\n     * @notice Returns the index of the signed checkpoint.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Index of the signed checkpoint\n     */\n    function signedIndex(\n        bytes calldata _metadata\n    ) internal pure returns (uint32) {\n        return\n            uint32(\n                bytes4(_metadata[SIGNED_INDEX_OFFSET:SIGNED_INDEX_OFFSET + 4])\n            );\n    }\n\n    /**\n     * @notice Returns the message ID of the signed checkpoint.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Message ID of the signed checkpoint\n     */\n    function signedMessageId(\n        bytes calldata _metadata\n    ) internal pure returns (bytes32) {\n        return bytes32(_metadata[MESSAGE_ID_OFFSET:MESSAGE_ID_OFFSET + 32]);\n    }\n\n    /**\n     * @notice Returns the merkle proof branch of the message.\n     * @dev This appears to be more gas efficient than returning a calldata\n     * slice and using that.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Merkle proof branch of the message.\n     */\n    function proof(\n        bytes calldata _metadata\n    ) internal pure returns (bytes32[32] memory) {\n        return\n            abi.decode(\n                _metadata[MERKLE_PROOF_OFFSET:MERKLE_PROOF_OFFSET +\n                    MERKLE_PROOF_LENGTH],\n                (bytes32[32])\n            );\n    }\n\n    /**\n     * @notice Returns the validator ECDSA signature at `_index`.\n     * @dev Assumes signatures are sorted by validator\n     * @dev Assumes `_metadata` encodes `threshold` signatures.\n     * @dev Assumes `_index` is less than `threshold`\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @param _index The index of the signature to return.\n     * @return The validator ECDSA signature at `_index`.\n     */\n    function signatureAt(\n        bytes calldata _metadata,\n        uint256 _index\n    ) internal pure returns (bytes calldata) {\n        uint256 _start = SIGNATURES_OFFSET + (_index * SIGNATURE_LENGTH);\n        uint256 _end = _start + SIGNATURE_LENGTH;\n        return _metadata[_start:_end];\n    }\n}\n"
      },
      "contracts/isms/libs/MessageIdMultisigIsmMetadata.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/**\n * Format of metadata:\n * [   0:  32] Origin merkle tree address\n * [  32:  64] Signed checkpoint root\n * [  64:  68] Signed checkpoint index\n * [  68:????] Validator signatures (length := threshold * 65)\n */\nlibrary MessageIdMultisigIsmMetadata {\n    uint8 private constant ORIGIN_MERKLE_TREE_OFFSET = 0;\n    uint8 private constant MERKLE_ROOT_OFFSET = 32;\n    uint8 private constant MERKLE_INDEX_OFFSET = 64;\n    uint8 private constant SIGNATURES_OFFSET = 68;\n    uint8 private constant SIGNATURE_LENGTH = 65;\n\n    /**\n     * @notice Returns the origin merkle tree hook of the signed checkpoint as bytes32.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Origin merkle tree hook of the signed checkpoint as bytes32\n     */\n    function originMerkleTreeHook(\n        bytes calldata _metadata\n    ) internal pure returns (bytes32) {\n        return\n            bytes32(\n                _metadata[ORIGIN_MERKLE_TREE_OFFSET:ORIGIN_MERKLE_TREE_OFFSET +\n                    32]\n            );\n    }\n\n    /**\n     * @notice Returns the merkle root of the signed checkpoint.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Merkle root of the signed checkpoint\n     */\n    function root(bytes calldata _metadata) internal pure returns (bytes32) {\n        return bytes32(_metadata[MERKLE_ROOT_OFFSET:MERKLE_ROOT_OFFSET + 32]);\n    }\n\n    /**\n     * @notice Returns the merkle index of the signed checkpoint.\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @return Merkle index of the signed checkpoint\n     */\n    function index(bytes calldata _metadata) internal pure returns (uint32) {\n        return\n            uint32(\n                bytes4(_metadata[MERKLE_INDEX_OFFSET:MERKLE_INDEX_OFFSET + 4])\n            );\n    }\n\n    /**\n     * @notice Returns the validator ECDSA signature at `_index`.\n     * @dev Assumes signatures are sorted by validator\n     * @dev Assumes `_metadata` encodes `threshold` signatures.\n     * @dev Assumes `_index` is less than `threshold`\n     * @param _metadata ABI encoded Multisig ISM metadata.\n     * @param _index The index of the signature to return.\n     * @return The validator ECDSA signature at `_index`.\n     */\n    function signatureAt(\n        bytes calldata _metadata,\n        uint256 _index\n    ) internal pure returns (bytes calldata) {\n        uint256 _start = SIGNATURES_OFFSET + (_index * SIGNATURE_LENGTH);\n        uint256 _end = _start + SIGNATURE_LENGTH;\n        return _metadata[_start:_end];\n    }\n}\n"
      },
      "contracts/isms/multisig/AbstractMerkleRootMultisigIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {AbstractMultisigIsm} from \"./AbstractMultisigIsm.sol\";\nimport {MerkleRootMultisigIsmMetadata} from \"../../isms/libs/MerkleRootMultisigIsmMetadata.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {MerkleLib} from \"../../libs/Merkle.sol\";\nimport {CheckpointLib} from \"../../libs/CheckpointLib.sol\";\n\n/**\n * @title `AbstractMerkleRootMultisigIsm` — multi-sig ISM with the validators-censorship resistance guarantee.\n * @notice This ISM allows using a newer signed checkpoint (say #33) to prove existence of an older message (#22) in the validators' MerkleTree.\n * This guarantees censorship resistance as validators cannot hide a message\n * by refusing to sign its checkpoint but later signing a checkpoint for a newer message.\n * If validators decide to censor a message, they are left with only one option — to not produce checkpoints at all.\n * Otherwise, the very next signed checkpoint (#33) can be used by any relayer to prove the previous message inclusion using this ISM.\n * This is censorship resistance is missing in the sibling implementation `AbstractMessageIdMultisigIsm`,\n * since it can only verify messages having the corresponding checkpoints.\n * @dev Provides the default implementation of verifying signatures over a checkpoint and the message inclusion in that checkpoint.\n * This abstract contract can be overridden for customizing the `validatorsAndThreshold()` (static or dynamic).\n * @dev May be adapted in future to support batch message verification against a single root.\n */\nabstract contract AbstractMerkleRootMultisigIsm is AbstractMultisigIsm {\n    using MerkleRootMultisigIsmMetadata for bytes;\n    using Message for bytes;\n\n    // ============ Constants ============\n\n    // solhint-disable-next-line const-name-snakecase\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.MERKLE_ROOT_MULTISIG);\n\n    /**\n     * @inheritdoc AbstractMultisigIsm\n     */\n    function digest(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) internal pure override returns (bytes32) {\n        require(\n            _metadata.messageIndex() <= _metadata.signedIndex(),\n            \"Invalid merkle index metadata\"\n        );\n        // We verify a merkle proof of (messageId, index) I to compute root J\n        bytes32 _signedRoot = MerkleLib.branchRoot(\n            _message.id(),\n            _metadata.proof(),\n            _metadata.messageIndex()\n        );\n        // We provide (messageId, index) J in metadata for digest derivation\n        return\n            CheckpointLib.digest(\n                _message.origin(),\n                _metadata.originMerkleTreeHook(),\n                _signedRoot,\n                _metadata.signedIndex(),\n                _metadata.signedMessageId()\n            );\n    }\n\n    /**\n     * @inheritdoc AbstractMultisigIsm\n     */\n    function signatureAt(\n        bytes calldata _metadata,\n        uint256 _index\n    ) internal pure virtual override returns (bytes calldata) {\n        return _metadata.signatureAt(_index);\n    }\n}\n"
      },
      "contracts/isms/multisig/AbstractMessageIdMultisigIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {AbstractMultisigIsm} from \"./AbstractMultisigIsm.sol\";\nimport {MessageIdMultisigIsmMetadata} from \"../libs/MessageIdMultisigIsmMetadata.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {CheckpointLib} from \"../../libs/CheckpointLib.sol\";\n\n/**\n * @title `AbstractMessageIdMultisigIsm` — multi-sig ISM for the censorship-friendly validators.\n * @notice This ISM minimizes gas/performance overhead of the checkpoints verification by compromising on the censorship resistance.\n * For censorship resistance consider using `AbstractMerkleRootMultisigIsm`.\n * If the validators (`validatorsAndThreshold`) skip messages by not sign checkpoints for them,\n * the relayers will not be able to aggregate a quorum of signatures sufficient to deliver these messages via this ISM.\n * Integrations are free to choose the trade-off between the censorship resistance and the gas/processing overhead.\n * @dev Provides the default implementation of verifying signatures over a checkpoint related to a specific message ID.\n * This abstract contract can be customized to change the `validatorsAndThreshold()` (static or dynamic).\n */\nabstract contract AbstractMessageIdMultisigIsm is AbstractMultisigIsm {\n    using Message for bytes;\n    using MessageIdMultisigIsmMetadata for bytes;\n\n    // ============ Constants ============\n\n    // solhint-disable-next-line const-name-snakecase\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.MESSAGE_ID_MULTISIG);\n\n    /**\n     * @inheritdoc AbstractMultisigIsm\n     */\n    function digest(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) internal pure override returns (bytes32) {\n        return\n            CheckpointLib.digest(\n                _message.origin(),\n                _metadata.originMerkleTreeHook(),\n                _metadata.root(),\n                _metadata.index(),\n                _message.id()\n            );\n    }\n\n    /**\n     * @inheritdoc AbstractMultisigIsm\n     */\n    function signatureAt(\n        bytes calldata _metadata,\n        uint256 _index\n    ) internal pure virtual override returns (bytes calldata) {\n        return _metadata.signatureAt(_index);\n    }\n}\n"
      },
      "contracts/isms/multisig/AbstractMultisigIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ External Imports ============\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\n// ============ Internal Imports ============\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {IMultisigIsm} from \"../../interfaces/isms/IMultisigIsm.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {MerkleLib} from \"../../libs/Merkle.sol\";\n\n/**\n * @title MultisigIsm\n * @notice Manages per-domain m-of-n Validator sets that are used to verify\n * interchain messages.\n * @dev See ./AbstractMerkleRootMultisigIsm.sol and ./AbstractMessageIdMultisigIsm.sol\n * for concrete implementations of `digest` and `signatureAt`.\n * @dev See ./StaticMultisigIsm.sol for concrete implementations.\n */\nabstract contract AbstractMultisigIsm is IMultisigIsm {\n    // ============ Virtual Functions ============\n    // ======= OVERRIDE THESE TO IMPLEMENT =======\n\n    /**\n     * @notice Returns the set of validators responsible for verifying _message\n     * and the number of signatures required\n     * @dev Can change based on the content of _message\n     * @param _message Hyperlane formatted interchain message\n     * @return validators The array of validator addresses\n     * @return threshold The number of validator signatures needed\n     */\n    function validatorsAndThreshold(\n        bytes calldata _message\n    ) public view virtual returns (address[] memory, uint8);\n\n    /**\n     * @notice Returns the digest to be used for signature verification.\n     * @param _metadata ABI encoded module metadata\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     * @return digest The digest to be signed by validators\n     */\n    function digest(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) internal view virtual returns (bytes32);\n\n    /**\n     * @notice Returns the signature at a given index from the metadata.\n     * @param _metadata ABI encoded module metadata\n     * @param _index The index of the signature to return\n     * @return signature Packed encoding of signature (65 bytes)\n     */\n    function signatureAt(\n        bytes calldata _metadata,\n        uint256 _index\n    ) internal pure virtual returns (bytes calldata);\n\n    // ============ Public Functions ============\n\n    /**\n     * @notice Requires that m-of-n validators verify a merkle root,\n     * and verifies a me∑rkle proof of `_message` against that root.\n     * @param _metadata ABI encoded module metadata\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     */\n    function verify(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) public view returns (bool) {\n        bytes32 _digest = digest(_metadata, _message);\n        (\n            address[] memory _validators,\n            uint8 _threshold\n        ) = validatorsAndThreshold(_message);\n        require(_threshold > 0, \"No MultisigISM threshold present for message\");\n\n        uint256 _validatorCount = _validators.length;\n        uint256 _validatorIndex = 0;\n        // Assumes that signatures are ordered by validator\n        for (uint256 i = 0; i < _threshold; ++i) {\n            address _signer = ECDSA.recover(_digest, signatureAt(_metadata, i));\n            // Loop through remaining validators until we find a match\n            while (\n                _validatorIndex < _validatorCount &&\n                _signer != _validators[_validatorIndex]\n            ) {\n                ++_validatorIndex;\n            }\n            // Fail if we never found a match\n            require(_validatorIndex < _validatorCount, \"!threshold\");\n            ++_validatorIndex;\n        }\n        return true;\n    }\n}\n"
      },
      "contracts/isms/multisig/StaticMultisigIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n// ============ Internal Imports ============\nimport {AbstractMultisigIsm} from \"./AbstractMultisigIsm.sol\";\nimport {AbstractMerkleRootMultisigIsm} from \"./AbstractMerkleRootMultisigIsm.sol\";\nimport {AbstractMessageIdMultisigIsm} from \"./AbstractMessageIdMultisigIsm.sol\";\nimport {MetaProxy} from \"../../libs/MetaProxy.sol\";\nimport {StaticThresholdAddressSetFactory} from \"../../libs/StaticAddressSetFactory.sol\";\n\n/**\n * @title AbstractMetaProxyMultisigIsm\n * @notice Manages per-domain m-of-n Validator set that is used\n * to verify interchain messages.\n */\nabstract contract AbstractMetaProxyMultisigIsm is AbstractMultisigIsm {\n    /**\n     * @inheritdoc AbstractMultisigIsm\n     */\n    function validatorsAndThreshold(\n        bytes calldata\n    ) public pure override returns (address[] memory, uint8) {\n        return abi.decode(MetaProxy.metadata(), (address[], uint8));\n    }\n}\n\n// solhint-disable no-empty-blocks\n\n/**\n * @title StaticMerkleRootMultisigIsm\n * @notice Manages per-domain m-of-n validator set that is used\n * to verify interchain messages using a merkle root signature quorum\n * and merkle proof of inclusion.\n */\ncontract StaticMerkleRootMultisigIsm is\n    AbstractMerkleRootMultisigIsm,\n    AbstractMetaProxyMultisigIsm\n{}\n\n/**\n * @title StaticMessageIdMultisigIsm\n * @notice Manages per-domain m-of-n validator set that is used\n * to verify interchain messages using a message ID signature quorum.\n */\ncontract StaticMessageIdMultisigIsm is\n    AbstractMessageIdMultisigIsm,\n    AbstractMetaProxyMultisigIsm\n{}\n\n// solhint-enable no-empty-blocks\n\ncontract StaticMerkleRootMultisigIsmFactory is\n    StaticThresholdAddressSetFactory\n{\n    function _deployImplementation() internal override returns (address) {\n        return address(new StaticMerkleRootMultisigIsm());\n    }\n}\n\ncontract StaticMessageIdMultisigIsmFactory is StaticThresholdAddressSetFactory {\n    function _deployImplementation() internal override returns (address) {\n        return address(new StaticMessageIdMultisigIsm());\n    }\n}\n"
      },
      "contracts/isms/multisig/ValidatorAnnounce.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {IValidatorAnnounce} from \"../../interfaces/IValidatorAnnounce.sol\";\nimport {IMailbox} from \"../../interfaces/IMailbox.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {MailboxClient} from \"../../client/MailboxClient.sol\";\n\n// ============ External Imports ============\nimport {EnumerableSet} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\n/**\n * @title ValidatorAnnounce\n * @notice Stores the location(s) of validator signed checkpoints\n */\ncontract ValidatorAnnounce is MailboxClient, IValidatorAnnounce {\n    // ============ Libraries ============\n\n    using EnumerableSet for EnumerableSet.AddressSet;\n    using TypeCasts for address;\n\n    // ============ Public Storage ============\n\n    // The set of validators that have announced\n    EnumerableSet.AddressSet private validators;\n    // Storage locations of validator signed checkpoints\n    mapping(address => string[]) private storageLocations;\n    // Mapping to prevent the same announcement from being registered\n    // multiple times.\n    mapping(bytes32 => bool) private replayProtection;\n\n    // ============ Events ============\n\n    /**\n     * @notice Emitted when a new validator announcement is made\n     * @param validator The address of the announcing validator\n     * @param storageLocation The storage location being announced\n     */\n    event ValidatorAnnouncement(\n        address indexed validator,\n        string storageLocation\n    );\n\n    // ============ Constructor ============\n\n    constructor(address _mailbox) MailboxClient(_mailbox) {}\n\n    // ============ External Functions ============\n\n    /**\n     * @notice Announces a validator signature storage location\n     * @param _storageLocation Information encoding the location of signed\n     * checkpoints\n     * @param _signature The signed validator announcement\n     * @return True upon success\n     */\n    function announce(\n        address _validator,\n        string calldata _storageLocation,\n        bytes calldata _signature\n    ) external returns (bool) {\n        // Ensure that the same storage metadata isn't being announced\n        // multiple times for the same validator.\n        bytes32 _replayId = keccak256(\n            abi.encodePacked(_validator, _storageLocation)\n        );\n        require(replayProtection[_replayId] == false, \"replay\");\n        replayProtection[_replayId] = true;\n\n        // Verify that the signature matches the declared validator\n        bytes32 _announcementDigest = getAnnouncementDigest(_storageLocation);\n        address _signer = ECDSA.recover(_announcementDigest, _signature);\n        require(_signer == _validator, \"!signature\");\n\n        // Store the announcement\n        if (!validators.contains(_validator)) {\n            validators.add(_validator);\n        }\n        storageLocations[_validator].push(_storageLocation);\n        emit ValidatorAnnouncement(_validator, _storageLocation);\n        return true;\n    }\n\n    /**\n     * @notice Returns a list of all announced storage locations\n     * @param _validators The list of validators to get registrations for\n     * @return A list of registered storage metadata\n     */\n    function getAnnouncedStorageLocations(\n        address[] calldata _validators\n    ) external view returns (string[][] memory) {\n        string[][] memory _metadata = new string[][](_validators.length);\n        for (uint256 i = 0; i < _validators.length; i++) {\n            _metadata[i] = storageLocations[_validators[i]];\n        }\n        return _metadata;\n    }\n\n    /// @notice Returns a list of validators that have made announcements\n    function getAnnouncedValidators() external view returns (address[] memory) {\n        return validators.values();\n    }\n\n    /**\n     * @notice Returns the digest validators are expected to sign when signing announcements.\n     * @param _storageLocation Storage location string.\n     * @return The digest of the announcement.\n     */\n    function getAnnouncementDigest(\n        string memory _storageLocation\n    ) public view returns (bytes32) {\n        return\n            ECDSA.toEthSignedMessageHash(\n                keccak256(abi.encodePacked(_domainHash(), _storageLocation))\n            );\n    }\n\n    /**\n     * @notice Returns the domain separator used in validator announcements.\n     */\n    function _domainHash() internal view returns (bytes32) {\n        return\n            keccak256(\n                abi.encodePacked(\n                    localDomain,\n                    address(mailbox).addressToBytes32(),\n                    \"HYPERLANE_ANNOUNCEMENT\"\n                )\n            );\n    }\n}\n"
      },
      "contracts/isms/NoopIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {IInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\n\ncontract NoopIsm is IInterchainSecurityModule {\n    uint8 public constant override moduleType = uint8(Types.NULL);\n\n    function verify(\n        bytes calldata,\n        bytes calldata\n    ) public pure override returns (bool) {\n        return true;\n    }\n}\n"
      },
      "contracts/isms/PausableIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ External Imports ============\nimport {Pausable} from \"@openzeppelin/contracts/security/Pausable.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\n// ============ Internal Imports ============\nimport {IInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\n\ncontract PausableIsm is IInterchainSecurityModule, Ownable, Pausable {\n    uint8 public constant override moduleType = uint8(Types.NULL);\n\n    constructor(address owner) Ownable() Pausable() {\n        _transferOwnership(owner);\n    }\n\n    /**\n     * @inheritdoc IInterchainSecurityModule\n     * @dev Reverts when paused, otherwise returns `true`.\n     */\n    function verify(\n        bytes calldata,\n        bytes calldata\n    ) external view whenNotPaused returns (bool) {\n        return true;\n    }\n\n    function pause() external onlyOwner {\n        _pause();\n    }\n\n    function unpause() external onlyOwner {\n        _unpause();\n    }\n}\n"
      },
      "contracts/isms/routing/AbstractRoutingIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {IRoutingIsm} from \"../../interfaces/isms/IRoutingIsm.sol\";\n\n/**\n * @title RoutingIsm\n */\nabstract contract AbstractRoutingIsm is IRoutingIsm {\n    // ============ Constants ============\n\n    // solhint-disable-next-line const-name-snakecase\n    uint8 public constant moduleType =\n        uint8(IInterchainSecurityModule.Types.ROUTING);\n\n    // ============ Virtual Functions ============\n    // ======= OVERRIDE THESE TO IMPLEMENT =======\n\n    /**\n     * @notice Returns the ISM responsible for verifying _message\n     * @dev Can change based on the content of _message\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     * @return module The ISM to use to verify _message\n     */\n    function route(\n        bytes calldata _message\n    ) public view virtual returns (IInterchainSecurityModule);\n\n    // ============ Public Functions ============\n\n    /**\n     * @notice Routes _metadata and _message to the correct ISM\n     * @param _metadata ABI encoded module metadata\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     */\n    function verify(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) public returns (bool) {\n        return route(_message).verify(_metadata, _message);\n    }\n}\n"
      },
      "contracts/isms/routing/DefaultFallbackRoutingIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {DomainRoutingIsm} from \"./DomainRoutingIsm.sol\";\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {EnumerableMapExtended} from \"../../libs/EnumerableMapExtended.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {MailboxClient} from \"../../client/MailboxClient.sol\";\n\n// ============ External Imports ============\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\ncontract DefaultFallbackRoutingIsm is DomainRoutingIsm, MailboxClient {\n    using EnumerableMapExtended for EnumerableMapExtended.UintToBytes32Map;\n    using Address for address;\n    using TypeCasts for bytes32;\n\n    constructor(address _mailbox) MailboxClient(_mailbox) {}\n\n    function module(\n        uint32 origin\n    ) public view override returns (IInterchainSecurityModule) {\n        (bool contained, bytes32 _module) = _modules.tryGet(origin);\n        if (contained) {\n            return IInterchainSecurityModule(_module.bytes32ToAddress());\n        } else {\n            return mailbox.defaultIsm();\n        }\n    }\n}\n"
      },
      "contracts/isms/routing/DomainRoutingIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ External Imports ============\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport {Strings} from \"@openzeppelin/contracts/utils/Strings.sol\";\n\n// ============ Internal Imports ============\nimport {AbstractRoutingIsm} from \"./AbstractRoutingIsm.sol\";\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {EnumerableMapExtended} from \"../../libs/EnumerableMapExtended.sol\";\n\n/**\n * @title DomainRoutingIsm\n */\ncontract DomainRoutingIsm is AbstractRoutingIsm, OwnableUpgradeable {\n    using EnumerableMapExtended for EnumerableMapExtended.UintToBytes32Map;\n    using Message for bytes;\n    using TypeCasts for bytes32;\n    using TypeCasts for address;\n    using Address for address;\n    using Strings for uint32;\n\n    // ============ Mutable Storage ============\n    EnumerableMapExtended.UintToBytes32Map internal _modules;\n\n    // ============ External Functions ============\n\n    /**\n     * @param _owner The owner of the contract.\n     */\n    function initialize(address _owner) public initializer {\n        __Ownable_init();\n        _transferOwnership(_owner);\n    }\n\n    /**\n     * @notice Sets the ISMs to be used for the specified origin domains\n     * @param _owner The owner of the contract.\n     * @param _domains The origin domains\n     * @param __modules The ISMs to use to verify messages\n     */\n    function initialize(\n        address _owner,\n        uint32[] calldata _domains,\n        IInterchainSecurityModule[] calldata __modules\n    ) public initializer {\n        __Ownable_init();\n        require(_domains.length == __modules.length, \"length mismatch\");\n        uint256 _length = _domains.length;\n        for (uint256 i = 0; i < _length; ++i) {\n            _set(_domains[i], address(__modules[i]));\n        }\n        _transferOwnership(_owner);\n    }\n\n    /**\n     * @notice Sets the ISM to be used for the specified origin domain\n     * @param _domain The origin domain\n     * @param _module The ISM to use to verify messages\n     */\n    function set(\n        uint32 _domain,\n        IInterchainSecurityModule _module\n    ) external onlyOwner {\n        _set(_domain, address(_module));\n    }\n\n    /**\n     * @notice Removes the specified origin domain\n     * @param _domain The origin domain\n     */\n    function remove(uint32 _domain) external onlyOwner {\n        _remove(_domain);\n    }\n\n    function domains() external view returns (uint256[] memory) {\n        return _modules.keys();\n    }\n\n    function module(\n        uint32 origin\n    ) public view virtual returns (IInterchainSecurityModule) {\n        (bool contained, bytes32 _module) = _modules.tryGet(origin);\n        require(contained, _originNotFoundError(origin));\n        return IInterchainSecurityModule(_module.bytes32ToAddress());\n    }\n\n    // ============ Public Functions ============\n    /**\n     * @notice Returns the ISM responsible for verifying _message\n     * @dev Can change based on the content of _message\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     * @return module The ISM to use to verify _message\n     */\n    function route(\n        bytes calldata _message\n    ) public view override returns (IInterchainSecurityModule) {\n        return module(_message.origin());\n    }\n\n    // ============ Internal Functions ============\n\n    /**\n     * @notice Removes the specified origin domain's ISM\n     * @param _domain The origin domain\n     */\n    function _remove(uint32 _domain) internal {\n        require(_modules.remove(_domain), _originNotFoundError(_domain));\n    }\n\n    function _originNotFoundError(\n        uint32 _origin\n    ) internal pure returns (string memory) {\n        return string.concat(\"No ISM found for origin: \", _origin.toString());\n    }\n\n    /**\n     * @notice Sets the ISM to be used for the specified origin domain\n     * @param _domain The origin domain\n     * @param _module The ISM to use to verify messages\n     */\n    function _set(uint32 _domain, address _module) internal {\n        require(_module.isContract(), \"ISM must be a contract\");\n        _modules.set(_domain, _module.addressToBytes32());\n    }\n}\n"
      },
      "contracts/isms/routing/DomainRoutingIsmFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {DomainRoutingIsm} from \"./DomainRoutingIsm.sol\";\nimport {DefaultFallbackRoutingIsm} from \"./DefaultFallbackRoutingIsm.sol\";\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {MinimalProxy} from \"../../libs/MinimalProxy.sol\";\n\nabstract contract AbstractDomainRoutingIsmFactory {\n    /**\n     * @notice Emitted when a routing module is deployed\n     * @param module The deployed ISM\n     */\n    event ModuleDeployed(DomainRoutingIsm module);\n\n    // ============ External Functions ============\n\n    /**\n     * @notice Deploys and initializes a DomainRoutingIsm using a minimal proxy\n     * @param _owner The owner to set on the ISM\n     * @param _domains The origin domains\n     * @param _modules The ISMs to use to verify messages\n     */\n    function deploy(\n        address _owner,\n        uint32[] calldata _domains,\n        IInterchainSecurityModule[] calldata _modules\n    ) external returns (DomainRoutingIsm) {\n        DomainRoutingIsm _ism = DomainRoutingIsm(\n            MinimalProxy.create(implementation())\n        );\n        emit ModuleDeployed(_ism);\n        _ism.initialize(_owner, _domains, _modules);\n        return _ism;\n    }\n\n    function implementation() public view virtual returns (address);\n}\n\n/**\n * @title DomainRoutingIsmFactory\n */\ncontract DomainRoutingIsmFactory is AbstractDomainRoutingIsmFactory {\n    // ============ Immutables ============\n    address internal immutable _implementation;\n\n    constructor() {\n        _implementation = address(new DomainRoutingIsm());\n    }\n\n    function implementation() public view override returns (address) {\n        return _implementation;\n    }\n}\n"
      },
      "contracts/isms/routing/InterchainAccountIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n// ============ Internal Imports ============\nimport {AbstractRoutingIsm} from \"./AbstractRoutingIsm.sol\";\nimport {IMailbox} from \"../../interfaces/IMailbox.sol\";\nimport {IInterchainSecurityModule} from \"../../interfaces/IInterchainSecurityModule.sol\";\nimport {Message} from \"../../libs/Message.sol\";\nimport {InterchainAccountMessage} from \"../../middleware/libs/InterchainAccountMessage.sol\";\n\n/**\n * @title InterchainAccountIsm\n */\ncontract InterchainAccountIsm is AbstractRoutingIsm {\n    IMailbox private immutable mailbox;\n\n    // ============ Constructor ============\n    constructor(address _mailbox) {\n        mailbox = IMailbox(_mailbox);\n    }\n\n    // ============ Public Functions ============\n\n    /**\n     * @notice Returns the ISM responsible for verifying _message\n     * @param _message Formatted Hyperlane message (see Message.sol).\n     * @return module The ISM to use to verify _message\n     */\n    function route(\n        bytes calldata _message\n    ) public view virtual override returns (IInterchainSecurityModule) {\n        address _ism = InterchainAccountMessage.ism(Message.body(_message));\n        if (_ism == address(0)) {\n            return mailbox.defaultIsm();\n        } else {\n            return IInterchainSecurityModule(_ism);\n        }\n    }\n}\n"
      },
      "contracts/libs/CheckpointLib.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ External Imports ============\nimport {ECDSA} from \"@openzeppelin/contracts/utils/cryptography/ECDSA.sol\";\n\nlibrary CheckpointLib {\n    /**\n     * @notice Returns the digest validators are expected to sign when signing checkpoints.\n     * @param _origin The origin domain of the checkpoint.\n     * @param _originmerkleTreeHook The address of the origin merkle tree hook as bytes32.\n     * @param _checkpointRoot The root of the checkpoint.\n     * @param _checkpointIndex The index of the checkpoint.\n     * @param _messageId The message ID of the checkpoint.\n     * @dev Message ID must match leaf content of checkpoint root at index.\n     * @return The digest of the checkpoint.\n     */\n    function digest(\n        uint32 _origin,\n        bytes32 _originmerkleTreeHook,\n        bytes32 _checkpointRoot,\n        uint32 _checkpointIndex,\n        bytes32 _messageId\n    ) internal pure returns (bytes32) {\n        bytes32 _domainHash = domainHash(_origin, _originmerkleTreeHook);\n        return\n            ECDSA.toEthSignedMessageHash(\n                keccak256(\n                    abi.encodePacked(\n                        _domainHash,\n                        _checkpointRoot,\n                        _checkpointIndex,\n                        _messageId\n                    )\n                )\n            );\n    }\n\n    /**\n     * @notice Returns the domain hash that validators are expected to use\n     * when signing checkpoints.\n     * @param _origin The origin domain of the checkpoint.\n     * @param _originmerkleTreeHook The address of the origin merkle tree as bytes32.\n     * @return The domain hash.\n     */\n    function domainHash(\n        uint32 _origin,\n        bytes32 _originmerkleTreeHook\n    ) internal pure returns (bytes32) {\n        // Including the origin merkle tree address in the signature allows the slashing\n        // protocol to enroll multiple trees. Otherwise, a valid signature for\n        // tree A would be indistinguishable from a fraudulent signature for tree B.\n        // The slashing protocol should slash if validators sign attestations for\n        // anything other than a whitelisted tree.\n        return\n            keccak256(\n                abi.encodePacked(_origin, _originmerkleTreeHook, \"HYPERLANE\")\n            );\n    }\n}\n"
      },
      "contracts/libs/EnumerableMapExtended.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\n// ============ External Imports ============\nimport \"@openzeppelin/contracts/utils/structs/EnumerableMap.sol\";\nimport \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\n\n// extends EnumerableMap with uint256 => bytes32 type\n// modelled after https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.8.0/contracts/utils/structs/EnumerableMap.sol\nlibrary EnumerableMapExtended {\n    using EnumerableMap for EnumerableMap.Bytes32ToBytes32Map;\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    struct UintToBytes32Map {\n        EnumerableMap.Bytes32ToBytes32Map _inner;\n    }\n\n    // ============ Library Functions ============\n    function keys(\n        UintToBytes32Map storage map\n    ) internal view returns (uint256[] memory _keys) {\n        uint256 _length = map._inner.length();\n        _keys = new uint256[](_length);\n        for (uint256 i = 0; i < _length; i++) {\n            _keys[i] = uint256(map._inner._keys.at(i));\n        }\n    }\n\n    function uint32Keys(\n        UintToBytes32Map storage map\n    ) internal view returns (uint32[] memory _keys) {\n        uint256[] memory uint256keys = keys(map);\n        _keys = new uint32[](uint256keys.length);\n        for (uint256 i = 0; i < uint256keys.length; i++) {\n            _keys[i] = uint32(uint256keys[i]);\n        }\n    }\n\n    function set(\n        UintToBytes32Map storage map,\n        uint256 key,\n        bytes32 value\n    ) internal {\n        map._inner.set(bytes32(key), value);\n    }\n\n    function get(\n        UintToBytes32Map storage map,\n        uint256 key\n    ) internal view returns (bytes32) {\n        return map._inner.get(bytes32(key));\n    }\n\n    function tryGet(\n        UintToBytes32Map storage map,\n        uint256 key\n    ) internal view returns (bool, bytes32) {\n        return map._inner.tryGet(bytes32(key));\n    }\n\n    function remove(\n        UintToBytes32Map storage map,\n        uint256 key\n    ) internal returns (bool) {\n        return map._inner.remove(bytes32(key));\n    }\n\n    function contains(\n        UintToBytes32Map storage map,\n        uint256 key\n    ) internal view returns (bool) {\n        return map._inner.contains(bytes32(key));\n    }\n\n    function length(\n        UintToBytes32Map storage map\n    ) internal view returns (uint256) {\n        return map._inner.length();\n    }\n\n    function at(\n        UintToBytes32Map storage map,\n        uint256 index\n    ) internal view returns (uint256, bytes32) {\n        (bytes32 key, bytes32 value) = map._inner.at(index);\n        return (uint256(key), value);\n    }\n}\n"
      },
      "contracts/libs/Indexed.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\ncontract Indexed {\n    uint256 public immutable deployedBlock;\n\n    constructor() {\n        deployedBlock = block.number;\n    }\n}\n"
      },
      "contracts/libs/LibBit.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n/// @notice Library for bit shifting and masking\nlibrary LibBit {\n    function setBit(\n        uint256 _value,\n        uint256 _index\n    ) internal pure returns (uint256) {\n        return _value | (1 << _index);\n    }\n\n    function clearBit(\n        uint256 _value,\n        uint256 _index\n    ) internal pure returns (uint256) {\n        return _value & ~(1 << _index);\n    }\n\n    function isBitSet(\n        uint256 _value,\n        uint256 _index\n    ) internal pure returns (bool) {\n        return (_value >> _index) & 1 == 1;\n    }\n}\n"
      },
      "contracts/libs/Merkle.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\n// work based on eth2 deposit contract, which is used under CC0-1.0\n\n/**\n * @title MerkleLib\n * @author Celo Labs Inc.\n * @notice An incremental merkle tree modeled on the eth2 deposit contract.\n **/\nlibrary MerkleLib {\n    uint256 internal constant TREE_DEPTH = 32;\n    uint256 internal constant MAX_LEAVES = 2 ** TREE_DEPTH - 1;\n\n    /**\n     * @notice Struct representing incremental merkle tree. Contains current\n     * branch and the number of inserted leaves in the tree.\n     **/\n    struct Tree {\n        bytes32[TREE_DEPTH] branch;\n        uint256 count;\n    }\n\n    /**\n     * @notice Inserts `_node` into merkle tree\n     * @dev Reverts if tree is full\n     * @param _node Element to insert into tree\n     **/\n    function insert(Tree storage _tree, bytes32 _node) internal {\n        require(_tree.count < MAX_LEAVES, \"merkle tree full\");\n\n        _tree.count += 1;\n        uint256 size = _tree.count;\n        for (uint256 i = 0; i < TREE_DEPTH; i++) {\n            if ((size & 1) == 1) {\n                _tree.branch[i] = _node;\n                return;\n            }\n            _node = keccak256(abi.encodePacked(_tree.branch[i], _node));\n            size /= 2;\n        }\n        // As the loop should always end prematurely with the `return` statement,\n        // this code should be unreachable. We assert `false` just to be safe.\n        assert(false);\n    }\n\n    /**\n     * @notice Calculates and returns`_tree`'s current root given array of zero\n     * hashes\n     * @param _zeroes Array of zero hashes\n     * @return _current Calculated root of `_tree`\n     **/\n    function rootWithCtx(\n        Tree storage _tree,\n        bytes32[TREE_DEPTH] memory _zeroes\n    ) internal view returns (bytes32 _current) {\n        uint256 _index = _tree.count;\n\n        for (uint256 i = 0; i < TREE_DEPTH; i++) {\n            uint256 _ithBit = (_index >> i) & 0x01;\n            bytes32 _next = _tree.branch[i];\n            if (_ithBit == 1) {\n                _current = keccak256(abi.encodePacked(_next, _current));\n            } else {\n                _current = keccak256(abi.encodePacked(_current, _zeroes[i]));\n            }\n        }\n    }\n\n    /// @notice Calculates and returns`_tree`'s current root\n    function root(Tree storage _tree) internal view returns (bytes32) {\n        return rootWithCtx(_tree, zeroHashes());\n    }\n\n    /// @notice Returns array of TREE_DEPTH zero hashes\n    /// @return _zeroes Array of TREE_DEPTH zero hashes\n    function zeroHashes()\n        internal\n        pure\n        returns (bytes32[TREE_DEPTH] memory _zeroes)\n    {\n        _zeroes[0] = Z_0;\n        _zeroes[1] = Z_1;\n        _zeroes[2] = Z_2;\n        _zeroes[3] = Z_3;\n        _zeroes[4] = Z_4;\n        _zeroes[5] = Z_5;\n        _zeroes[6] = Z_6;\n        _zeroes[7] = Z_7;\n        _zeroes[8] = Z_8;\n        _zeroes[9] = Z_9;\n        _zeroes[10] = Z_10;\n        _zeroes[11] = Z_11;\n        _zeroes[12] = Z_12;\n        _zeroes[13] = Z_13;\n        _zeroes[14] = Z_14;\n        _zeroes[15] = Z_15;\n        _zeroes[16] = Z_16;\n        _zeroes[17] = Z_17;\n        _zeroes[18] = Z_18;\n        _zeroes[19] = Z_19;\n        _zeroes[20] = Z_20;\n        _zeroes[21] = Z_21;\n        _zeroes[22] = Z_22;\n        _zeroes[23] = Z_23;\n        _zeroes[24] = Z_24;\n        _zeroes[25] = Z_25;\n        _zeroes[26] = Z_26;\n        _zeroes[27] = Z_27;\n        _zeroes[28] = Z_28;\n        _zeroes[29] = Z_29;\n        _zeroes[30] = Z_30;\n        _zeroes[31] = Z_31;\n    }\n\n    /**\n     * @notice Calculates and returns the merkle root for the given leaf\n     * `_item`, a merkle branch, and the index of `_item` in the tree.\n     * @param _item Merkle leaf\n     * @param _branch Merkle proof\n     * @param _index Index of `_item` in tree\n     * @return _current Calculated merkle root\n     **/\n    function branchRoot(\n        bytes32 _item,\n        bytes32[TREE_DEPTH] memory _branch, // cheaper than calldata indexing\n        uint256 _index\n    ) internal pure returns (bytes32 _current) {\n        _current = _item;\n\n        for (uint256 i = 0; i < TREE_DEPTH; i++) {\n            uint256 _ithBit = (_index >> i) & 0x01;\n            // cheaper than calldata indexing _branch[i*32:(i+1)*32];\n            bytes32 _next = _branch[i];\n            if (_ithBit == 1) {\n                _current = keccak256(abi.encodePacked(_next, _current));\n            } else {\n                _current = keccak256(abi.encodePacked(_current, _next));\n            }\n        }\n    }\n\n    // keccak256 zero hashes\n    bytes32 internal constant Z_0 =\n        hex\"0000000000000000000000000000000000000000000000000000000000000000\";\n    bytes32 internal constant Z_1 =\n        hex\"ad3228b676f7d3cd4284a5443f17f1962b36e491b30a40b2405849e597ba5fb5\";\n    bytes32 internal constant Z_2 =\n        hex\"b4c11951957c6f8f642c4af61cd6b24640fec6dc7fc607ee8206a99e92410d30\";\n    bytes32 internal constant Z_3 =\n        hex\"21ddb9a356815c3fac1026b6dec5df3124afbadb485c9ba5a3e3398a04b7ba85\";\n    bytes32 internal constant Z_4 =\n        hex\"e58769b32a1beaf1ea27375a44095a0d1fb664ce2dd358e7fcbfb78c26a19344\";\n    bytes32 internal constant Z_5 =\n        hex\"0eb01ebfc9ed27500cd4dfc979272d1f0913cc9f66540d7e8005811109e1cf2d\";\n    bytes32 internal constant Z_6 =\n        hex\"887c22bd8750d34016ac3c66b5ff102dacdd73f6b014e710b51e8022af9a1968\";\n    bytes32 internal constant Z_7 =\n        hex\"ffd70157e48063fc33c97a050f7f640233bf646cc98d9524c6b92bcf3ab56f83\";\n    bytes32 internal constant Z_8 =\n        hex\"9867cc5f7f196b93bae1e27e6320742445d290f2263827498b54fec539f756af\";\n    bytes32 internal constant Z_9 =\n        hex\"cefad4e508c098b9a7e1d8feb19955fb02ba9675585078710969d3440f5054e0\";\n    bytes32 internal constant Z_10 =\n        hex\"f9dc3e7fe016e050eff260334f18a5d4fe391d82092319f5964f2e2eb7c1c3a5\";\n    bytes32 internal constant Z_11 =\n        hex\"f8b13a49e282f609c317a833fb8d976d11517c571d1221a265d25af778ecf892\";\n    bytes32 internal constant Z_12 =\n        hex\"3490c6ceeb450aecdc82e28293031d10c7d73bf85e57bf041a97360aa2c5d99c\";\n    bytes32 internal constant Z_13 =\n        hex\"c1df82d9c4b87413eae2ef048f94b4d3554cea73d92b0f7af96e0271c691e2bb\";\n    bytes32 internal constant Z_14 =\n        hex\"5c67add7c6caf302256adedf7ab114da0acfe870d449a3a489f781d659e8becc\";\n    bytes32 internal constant Z_15 =\n        hex\"da7bce9f4e8618b6bd2f4132ce798cdc7a60e7e1460a7299e3c6342a579626d2\";\n    bytes32 internal constant Z_16 =\n        hex\"2733e50f526ec2fa19a22b31e8ed50f23cd1fdf94c9154ed3a7609a2f1ff981f\";\n    bytes32 internal constant Z_17 =\n        hex\"e1d3b5c807b281e4683cc6d6315cf95b9ade8641defcb32372f1c126e398ef7a\";\n    bytes32 internal constant Z_18 =\n        hex\"5a2dce0a8a7f68bb74560f8f71837c2c2ebbcbf7fffb42ae1896f13f7c7479a0\";\n    bytes32 internal constant Z_19 =\n        hex\"b46a28b6f55540f89444f63de0378e3d121be09e06cc9ded1c20e65876d36aa0\";\n    bytes32 internal constant Z_20 =\n        hex\"c65e9645644786b620e2dd2ad648ddfcbf4a7e5b1a3a4ecfe7f64667a3f0b7e2\";\n    bytes32 internal constant Z_21 =\n        hex\"f4418588ed35a2458cffeb39b93d26f18d2ab13bdce6aee58e7b99359ec2dfd9\";\n    bytes32 internal constant Z_22 =\n        hex\"5a9c16dc00d6ef18b7933a6f8dc65ccb55667138776f7dea101070dc8796e377\";\n    bytes32 internal constant Z_23 =\n        hex\"4df84f40ae0c8229d0d6069e5c8f39a7c299677a09d367fc7b05e3bc380ee652\";\n    bytes32 internal constant Z_24 =\n        hex\"cdc72595f74c7b1043d0e1ffbab734648c838dfb0527d971b602bc216c9619ef\";\n    bytes32 internal constant Z_25 =\n        hex\"0abf5ac974a1ed57f4050aa510dd9c74f508277b39d7973bb2dfccc5eeb0618d\";\n    bytes32 internal constant Z_26 =\n        hex\"b8cd74046ff337f0a7bf2c8e03e10f642c1886798d71806ab1e888d9e5ee87d0\";\n    bytes32 internal constant Z_27 =\n        hex\"838c5655cb21c6cb83313b5a631175dff4963772cce9108188b34ac87c81c41e\";\n    bytes32 internal constant Z_28 =\n        hex\"662ee4dd2dd7b2bc707961b1e646c4047669dcb6584f0d8d770daf5d7e7deb2e\";\n    bytes32 internal constant Z_29 =\n        hex\"388ab20e2573d171a88108e79d820e98f26c0b84aa8b2f4aa4968dbb818ea322\";\n    bytes32 internal constant Z_30 =\n        hex\"93237c50ba75ee485f4c22adf2f741400bdf8d6a9cc7df7ecae576221665d735\";\n    bytes32 internal constant Z_31 =\n        hex\"8448818bb4ae4562849e949e17ac16e0be16688e156b5cf15e098c627c0056a9\";\n}\n"
      },
      "contracts/libs/Message.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TypeCasts} from \"./TypeCasts.sol\";\n\n/**\n * @title Hyperlane Message Library\n * @notice Library for formatted messages used by Mailbox\n **/\nlibrary Message {\n    using TypeCasts for bytes32;\n\n    uint256 private constant VERSION_OFFSET = 0;\n    uint256 private constant NONCE_OFFSET = 1;\n    uint256 private constant ORIGIN_OFFSET = 5;\n    uint256 private constant SENDER_OFFSET = 9;\n    uint256 private constant DESTINATION_OFFSET = 41;\n    uint256 private constant RECIPIENT_OFFSET = 45;\n    uint256 private constant BODY_OFFSET = 77;\n\n    /**\n     * @notice Returns formatted (packed) Hyperlane message with provided fields\n     * @dev This function should only be used in memory message construction.\n     * @param _version The version of the origin and destination Mailboxes\n     * @param _nonce A nonce to uniquely identify the message on its origin chain\n     * @param _originDomain Domain of origin chain\n     * @param _sender Address of sender as bytes32\n     * @param _destinationDomain Domain of destination chain\n     * @param _recipient Address of recipient on destination chain as bytes32\n     * @param _messageBody Raw bytes of message body\n     * @return Formatted message\n     */\n    function formatMessage(\n        uint8 _version,\n        uint32 _nonce,\n        uint32 _originDomain,\n        bytes32 _sender,\n        uint32 _destinationDomain,\n        bytes32 _recipient,\n        bytes calldata _messageBody\n    ) internal pure returns (bytes memory) {\n        return\n            abi.encodePacked(\n                _version,\n                _nonce,\n                _originDomain,\n                _sender,\n                _destinationDomain,\n                _recipient,\n                _messageBody\n            );\n    }\n\n    /**\n     * @notice Returns the message ID.\n     * @param _message ABI encoded Hyperlane message.\n     * @return ID of `_message`\n     */\n    function id(bytes memory _message) internal pure returns (bytes32) {\n        return keccak256(_message);\n    }\n\n    /**\n     * @notice Returns the message version.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Version of `_message`\n     */\n    function version(bytes calldata _message) internal pure returns (uint8) {\n        return uint8(bytes1(_message[VERSION_OFFSET:NONCE_OFFSET]));\n    }\n\n    /**\n     * @notice Returns the message nonce.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Nonce of `_message`\n     */\n    function nonce(bytes calldata _message) internal pure returns (uint32) {\n        return uint32(bytes4(_message[NONCE_OFFSET:ORIGIN_OFFSET]));\n    }\n\n    /**\n     * @notice Returns the message origin domain.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Origin domain of `_message`\n     */\n    function origin(bytes calldata _message) internal pure returns (uint32) {\n        return uint32(bytes4(_message[ORIGIN_OFFSET:SENDER_OFFSET]));\n    }\n\n    /**\n     * @notice Returns the message sender as bytes32.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Sender of `_message` as bytes32\n     */\n    function sender(bytes calldata _message) internal pure returns (bytes32) {\n        return bytes32(_message[SENDER_OFFSET:DESTINATION_OFFSET]);\n    }\n\n    /**\n     * @notice Returns the message sender as address.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Sender of `_message` as address\n     */\n    function senderAddress(\n        bytes calldata _message\n    ) internal pure returns (address) {\n        return sender(_message).bytes32ToAddress();\n    }\n\n    /**\n     * @notice Returns the message destination domain.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Destination domain of `_message`\n     */\n    function destination(\n        bytes calldata _message\n    ) internal pure returns (uint32) {\n        return uint32(bytes4(_message[DESTINATION_OFFSET:RECIPIENT_OFFSET]));\n    }\n\n    /**\n     * @notice Returns the message recipient as bytes32.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Recipient of `_message` as bytes32\n     */\n    function recipient(\n        bytes calldata _message\n    ) internal pure returns (bytes32) {\n        return bytes32(_message[RECIPIENT_OFFSET:BODY_OFFSET]);\n    }\n\n    /**\n     * @notice Returns the message recipient as address.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Recipient of `_message` as address\n     */\n    function recipientAddress(\n        bytes calldata _message\n    ) internal pure returns (address) {\n        return recipient(_message).bytes32ToAddress();\n    }\n\n    /**\n     * @notice Returns the message body.\n     * @param _message ABI encoded Hyperlane message.\n     * @return Body of `_message`\n     */\n    function body(\n        bytes calldata _message\n    ) internal pure returns (bytes calldata) {\n        return bytes(_message[BODY_OFFSET:]);\n    }\n}\n"
      },
      "contracts/libs/MetaProxy.sol": {
        "content": "// SPDX-License-Identifier: CC0-1.0\npragma solidity >=0.7.6;\n\n/// @dev Adapted from https://eips.ethereum.org/EIPS/eip-3448\nlibrary MetaProxy {\n    bytes32 private constant PREFIX =\n        hex\"600b380380600b3d393df3363d3d373d3d3d3d60368038038091363936013d73\";\n    bytes13 private constant SUFFIX = hex\"5af43d3d93803e603457fd5bf3\";\n\n    function bytecode(\n        address _implementation,\n        bytes memory _metadata\n    ) internal pure returns (bytes memory) {\n        return\n            abi.encodePacked(\n                PREFIX,\n                bytes20(_implementation),\n                SUFFIX,\n                _metadata,\n                _metadata.length\n            );\n    }\n\n    function metadata() internal pure returns (bytes memory) {\n        bytes memory data;\n        assembly {\n            let posOfMetadataSize := sub(calldatasize(), 32)\n            let size := calldataload(posOfMetadataSize)\n            let dataPtr := sub(posOfMetadataSize, size)\n            data := mload(64)\n            // increment free memory pointer by metadata size + 32 bytes (length)\n            mstore(64, add(data, add(size, 32)))\n            mstore(data, size)\n            let memPtr := add(data, 32)\n            calldatacopy(memPtr, dataPtr, size)\n        }\n        return data;\n    }\n}\n"
      },
      "contracts/libs/MinimalProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\n// Library for building bytecode of minimal proxies (see https://eips.ethereum.org/EIPS/eip-1167)\nlibrary MinimalProxy {\n    bytes20 private constant PREFIX =\n        hex\"3d602d80600a3d3981f3363d3d373d3d3d363d73\";\n    bytes15 private constant SUFFIX = hex\"5af43d82803e903d91602b57fd5bf3\";\n\n    function create(address implementation) internal returns (address proxy) {\n        bytes memory _bytecode = bytecode(implementation);\n        assembly {\n            proxy := create(0, add(_bytecode, 32), mload(_bytecode))\n        }\n    }\n\n    function bytecode(\n        address implementation\n    ) internal pure returns (bytes memory) {\n        return abi.encodePacked(PREFIX, bytes20(implementation), SUFFIX);\n    }\n}\n"
      },
      "contracts/libs/StaticAddressSetFactory.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n// ============ External Imports ============\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {Create2} from \"@openzeppelin/contracts/utils/Create2.sol\";\n\n// ============ Internal Imports ============\nimport {MetaProxy} from \"./MetaProxy.sol\";\n\nabstract contract StaticThresholdAddressSetFactory {\n    // ============ Immutables ============\n    address public immutable implementation;\n\n    // ============ Constructor ============\n\n    constructor() {\n        implementation = _deployImplementation();\n    }\n\n    function _deployImplementation() internal virtual returns (address);\n\n    /**\n     * @notice Deploys a StaticThresholdAddressSet contract address for the given\n     * values\n     * @dev Consider sorting addresses to ensure contract reuse\n     * @param _values An array of addresses\n     * @param _threshold The threshold value to use\n     * @return set The contract address representing this StaticThresholdAddressSet\n     */\n    function deploy(\n        address[] calldata _values,\n        uint8 _threshold\n    ) public returns (address) {\n        (bytes32 _salt, bytes memory _bytecode) = _saltAndBytecode(\n            _values,\n            _threshold\n        );\n        address _set = _getAddress(_salt, _bytecode);\n        if (!Address.isContract(_set)) {\n            _set = Create2.deploy(0, _salt, _bytecode);\n        }\n        return _set;\n    }\n\n    /**\n     * @notice Returns the StaticThresholdAddressSet contract address for the given\n     * values\n     * @dev Consider sorting addresses to ensure contract reuse\n     * @param _values An array of addresses\n     * @param _threshold The threshold value to use\n     * @return set The contract address representing this StaticThresholdAddressSet\n     */\n    function getAddress(\n        address[] calldata _values,\n        uint8 _threshold\n    ) external view returns (address) {\n        (bytes32 _salt, bytes memory _bytecode) = _saltAndBytecode(\n            _values,\n            _threshold\n        );\n        return _getAddress(_salt, _bytecode);\n    }\n\n    /**\n     * @notice Returns the StaticThresholdAddressSet contract address for the given\n     * values\n     * @param _salt The salt used in Create2\n     * @param _bytecode The metaproxy bytecode used in Create2\n     * @return set The contract address representing this StaticThresholdAddressSet\n     */\n    function _getAddress(\n        bytes32 _salt,\n        bytes memory _bytecode\n    ) internal view returns (address) {\n        bytes32 _bytecodeHash = keccak256(_bytecode);\n        return Create2.computeAddress(_salt, _bytecodeHash);\n    }\n\n    /**\n     * @notice Returns the create2 salt and bytecode for the given values\n     * @param _values An array of addresses\n     * @param _threshold The threshold value to use\n     * @return _salt The salt used in Create2\n     * @return _bytecode The metaproxy bytecode used in Create2\n     */\n    function _saltAndBytecode(\n        address[] calldata _values,\n        uint8 _threshold\n    ) internal view returns (bytes32, bytes memory) {\n        bytes memory _metadata = abi.encode(_values, _threshold);\n        bytes memory _bytecode = MetaProxy.bytecode(implementation, _metadata);\n        bytes32 _salt = keccak256(_metadata);\n        return (_salt, _bytecode);\n    }\n}\n\nabstract contract StaticAddressSetFactory is StaticThresholdAddressSetFactory {\n    /**\n     * @notice Deploys a StaticAddressSet contract address for the given\n     * values\n     * @dev Consider sorting addresses to ensure contract reuse\n     * @param _values An array of addresses\n     * @return set The contract address representing this StaticAddressSet\n     */\n    function deploy(address[] calldata _values) external returns (address) {\n        return super.deploy(_values, uint8(_values.length));\n    }\n\n    /**\n     * @notice Returns the StaticAddressSet contract address for the given\n     * values\n     * @dev Consider sorting addresses to ensure contract reuse\n     * @param _values An array of addresses\n     * @return set The contract address representing this StaticAddressSet\n     */\n    function getAddress(\n        address[] calldata _values\n    ) external view returns (address) {\n        (bytes32 _salt, bytes memory _bytecode) = _saltAndBytecode(\n            _values,\n            uint8(_values.length)\n        );\n        return super._getAddress(_salt, _bytecode);\n    }\n}\n"
      },
      "contracts/libs/TypeCasts.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nlibrary TypeCasts {\n    // alignment preserving cast\n    function addressToBytes32(address _addr) internal pure returns (bytes32) {\n        return bytes32(uint256(uint160(_addr)));\n    }\n\n    // alignment preserving cast\n    function bytes32ToAddress(bytes32 _buf) internal pure returns (address) {\n        return address(uint160(uint256(_buf)));\n    }\n}\n"
      },
      "contracts/Mailbox.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {Versioned} from \"./upgrade/Versioned.sol\";\nimport {Indexed} from \"./libs/Indexed.sol\";\nimport {Message} from \"./libs/Message.sol\";\nimport {TypeCasts} from \"./libs/TypeCasts.sol\";\nimport {IInterchainSecurityModule, ISpecifiesInterchainSecurityModule} from \"./interfaces/IInterchainSecurityModule.sol\";\nimport {IPostDispatchHook} from \"./interfaces/hooks/IPostDispatchHook.sol\";\nimport {IMessageRecipient} from \"./interfaces/IMessageRecipient.sol\";\nimport {IMailbox} from \"./interfaces/IMailbox.sol\";\n\n// ============ External Imports ============\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {OwnableUpgradeable} from \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract Mailbox is IMailbox, Indexed, Versioned, OwnableUpgradeable {\n    // ============ Libraries ============\n\n    using Message for bytes;\n    using TypeCasts for bytes32;\n    using TypeCasts for address;\n\n    // ============ Constants ============\n\n    // Domain of chain on which the contract is deployed\n    uint32 public immutable localDomain;\n\n    // ============ Public Storage ============\n\n    // A monotonically increasing nonce for outbound unique message IDs.\n    uint32 public nonce;\n\n    // The latest dispatched message ID used for auth in post-dispatch hooks.\n    bytes32 public latestDispatchedId;\n\n    // The default ISM, used if the recipient fails to specify one.\n    IInterchainSecurityModule public defaultIsm;\n\n    // The default post dispatch hook, used for post processing of opting-in dispatches.\n    IPostDispatchHook public defaultHook;\n\n    // The required post dispatch hook, used for post processing of ALL dispatches.\n    IPostDispatchHook public requiredHook;\n\n    // Mapping of message ID to delivery context that processed the message.\n    struct Delivery {\n        address processor;\n        uint48 blockNumber;\n    }\n    mapping(bytes32 => Delivery) internal deliveries;\n\n    // ============ Events ============\n\n    /**\n     * @notice Emitted when the default ISM is updated\n     * @param module The new default ISM\n     */\n    event DefaultIsmSet(address indexed module);\n\n    /**\n     * @notice Emitted when the default hook is updated\n     * @param hook The new default hook\n     */\n    event DefaultHookSet(address indexed hook);\n\n    /**\n     * @notice Emitted when the required hook is updated\n     * @param hook The new required hook\n     */\n    event RequiredHookSet(address indexed hook);\n\n    // ============ Constructor ============\n    constructor(uint32 _localDomain) {\n        localDomain = _localDomain;\n    }\n\n    // ============ Initializers ============\n    function initialize(\n        address _owner,\n        address _defaultIsm,\n        address _defaultHook,\n        address _requiredHook\n    ) external initializer {\n        __Ownable_init();\n        setDefaultIsm(_defaultIsm);\n        setDefaultHook(_defaultHook);\n        setRequiredHook(_requiredHook);\n        transferOwnership(_owner);\n    }\n\n    // ============ External Functions ============\n    /**\n     * @notice Dispatches a message to the destination domain & recipient\n     * using the default hook and empty metadata.\n     * @param _destinationDomain Domain of destination chain\n     * @param _recipientAddress Address of recipient on destination chain as bytes32\n     * @param _messageBody Raw bytes content of message body\n     * @return The message ID inserted into the Mailbox's merkle tree\n     */\n    function dispatch(\n        uint32 _destinationDomain,\n        bytes32 _recipientAddress,\n        bytes calldata _messageBody\n    ) external payable override returns (bytes32) {\n        return\n            dispatch(\n                _destinationDomain,\n                _recipientAddress,\n                _messageBody,\n                _messageBody[0:0],\n                defaultHook\n            );\n    }\n\n    /**\n     * @notice Dispatches a message to the destination domain & recipient.\n     * @param destinationDomain Domain of destination chain\n     * @param recipientAddress Address of recipient on destination chain as bytes32\n     * @param messageBody Raw bytes content of message body\n     * @param hookMetadata Metadata used by the post dispatch hook\n     * @return The message ID inserted into the Mailbox's merkle tree\n     */\n    function dispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody,\n        bytes calldata hookMetadata\n    ) external payable override returns (bytes32) {\n        return\n            dispatch(\n                destinationDomain,\n                recipientAddress,\n                messageBody,\n                hookMetadata,\n                defaultHook\n            );\n    }\n\n    /**\n     * @notice Computes quote for dipatching a message to the destination domain & recipient\n     * using the default hook and empty metadata.\n     * @param destinationDomain Domain of destination chain\n     * @param recipientAddress Address of recipient on destination chain as bytes32\n     * @param messageBody Raw bytes content of message body\n     * @return fee The payment required to dispatch the message\n     */\n    function quoteDispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody\n    ) external view returns (uint256 fee) {\n        return\n            quoteDispatch(\n                destinationDomain,\n                recipientAddress,\n                messageBody,\n                messageBody[0:0],\n                defaultHook\n            );\n    }\n\n    /**\n     * @notice Computes quote for dispatching a message to the destination domain & recipient.\n     * @param destinationDomain Domain of destination chain\n     * @param recipientAddress Address of recipient on destination chain as bytes32\n     * @param messageBody Raw bytes content of message body\n     * @param defaultHookMetadata Metadata used by the default post dispatch hook\n     * @return fee The payment required to dispatch the message\n     */\n    function quoteDispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody,\n        bytes calldata defaultHookMetadata\n    ) external view returns (uint256 fee) {\n        return\n            quoteDispatch(\n                destinationDomain,\n                recipientAddress,\n                messageBody,\n                defaultHookMetadata,\n                defaultHook\n            );\n    }\n\n    /**\n     * @notice Attempts to deliver `_message` to its recipient. Verifies\n     * `_message` via the recipient's ISM using the provided `_metadata`.\n     * @param _metadata Metadata used by the ISM to verify `_message`.\n     * @param _message Formatted Hyperlane message (refer to Message.sol).\n     */\n    function process(\n        bytes calldata _metadata,\n        bytes calldata _message\n    ) external payable override {\n        /// CHECKS ///\n\n        // Check that the message was intended for this mailbox.\n        require(_message.version() == VERSION, \"Mailbox: bad version\");\n        require(\n            _message.destination() == localDomain,\n            \"Mailbox: unexpected destination\"\n        );\n\n        // Check that the message hasn't already been delivered.\n        bytes32 _id = _message.id();\n        require(delivered(_id) == false, \"Mailbox: already delivered\");\n\n        // Get the recipient's ISM.\n        address recipient = _message.recipientAddress();\n        IInterchainSecurityModule ism = recipientIsm(recipient);\n\n        /// EFFECTS ///\n\n        deliveries[_id] = Delivery({\n            processor: msg.sender,\n            blockNumber: uint48(block.number)\n        });\n        emit Process(_message.origin(), _message.sender(), recipient);\n        emit ProcessId(_id);\n\n        /// INTERACTIONS ///\n\n        // Verify the message via the interchain security module.\n        require(\n            ism.verify(_metadata, _message),\n            \"Mailbox: ISM verification failed\"\n        );\n\n        // Deliver the message to the recipient.\n        IMessageRecipient(recipient).handle{value: msg.value}(\n            _message.origin(),\n            _message.sender(),\n            _message.body()\n        );\n    }\n\n    /**\n     * @notice Returns the account that processed the message.\n     * @param _id The message ID to check.\n     * @return The account that processed the message.\n     */\n    function processor(bytes32 _id) external view returns (address) {\n        return deliveries[_id].processor;\n    }\n\n    /**\n     * @notice Returns the account that processed the message.\n     * @param _id The message ID to check.\n     * @return The number of the block that the message was processed at.\n     */\n    function processedAt(bytes32 _id) external view returns (uint48) {\n        return deliveries[_id].blockNumber;\n    }\n\n    // ============ Public Functions ============\n\n    /**\n     * @notice Dispatches a message to the destination domain & recipient.\n     * @param destinationDomain Domain of destination chain\n     * @param recipientAddress Address of recipient on destination chain as bytes32\n     * @param messageBody Raw bytes content of message body\n     * @param metadata Metadata used by the post dispatch hook\n     * @param hook Custom hook to use instead of the default\n     * @return The message ID inserted into the Mailbox's merkle tree\n     */\n    function dispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody,\n        bytes calldata metadata,\n        IPostDispatchHook hook\n    ) public payable virtual returns (bytes32) {\n        if (address(hook) == address(0)) {\n            hook = defaultHook;\n        }\n\n        /// CHECKS ///\n\n        // Format the message into packed bytes.\n        bytes memory message = _buildMessage(\n            destinationDomain,\n            recipientAddress,\n            messageBody\n        );\n        bytes32 id = message.id();\n\n        /// EFFECTS ///\n\n        latestDispatchedId = id;\n        nonce += 1;\n        emit Dispatch(msg.sender, destinationDomain, recipientAddress, message);\n        emit DispatchId(id);\n\n        /// INTERACTIONS ///\n        uint256 requiredValue = requiredHook.quoteDispatch(metadata, message);\n        // if underpaying, defer to required hook's reverting behavior\n        if (msg.value < requiredValue) {\n            requiredValue = msg.value;\n        }\n        requiredHook.postDispatch{value: requiredValue}(metadata, message);\n        hook.postDispatch{value: msg.value - requiredValue}(metadata, message);\n\n        return id;\n    }\n\n    /**\n     * @notice Computes quote for dispatching a message to the destination domain & recipient.\n     * @param destinationDomain Domain of destination chain\n     * @param recipientAddress Address of recipient on destination chain as bytes32\n     * @param messageBody Raw bytes content of message body\n     * @param metadata Metadata used by the post dispatch hook\n     * @param hook Custom hook to use instead of the default\n     * @return fee The payment required to dispatch the message\n     */\n    function quoteDispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody,\n        bytes calldata metadata,\n        IPostDispatchHook hook\n    ) public view returns (uint256 fee) {\n        if (address(hook) == address(0)) {\n            hook = defaultHook;\n        }\n\n        bytes memory message = _buildMessage(\n            destinationDomain,\n            recipientAddress,\n            messageBody\n        );\n        return\n            requiredHook.quoteDispatch(metadata, message) +\n            hook.quoteDispatch(metadata, message);\n    }\n\n    /**\n     * @notice Returns true if the message has been processed.\n     * @param _id The message ID to check.\n     * @return True if the message has been delivered.\n     */\n    function delivered(bytes32 _id) public view override returns (bool) {\n        return deliveries[_id].blockNumber > 0;\n    }\n\n    /**\n     * @notice Sets the default ISM for the Mailbox.\n     * @param _module The new default ISM. Must be a contract.\n     */\n    function setDefaultIsm(address _module) public onlyOwner {\n        require(\n            Address.isContract(_module),\n            \"Mailbox: default ISM not contract\"\n        );\n        defaultIsm = IInterchainSecurityModule(_module);\n        emit DefaultIsmSet(_module);\n    }\n\n    /**\n     * @notice Sets the default post dispatch hook for the Mailbox.\n     * @param _hook The new default post dispatch hook. Must be a contract.\n     */\n    function setDefaultHook(address _hook) public onlyOwner {\n        require(\n            Address.isContract(_hook),\n            \"Mailbox: default hook not contract\"\n        );\n        defaultHook = IPostDispatchHook(_hook);\n        emit DefaultHookSet(_hook);\n    }\n\n    /**\n     * @notice Sets the required post dispatch hook for the Mailbox.\n     * @param _hook The new default post dispatch hook. Must be a contract.\n     */\n    function setRequiredHook(address _hook) public onlyOwner {\n        require(\n            Address.isContract(_hook),\n            \"Mailbox: required hook not contract\"\n        );\n        requiredHook = IPostDispatchHook(_hook);\n        emit RequiredHookSet(_hook);\n    }\n\n    /**\n     * @notice Returns the ISM to use for the recipient, defaulting to the\n     * default ISM if none is specified.\n     * @param _recipient The message recipient whose ISM should be returned.\n     * @return The ISM to use for `_recipient`.\n     */\n    function recipientIsm(\n        address _recipient\n    ) public view returns (IInterchainSecurityModule) {\n        // use low-level staticcall in case of revert or empty return data\n        (bool success, bytes memory returnData) = _recipient.staticcall(\n            abi.encodeCall(\n                ISpecifiesInterchainSecurityModule.interchainSecurityModule,\n                ()\n            )\n        );\n        // check if call was successful and returned data\n        if (success && returnData.length != 0) {\n            // check if returnData is a valid address\n            address ism = abi.decode(returnData, (address));\n            // check if the ISM is a contract\n            if (ism != address(0)) {\n                return IInterchainSecurityModule(ism);\n            }\n        }\n        // Use the default if a valid one is not specified by the recipient.\n        return defaultIsm;\n    }\n\n    // ============ Internal Functions ============\n    function _buildMessage(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody\n    ) internal view returns (bytes memory) {\n        return\n            Message.formatMessage(\n                VERSION,\n                nonce,\n                localDomain,\n                msg.sender.addressToBytes32(),\n                destinationDomain,\n                recipientAddress,\n                messageBody\n            );\n    }\n}\n"
      },
      "contracts/middleware/InterchainAccountRouter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\n/*@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n     @@@@@  HYPERLANE  @@@@@@@\n    @@@@@@@@@@@@@@@@@@@@@@@@@\n   @@@@@@@@@       @@@@@@@@@\n  @@@@@@@@@       @@@@@@@@@\n @@@@@@@@@       @@@@@@@@@\n@@@@@@@@@       @@@@@@@@*/\n\n// ============ Internal Imports ============\nimport {OwnableMulticall} from \"./libs/OwnableMulticall.sol\";\nimport {InterchainAccountMessage} from \"./libs/InterchainAccountMessage.sol\";\nimport {CallLib} from \"./libs/Call.sol\";\nimport {MinimalProxy} from \"../libs/MinimalProxy.sol\";\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\nimport {StandardHookMetadata} from \"../hooks/libs/StandardHookMetadata.sol\";\nimport {EnumerableMapExtended} from \"../libs/EnumerableMapExtended.sol\";\nimport {Router} from \"../client/Router.sol\";\n\n// ============ External Imports ============\nimport {Create2} from \"@openzeppelin/contracts/utils/Create2.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {Initializable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/*\n * @title A contract that allows accounts on chain A to call contracts via a\n * proxy contract on chain B.\n */\ncontract InterchainAccountRouter is Router {\n    // ============ Libraries ============\n\n    using TypeCasts for address;\n    using TypeCasts for bytes32;\n\n    struct AccountOwner {\n        uint32 origin;\n        bytes32 owner; // remote owner\n    }\n\n    // ============ Constants ============\n\n    address internal implementation;\n    bytes32 internal bytecodeHash;\n\n    // ============ Public Storage ============\n    mapping(uint32 => bytes32) public isms;\n    // reverse lookup from the ICA account to the remote owner\n    mapping(address => AccountOwner) public accountOwners;\n\n    // ============ Upgrade Gap ============\n\n    uint256[47] private __GAP;\n\n    // ============ Events ============\n\n    /**\n     * @notice Emitted when a default ISM is set for a remote domain\n     * @param domain The remote domain\n     * @param ism The address of the remote ISM\n     */\n    event RemoteIsmEnrolled(uint32 indexed domain, bytes32 ism);\n\n    /**\n     * @notice Emitted when an interchain call is dispatched to a remote domain\n     * @param destination The destination domain on which to make the call\n     * @param owner The local owner of the remote ICA\n     * @param router The address of the remote router\n     * @param ism The address of the remote ISM\n     */\n    event RemoteCallDispatched(\n        uint32 indexed destination,\n        address indexed owner,\n        bytes32 router,\n        bytes32 ism\n    );\n\n    /**\n     * @notice Emitted when an interchain account contract is deployed\n     * @param origin The domain of the chain where the message was sent from\n     * @param owner The address of the account that sent the message\n     * @param ism The address of the local ISM\n     * @param account The address of the proxy account that was created\n     */\n    event InterchainAccountCreated(\n        uint32 indexed origin,\n        bytes32 indexed owner,\n        address ism,\n        address account\n    );\n\n    // ============ Constructor ============\n\n    constructor(address _mailbox) Router(_mailbox) {}\n\n    // ============ Initializers ============\n\n    /**\n     * @notice Initializes the contract with HyperlaneConnectionClient contracts\n     * @param _customHook used by the Router to set the hook to override with\n     * @param _interchainSecurityModule The address of the local ISM contract\n     * @param _owner The address with owner privileges\n     */\n    function initialize(\n        address _customHook,\n        address _interchainSecurityModule,\n        address _owner\n    ) external initializer {\n        _MailboxClient_initialize(\n            _customHook,\n            _interchainSecurityModule,\n            _owner\n        );\n\n        implementation = address(new OwnableMulticall(address(this)));\n        // cannot be stored immutably because it is dynamically sized\n        bytes memory _bytecode = MinimalProxy.bytecode(implementation);\n        bytecodeHash = keccak256(_bytecode);\n    }\n\n    /**\n     * @notice Registers the address of remote InterchainAccountRouter\n     * and ISM contracts to use as a default when making interchain calls\n     * @param _destination The remote domain\n     * @param _router The address of the remote InterchainAccountRouter\n     * @param _ism The address of the remote ISM\n     */\n    function enrollRemoteRouterAndIsm(\n        uint32 _destination,\n        bytes32 _router,\n        bytes32 _ism\n    ) external onlyOwner {\n        _enrollRemoteRouterAndIsm(_destination, _router, _ism);\n    }\n\n    /**\n     * @notice Registers the address of remote InterchainAccountRouters\n     * and ISM contracts to use as defaults when making interchain calls\n     * @param _destinations The remote domains\n     * @param _routers The address of the remote InterchainAccountRouters\n     * @param _isms The address of the remote ISMs\n     */\n    function enrollRemoteRouterAndIsms(\n        uint32[] calldata _destinations,\n        bytes32[] calldata _routers,\n        bytes32[] calldata _isms\n    ) external onlyOwner {\n        require(\n            _destinations.length == _routers.length &&\n                _destinations.length == _isms.length,\n            \"length mismatch\"\n        );\n        for (uint256 i = 0; i < _destinations.length; i++) {\n            _enrollRemoteRouterAndIsm(_destinations[i], _routers[i], _isms[i]);\n        }\n    }\n\n    // ============ External Functions ============\n    /**\n     * @notice Dispatches a single remote call to be made by an owner's\n     * interchain account on the destination domain\n     * @dev Uses the default router and ISM addresses for the destination\n     * domain, reverting if none have been configured\n     * @param _destination The remote domain of the chain to make calls on\n     * @param _to The address of the contract to call\n     * @param _value The value to include in the call\n     * @param _data The calldata\n     * @return The Hyperlane message ID\n     */\n    function callRemote(\n        uint32 _destination,\n        address _to,\n        uint256 _value,\n        bytes memory _data\n    ) external payable returns (bytes32) {\n        bytes32 _router = routers(_destination);\n        bytes32 _ism = isms[_destination];\n        bytes memory _body = InterchainAccountMessage.encode(\n            msg.sender,\n            _ism,\n            _to,\n            _value,\n            _data\n        );\n        return _dispatchMessage(_destination, _router, _ism, _body);\n    }\n\n    /**\n     * @notice Dispatches a single remote call to be made by an owner's\n     * interchain account on the destination domain\n     * @dev Uses the default router and ISM addresses for the destination\n     * domain, reverting if none have been configured\n     * @param _destination The remote domain of the chain to make calls on\n     * @param _to The address of the contract to call\n     * @param _value The value to include in the call\n     * @param _data The calldata\n     * @param _hookMetadata The hook metadata to override with for the hook set by the owner\n     * @return The Hyperlane message ID\n     */\n    function callRemote(\n        uint32 _destination,\n        address _to,\n        uint256 _value,\n        bytes memory _data,\n        bytes memory _hookMetadata\n    ) external payable returns (bytes32) {\n        bytes32 _router = routers(_destination);\n        bytes32 _ism = isms[_destination];\n        bytes memory _body = InterchainAccountMessage.encode(\n            msg.sender,\n            _ism,\n            _to,\n            _value,\n            _data\n        );\n        return\n            _dispatchMessageWithMetadata(\n                _destination,\n                _router,\n                _ism,\n                _body,\n                _hookMetadata\n            );\n    }\n\n    /**\n     * @notice Dispatches a sequence of remote calls to be made by an owner's\n     * interchain account on the destination domain\n     * @dev Uses the default router and ISM addresses for the destination\n     * domain, reverting if none have been configured\n     * @dev Recommend using CallLib.build to format the interchain calls.\n     * @param _destination The remote domain of the chain to make calls on\n     * @param _calls The sequence of calls to make\n     * @return The Hyperlane message ID\n     */\n    function callRemote(\n        uint32 _destination,\n        CallLib.Call[] calldata _calls\n    ) external payable returns (bytes32) {\n        bytes32 _router = routers(_destination);\n        bytes32 _ism = isms[_destination];\n        bytes memory _body = InterchainAccountMessage.encode(\n            msg.sender,\n            _ism,\n            _calls\n        );\n\n        return _dispatchMessage(_destination, _router, _ism, _body);\n    }\n\n    /**\n     * @notice Dispatches a sequence of remote calls to be made by an owner's\n     * interchain account on the destination domain\n     * @dev Uses the default router and ISM addresses for the destination\n     * domain, reverting if none have been configured\n     * @dev Recommend using CallLib.build to format the interchain calls.\n     * @param _destination The remote domain of the chain to make calls on\n     * @param _calls The sequence of calls to make\n     * @param _hookMetadata The hook metadata to override with for the hook set by the owner\n     * @return The Hyperlane message ID\n     */\n    function callRemote(\n        uint32 _destination,\n        CallLib.Call[] calldata _calls,\n        bytes calldata _hookMetadata\n    ) external payable returns (bytes32) {\n        bytes32 _router = routers(_destination);\n        bytes32 _ism = isms[_destination];\n        return\n            callRemoteWithOverrides(\n                _destination,\n                _router,\n                _ism,\n                _calls,\n                _hookMetadata\n            );\n    }\n\n    /**\n     * @notice Handles dispatched messages by relaying calls to the interchain account\n     * @param _origin The origin domain of the interchain account\n     * @param _sender The sender of the interchain message\n     * @param _message The InterchainAccountMessage containing the account\n     * owner, ISM, and sequence of calls to be relayed\n     * @dev Does not need to be onlyRemoteRouter, as this application is designed\n     * to receive messages from untrusted remote contracts.\n     */\n    function handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message\n    ) external payable override onlyMailbox {\n        (\n            bytes32 _owner,\n            bytes32 _ism,\n            CallLib.Call[] memory _calls\n        ) = InterchainAccountMessage.decode(_message);\n\n        OwnableMulticall _interchainAccount = getDeployedInterchainAccount(\n            _origin,\n            _owner,\n            _sender,\n            _ism.bytes32ToAddress()\n        );\n        _interchainAccount.multicall(_calls);\n    }\n\n    /**\n     * @notice Returns the local address of an interchain account\n     * @dev This interchain account is not guaranteed to have been deployed\n     * @param _origin The remote origin domain of the interchain account\n     * @param _router The remote origin InterchainAccountRouter\n     * @param _owner The remote owner of the interchain account\n     * @param _ism The local address of the ISM\n     * @return The local address of the interchain account\n     */\n    function getLocalInterchainAccount(\n        uint32 _origin,\n        address _owner,\n        address _router,\n        address _ism\n    ) external view returns (OwnableMulticall) {\n        return\n            getLocalInterchainAccount(\n                _origin,\n                _owner.addressToBytes32(),\n                _router.addressToBytes32(),\n                _ism\n            );\n    }\n\n    /**\n     * @notice Returns the remote address of a locally owned interchain account\n     * @dev This interchain account is not guaranteed to have been deployed\n     * @dev This function will only work if the destination domain is\n     * EVM compatible\n     * @param _destination The remote destination domain of the interchain account\n     * @param _owner The local owner of the interchain account\n     * @return The remote address of the interchain account\n     */\n    function getRemoteInterchainAccount(\n        uint32 _destination,\n        address _owner\n    ) external view returns (address) {\n        address _router = routers(_destination).bytes32ToAddress();\n        address _ism = isms[_destination].bytes32ToAddress();\n        return getRemoteInterchainAccount(_owner, _router, _ism);\n    }\n\n    // ============ Public Functions ============\n\n    /**\n     * @notice Returns and deploys (if not already) an interchain account\n     * @param _origin The remote origin domain of the interchain account\n     * @param _owner The remote owner of the interchain account\n     * @param _router The remote origin InterchainAccountRouter\n     * @param _ism The local address of the ISM\n     * @return The address of the interchain account\n     */\n    function getDeployedInterchainAccount(\n        uint32 _origin,\n        address _owner,\n        address _router,\n        address _ism\n    ) public returns (OwnableMulticall) {\n        return\n            getDeployedInterchainAccount(\n                _origin,\n                _owner.addressToBytes32(),\n                _router.addressToBytes32(),\n                _ism\n            );\n    }\n\n    /**\n     * @notice Returns and deploys (if not already) an interchain account\n     * @param _origin The remote origin domain of the interchain account\n     * @param _owner The remote owner of the interchain account\n     * @param _router The remote origin InterchainAccountRouter\n     * @param _ism The local address of the ISM\n     * @return The address of the interchain account\n     */\n    function getDeployedInterchainAccount(\n        uint32 _origin,\n        bytes32 _owner,\n        bytes32 _router,\n        address _ism\n    ) public returns (OwnableMulticall) {\n        bytes32 _salt = _getSalt(\n            _origin,\n            _owner,\n            _router,\n            _ism.addressToBytes32()\n        );\n        address payable _account = _getLocalInterchainAccount(_salt);\n        if (!Address.isContract(_account)) {\n            bytes memory _bytecode = MinimalProxy.bytecode(implementation);\n            _account = payable(Create2.deploy(0, _salt, _bytecode));\n            accountOwners[_account] = AccountOwner(_origin, _owner);\n            emit InterchainAccountCreated(_origin, _owner, _ism, _account);\n        }\n        return OwnableMulticall(_account);\n    }\n\n    /**\n     * @notice Returns the local address of a remotely owned interchain account\n     * @dev This interchain account is not guaranteed to have been deployed\n     * @param _origin The remote origin domain of the interchain account\n     * @param _owner The remote owner of the interchain account\n     * @param _router The remote InterchainAccountRouter\n     * @param _ism The local address of the ISM\n     * @return The local address of the interchain account\n     */\n    function getLocalInterchainAccount(\n        uint32 _origin,\n        bytes32 _owner,\n        bytes32 _router,\n        address _ism\n    ) public view returns (OwnableMulticall) {\n        return\n            OwnableMulticall(\n                _getLocalInterchainAccount(\n                    _getSalt(_origin, _owner, _router, _ism.addressToBytes32())\n                )\n            );\n    }\n\n    /**\n     * @notice Returns the remote address of a locally owned interchain account\n     * @dev This interchain account is not guaranteed to have been deployed\n     * @dev This function will only work if the destination domain is\n     * EVM compatible\n     * @param _owner The local owner of the interchain account\n     * @param _router The remote InterchainAccountRouter\n     * @param _ism The remote address of the ISM\n     * @return The remote address of the interchain account\n     */\n    function getRemoteInterchainAccount(\n        address _owner,\n        address _router,\n        address _ism\n    ) public view returns (address) {\n        require(_router != address(0), \"no router specified for destination\");\n        // Derives the address of the first contract deployed by _router using\n        // the CREATE opcode.\n        address _implementation = address(\n            uint160(\n                uint256(\n                    keccak256(\n                        abi.encodePacked(\n                            bytes1(0xd6),\n                            bytes1(0x94),\n                            _router,\n                            bytes1(0x01)\n                        )\n                    )\n                )\n            )\n        );\n        bytes memory _proxyBytecode = MinimalProxy.bytecode(_implementation);\n        bytes32 _bytecodeHash = keccak256(_proxyBytecode);\n        bytes32 _salt = _getSalt(\n            localDomain,\n            _owner.addressToBytes32(),\n            address(this).addressToBytes32(),\n            _ism.addressToBytes32()\n        );\n        return Create2.computeAddress(_salt, _bytecodeHash, _router);\n    }\n\n    /**\n     * @notice Dispatches a sequence of remote calls to be made by an owner's\n     * interchain account on the destination domain\n     * @dev Recommend using CallLib.build to format the interchain calls\n     * @param _destination The remote domain of the chain to make calls on\n     * @param _router The remote router address\n     * @param _ism The remote ISM address\n     * @param _calls The sequence of calls to make\n     * @return The Hyperlane message ID\n     */\n    function callRemoteWithOverrides(\n        uint32 _destination,\n        bytes32 _router,\n        bytes32 _ism,\n        CallLib.Call[] calldata _calls\n    ) public payable returns (bytes32) {\n        bytes memory _body = InterchainAccountMessage.encode(\n            msg.sender,\n            _ism,\n            _calls\n        );\n        return _dispatchMessage(_destination, _router, _ism, _body);\n    }\n\n    /**\n     * @notice Dispatches a sequence of remote calls to be made by an owner's\n     * interchain account on the destination domain\n     * @dev Recommend using CallLib.build to format the interchain calls\n     * @param _destination The remote domain of the chain to make calls on\n     * @param _router The remote router address\n     * @param _ism The remote ISM address\n     * @param _calls The sequence of calls to make\n     * @param _hookMetadata The hook metadata to override with for the hook set by the owner\n     * @return The Hyperlane message ID\n     */\n    function callRemoteWithOverrides(\n        uint32 _destination,\n        bytes32 _router,\n        bytes32 _ism,\n        CallLib.Call[] calldata _calls,\n        bytes memory _hookMetadata\n    ) public payable returns (bytes32) {\n        bytes memory _body = InterchainAccountMessage.encode(\n            msg.sender,\n            _ism,\n            _calls\n        );\n        return\n            _dispatchMessageWithMetadata(\n                _destination,\n                _router,\n                _ism,\n                _body,\n                _hookMetadata\n            );\n    }\n\n    // ============ Internal Functions ============\n\n    /**\n     * @dev Required for use of Router, compiler will not include this function in the bytecode\n     */\n    function _handle(uint32, bytes32, bytes calldata) internal pure override {\n        assert(false);\n    }\n\n    /**\n     * @notice Overrides Router._enrollRemoteRouter to also enroll a default ISM\n     * @param _destination The remote domain\n     * @param _address The address of the remote InterchainAccountRouter\n     * @dev Sets the default ISM to the zero address\n     */\n    function _enrollRemoteRouter(\n        uint32 _destination,\n        bytes32 _address\n    ) internal override {\n        _enrollRemoteRouterAndIsm(_destination, _address, bytes32(0));\n    }\n\n    // ============ Private Functions ============\n\n    /**\n     * @notice Registers the address of a remote ISM contract to use as default\n     * @param _destination The remote domain\n     * @param _ism The address of the remote ISM\n     */\n    function _enrollRemoteIsm(uint32 _destination, bytes32 _ism) private {\n        isms[_destination] = _ism;\n        emit RemoteIsmEnrolled(_destination, _ism);\n    }\n\n    /**\n     * @notice Registers the address of remote InterchainAccountRouter\n     * and ISM contracts to use as a default when making interchain calls\n     * @param _destination The remote domain\n     * @param _router The address of the remote InterchainAccountRouter\n     * @param _ism The address of the remote ISM\n     */\n    function _enrollRemoteRouterAndIsm(\n        uint32 _destination,\n        bytes32 _router,\n        bytes32 _ism\n    ) private {\n        require(\n            routers(_destination) == bytes32(0) &&\n                isms[_destination] == bytes32(0),\n            \"router and ISM defaults are immutable once set\"\n        );\n        Router._enrollRemoteRouter(_destination, _router);\n        _enrollRemoteIsm(_destination, _ism);\n    }\n\n    /**\n     * @notice Dispatches an InterchainAccountMessage to the remote router\n     * @param _destination The remote domain\n     * @param _router The address of the remote InterchainAccountRouter\n     * @param _ism The address of the remote ISM\n     * @param _body The InterchainAccountMessage body\n     */\n    function _dispatchMessage(\n        uint32 _destination,\n        bytes32 _router,\n        bytes32 _ism,\n        bytes memory _body\n    ) private returns (bytes32) {\n        require(_router != bytes32(0), \"no router specified for destination\");\n        emit RemoteCallDispatched(_destination, msg.sender, _router, _ism);\n        return mailbox.dispatch{value: msg.value}(_destination, _router, _body);\n    }\n\n    /**\n     * @notice Dispatches an InterchainAccountMessage to the remote router with hook metadata\n     * @param _destination The remote domain\n     * @param _router The address of the remote InterchainAccountRouter\n     * @param _ism The address of the remote ISM\n     * @param _body The InterchainAccountMessage body\n     * @param _hookMetadata The hook metadata to override with for the hook set by the owner\n     */\n    function _dispatchMessageWithMetadata(\n        uint32 _destination,\n        bytes32 _router,\n        bytes32 _ism,\n        bytes memory _body,\n        bytes memory _hookMetadata\n    ) private returns (bytes32) {\n        require(_router != bytes32(0), \"no router specified for destination\");\n        emit RemoteCallDispatched(_destination, msg.sender, _router, _ism);\n        return\n            mailbox.dispatch{value: msg.value}(\n                _destination,\n                _router,\n                _body,\n                _hookMetadata\n            );\n    }\n\n    /**\n     * @notice Returns the salt used to deploy an interchain account\n     * @param _origin The remote origin domain of the interchain account\n     * @param _owner The remote owner of the interchain account\n     * @param _router The remote origin InterchainAccountRouter\n     * @param _ism The local address of the ISM\n     * @return The CREATE2 salt used for deploying the interchain account\n     */\n    function _getSalt(\n        uint32 _origin,\n        bytes32 _owner,\n        bytes32 _router,\n        bytes32 _ism\n    ) private pure returns (bytes32) {\n        return keccak256(abi.encodePacked(_origin, _owner, _router, _ism));\n    }\n\n    /**\n     * @notice Returns the address of the interchain account on the local chain\n     * @param _salt The CREATE2 salt used for deploying the interchain account\n     * @return The address of the interchain account\n     */\n    function _getLocalInterchainAccount(\n        bytes32 _salt\n    ) private view returns (address payable) {\n        return payable(Create2.computeAddress(_salt, bytecodeHash));\n    }\n\n    /**\n     * @notice Returns the gas payment required to dispatch a message to the given domain's router.\n     * @param _destination The domain of the destination router.\n     * @return _gasPayment Payment computed by the registered hooks via MailboxClient.\n     */\n    function quoteGasPayment(\n        uint32 _destination\n    ) external view returns (uint256 _gasPayment) {\n        return _quoteDispatch(_destination, \"\");\n    }\n\n    /**\n     * @notice Returns the gas payment required to dispatch a given messageBody to the given domain's router with gas limit override.\n     * @param _destination The domain of the destination router.\n     * @param _messageBody The message body to be dispatched.\n     * @param gasLimit The gas limit to override with.\n     */\n    function quoteGasPayment(\n        uint32 _destination,\n        bytes calldata _messageBody,\n        uint256 gasLimit\n    ) external view returns (uint256 _gasPayment) {\n        bytes32 _router = _mustHaveRemoteRouter(_destination);\n        return\n            mailbox.quoteDispatch(\n                _destination,\n                _router,\n                _messageBody,\n                StandardHookMetadata.overrideGasLimit(gasLimit)\n            );\n    }\n}\n"
      },
      "contracts/middleware/InterchainQueryRouter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\n// ============ Internal Imports ============\nimport {Router} from \"../client/Router.sol\";\nimport {CallLib} from \"./libs/Call.sol\";\nimport {InterchainQueryMessage} from \"./libs/InterchainQueryMessage.sol\";\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\n\n// ============ External Imports ============\nimport {Create2} from \"@openzeppelin/contracts/utils/Create2.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\nimport {Initializable} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\n\n/**\n * @title Interchain Query Router that performs remote view calls on other chains and returns the result.\n * @dev Currently does not support Sovereign Consensus (user specified Interchain Security Modules).\n */\ncontract InterchainQueryRouter is Router {\n    using TypeCasts for address;\n    using TypeCasts for bytes32;\n    using InterchainQueryMessage for bytes;\n\n    /**\n     * @notice Emitted when a query is dispatched to another chain.\n     * @param destination The domain of the chain to query.\n     * @param sender The address that dispatched the query.\n     */\n    event QueryDispatched(uint32 indexed destination, address indexed sender);\n    /**\n     * @notice Emitted when a query is executed on the and callback dispatched to the origin chain.\n     * @param originDomain The domain of the chain that dispatched the query and receives the callback.\n     * @param sender The address to receive the result.\n     */\n    event QueryExecuted(uint32 indexed originDomain, bytes32 indexed sender);\n    /**\n     * @notice Emitted when a query is resolved on the origin chain.\n     * @param destination The domain of the chain that was queried.\n     * @param sender The address that resolved the query.\n     */\n    event QueryResolved(uint32 indexed destination, address indexed sender);\n\n    constructor(address _mailbox) Router(_mailbox) {}\n\n    /**\n     * @notice Initializes the Router contract with Hyperlane core contracts and the address of the interchain security module.\n     * @param _interchainGasPaymaster The address of the interchain gas paymaster contract.\n     * @param _interchainSecurityModule The address of the interchain security module contract.\n     * @param _owner The address with owner privileges.\n     */\n    function initialize(\n        address _interchainGasPaymaster,\n        address _interchainSecurityModule,\n        address _owner\n    ) external initializer {\n        _MailboxClient_initialize(\n            _interchainGasPaymaster,\n            _interchainSecurityModule,\n            _owner\n        );\n    }\n\n    /**\n     * @notice Dispatches a sequence of static calls (query) to the destination domain and set of callbacks to resolve the results on the dispatcher.\n     * @param _destination The domain of the chain to query.\n     * @param _to The address of the contract to query\n     * @param _data The calldata encoding the query\n     * @param _callback The calldata of the callback that will be made on the sender.\n     * The return value of the query will be appended.\n     * @dev Callbacks must be returned to the `msg.sender` for security reasons. Require this contract is the `msg.sender` on callbacks.\n     */\n    function query(\n        uint32 _destination,\n        address _to,\n        bytes memory _data,\n        bytes memory _callback\n    ) public returns (bytes32 messageId) {\n        emit QueryDispatched(_destination, msg.sender);\n\n        messageId = _dispatch(\n            _destination,\n            InterchainQueryMessage.encode(\n                msg.sender.addressToBytes32(),\n                _to,\n                _data,\n                _callback\n            )\n        );\n    }\n\n    /**\n     * @notice Dispatches a sequence of static calls (query) to the destination domain and set of callbacks to resolve the results on the dispatcher.\n     * @param _destination The domain of the chain to query.\n     * @param calls The sequence of static calls to dispatch and callbacks on the sender to resolve the results.\n     * @dev Recommend using CallLib.build to format the interchain calls.\n     * @dev Callbacks must be returned to the `msg.sender` for security reasons. Require this contract is the `msg.sender` on callbacks.\n     */\n    function query(\n        uint32 _destination,\n        CallLib.StaticCallWithCallback[] calldata calls\n    ) public returns (bytes32 messageId) {\n        emit QueryDispatched(_destination, msg.sender);\n        messageId = _dispatch(\n            _destination,\n            InterchainQueryMessage.encode(msg.sender.addressToBytes32(), calls)\n        );\n    }\n\n    /**\n     * @notice Handles a message from remote enrolled Interchain Query Router.\n     * @param _origin The domain of the chain that sent the message.\n     * @param _message The ABI-encoded interchain query.\n     */\n    function _handle(\n        uint32 _origin,\n        bytes32, // router sender\n        bytes calldata _message\n    ) internal override {\n        InterchainQueryMessage.MessageType messageType = _message.messageType();\n        bytes32 sender = _message.sender();\n        if (messageType == InterchainQueryMessage.MessageType.QUERY) {\n            CallLib.StaticCallWithCallback[]\n                memory callsWithCallback = InterchainQueryMessage\n                    .callsWithCallbacks(_message);\n            bytes[] memory callbacks = CallLib.multistaticcall(\n                callsWithCallback\n            );\n            emit QueryExecuted(_origin, sender);\n            _dispatch(\n                _origin,\n                InterchainQueryMessage.encode(sender, callbacks)\n            );\n        } else if (messageType == InterchainQueryMessage.MessageType.RESPONSE) {\n            address senderAddress = sender.bytes32ToAddress();\n            bytes[] memory rawCalls = _message.rawCalls();\n            CallLib.multicallto(senderAddress, rawCalls);\n            emit QueryResolved(_origin, senderAddress);\n        } else {\n            assert(false);\n        }\n    }\n}\n"
      },
      "contracts/middleware/libs/Call.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\n\nlibrary CallLib {\n    struct StaticCall {\n        // supporting non EVM targets\n        bytes32 to;\n        bytes data;\n    }\n\n    struct Call {\n        // supporting non EVM targets\n        bytes32 to;\n        uint256 value;\n        bytes data;\n    }\n\n    struct StaticCallWithCallback {\n        StaticCall _call;\n        bytes callback;\n    }\n\n    function call(\n        Call memory _call\n    ) internal returns (bytes memory returnData) {\n        return\n            Address.functionCallWithValue(\n                TypeCasts.bytes32ToAddress(_call.to),\n                _call.data,\n                _call.value\n            );\n    }\n\n    function staticcall(\n        StaticCall memory _call\n    ) private view returns (bytes memory) {\n        return\n            Address.functionStaticCall(\n                TypeCasts.bytes32ToAddress(_call.to),\n                _call.data\n            );\n    }\n\n    function staticcall(\n        StaticCallWithCallback memory _call\n    ) internal view returns (bytes memory callback) {\n        return bytes.concat(_call.callback, staticcall(_call._call));\n    }\n\n    function multicall(Call[] memory calls) internal {\n        uint256 i = 0;\n        uint256 len = calls.length;\n        while (i < len) {\n            call(calls[i]);\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    function multistaticcall(\n        StaticCallWithCallback[] memory _calls\n    ) internal view returns (bytes[] memory) {\n        uint256 i = 0;\n        uint256 len = _calls.length;\n        bytes[] memory callbacks = new bytes[](len);\n        while (i < len) {\n            callbacks[i] = staticcall(_calls[i]);\n            unchecked {\n                ++i;\n            }\n        }\n        return callbacks;\n    }\n\n    function multicallto(address to, bytes[] memory calls) internal {\n        uint256 i = 0;\n        uint256 len = calls.length;\n        while (i < len) {\n            Address.functionCall(to, calls[i]);\n            unchecked {\n                ++i;\n            }\n        }\n    }\n\n    function build(\n        bytes32 to,\n        bytes memory data\n    ) internal pure returns (StaticCall memory) {\n        return StaticCall(to, data);\n    }\n\n    function build(\n        address to,\n        bytes memory data\n    ) internal pure returns (StaticCall memory) {\n        return build(TypeCasts.addressToBytes32(to), data);\n    }\n\n    function build(\n        bytes32 to,\n        uint256 value,\n        bytes memory data\n    ) internal pure returns (Call memory) {\n        return Call(to, value, data);\n    }\n\n    function build(\n        address to,\n        uint256 value,\n        bytes memory data\n    ) internal pure returns (Call memory) {\n        return Call(TypeCasts.addressToBytes32(to), value, data);\n    }\n\n    function build(\n        bytes32 to,\n        bytes memory data,\n        bytes memory callback\n    ) internal pure returns (StaticCallWithCallback memory) {\n        return StaticCallWithCallback(build(to, data), callback);\n    }\n\n    function build(\n        address to,\n        bytes memory data,\n        bytes memory callback\n    ) internal pure returns (StaticCallWithCallback memory) {\n        return StaticCallWithCallback(build(to, data), callback);\n    }\n}\n"
      },
      "contracts/middleware/libs/InterchainAccountMessage.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {CallLib} from \"./Call.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\n\n/**\n * Format of message:\n * [   0:  32] ICA owner\n * [  32:  64] ICA ISM\n * [  64:????] Calls, abi encoded\n */\nlibrary InterchainAccountMessage {\n    using TypeCasts for bytes32;\n\n    /**\n     * @notice Returns formatted (packed) InterchainAccountMessage\n     * @dev This function should only be used in memory message construction.\n     * @param _owner The owner of the interchain account\n     * @param _ism The address of the remote ISM\n     * @param _to The address of the contract to call\n     * @param _value The value to include in the call\n     * @param _data The calldata\n     * @return Formatted message body\n     */\n    function encode(\n        address _owner,\n        bytes32 _ism,\n        address _to,\n        uint256 _value,\n        bytes memory _data\n    ) internal pure returns (bytes memory) {\n        CallLib.Call[] memory _calls = new CallLib.Call[](1);\n        _calls[0] = CallLib.build(_to, _value, _data);\n        return abi.encode(TypeCasts.addressToBytes32(_owner), _ism, _calls);\n    }\n\n    /**\n     * @notice Returns formatted (packed) InterchainAccountMessage\n     * @dev This function should only be used in memory message construction.\n     * @param _owner The owner of the interchain account\n     * @param _ism The address of the remote ISM\n     * @param _calls The sequence of calls to make\n     * @return Formatted message body\n     */\n    function encode(\n        bytes32 _owner,\n        bytes32 _ism,\n        CallLib.Call[] calldata _calls\n    ) internal pure returns (bytes memory) {\n        return abi.encode(_owner, _ism, _calls);\n    }\n\n    /**\n     * @notice Returns formatted (packed) InterchainAccountMessage\n     * @dev This function should only be used in memory message construction.\n     * @param _owner The owner of the interchain account\n     * @param _ism The address of the remote ISM\n     * @param _calls The sequence of calls to make\n     * @return Formatted message body\n     */\n    function encode(\n        address _owner,\n        bytes32 _ism,\n        CallLib.Call[] calldata _calls\n    ) internal pure returns (bytes memory) {\n        return encode(TypeCasts.addressToBytes32(_owner), _ism, _calls);\n    }\n\n    /**\n     * @notice Parses and returns the calls from the provided message\n     * @param _message The interchain account message\n     * @return The array of calls\n     */\n    function decode(\n        bytes calldata _message\n    ) internal pure returns (bytes32, bytes32, CallLib.Call[] memory) {\n        return abi.decode(_message, (bytes32, bytes32, CallLib.Call[]));\n    }\n\n    /**\n     * @notice Parses and returns the ISM address from the provided message\n     * @param _message The interchain account message\n     * @return The ISM encoded in the message\n     */\n    function ism(bytes calldata _message) internal pure returns (address) {\n        return address(bytes20(_message[44:64]));\n    }\n}\n"
      },
      "contracts/middleware/libs/InterchainQueryMessage.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {CallLib} from \"./Call.sol\";\n\n/**\n * Format of message:\n * [   0: 32] Sender address\n * [  32: 64] Message type (left padded with zeroes)\n * [  64:???] Encoded call array\n */\nlibrary InterchainQueryMessage {\n    uint256 private constant SENDER_OFFSET = 0;\n    uint256 private constant TYPE_OFFSET = 32;\n    uint256 private constant CALLS_OFFSET = 64;\n\n    enum MessageType {\n        QUERY,\n        RESPONSE\n    }\n\n    /**\n     * @notice Parses and returns the query sender from the provided message\n     * @param _message The interchain query message\n     * @return The query sender as bytes32\n     */\n    function sender(bytes calldata _message) internal pure returns (bytes32) {\n        return bytes32(_message[SENDER_OFFSET:TYPE_OFFSET]);\n    }\n\n    /**\n     * @notice Parses and returns the message type from the provided message\n     * @param _message The interchain query message\n     * @return The message type (query or response)\n     */\n    function messageType(\n        bytes calldata _message\n    ) internal pure returns (MessageType) {\n        // left padded with zeroes\n        return MessageType(uint8(bytes1(_message[CALLS_OFFSET - 1])));\n    }\n\n    /**\n     * @notice Returns formatted InterchainQueryMessage, type == QUERY\n     * @param _sender The query sender as bytes32\n     * @param _calls The sequence of queries to make, with the corresponding\n     * response callbacks\n     * @return Formatted message body\n     */\n    function encode(\n        bytes32 _sender,\n        CallLib.StaticCallWithCallback[] calldata _calls\n    ) internal pure returns (bytes memory) {\n        return abi.encode(_sender, MessageType.QUERY, _calls);\n    }\n\n    /**\n     * @notice Returns formatted InterchainQueryMessage, type == QUERY\n     * @param _sender The query sender as bytes32\n     * @param _to The address of the contract to query\n     * @param _data The calldata encoding the query\n     * @param _callback The calldata of the callback that will be made on the sender.\n     * The return value of the query will be appended.\n     * @return Formatted message body\n     */\n    function encode(\n        bytes32 _sender,\n        address _to,\n        bytes memory _data,\n        bytes memory _callback\n    ) internal pure returns (bytes memory) {\n        CallLib.StaticCallWithCallback[]\n            memory _calls = new CallLib.StaticCallWithCallback[](1);\n        _calls[0] = CallLib.build(_to, _data, _callback);\n        return abi.encode(_sender, MessageType.QUERY, _calls);\n    }\n\n    /**\n     * @notice Parses and returns the calls and callbacks from the message\n     * @param _message The interchain query message, type == QUERY\n     * @return _calls The sequence of queries to make with the corresponding\n     * response callbacks\n     */\n    function callsWithCallbacks(\n        bytes calldata _message\n    ) internal pure returns (CallLib.StaticCallWithCallback[] memory _calls) {\n        assert(messageType(_message) == MessageType.QUERY);\n        (, , _calls) = abi.decode(\n            _message,\n            (bytes32, MessageType, CallLib.StaticCallWithCallback[])\n        );\n    }\n\n    /**\n     * @notice Returns formatted InterchainQueryMessage, type == RESPONSE\n     * @param _sender The query sender as bytes32\n     * @param _calls The sequence of callbacks to make\n     * @return Formatted message body\n     */\n    function encode(\n        bytes32 _sender,\n        bytes[] memory _calls\n    ) internal pure returns (bytes memory) {\n        return abi.encode(_sender, MessageType.RESPONSE, _calls);\n    }\n\n    /**\n     * @notice Parses and returns the callbacks from the message\n     * @param _message The interchain query message, type == RESPONSE\n     * @return _calls The sequence of callbacks to make\n     */\n    function rawCalls(\n        bytes calldata _message\n    ) internal pure returns (bytes[] memory _calls) {\n        assert(messageType(_message) == MessageType.RESPONSE);\n        (, , _calls) = abi.decode(_message, (bytes32, MessageType, bytes[]));\n    }\n}\n"
      },
      "contracts/middleware/libs/OwnableMulticall.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\n// ============ Internal Imports ============\nimport {CallLib} from \"./Call.sol\";\n\n/*\n * @title OwnableMulticall\n * @dev Permits immutable owner address to execute calls with value to other contracts.\n */\ncontract OwnableMulticall {\n    address public immutable owner;\n\n    constructor(address _owner) {\n        owner = _owner;\n    }\n\n    modifier onlyOwner() {\n        require(msg.sender == owner, \"!owner\");\n        _;\n    }\n\n    function multicall(CallLib.Call[] calldata calls) external onlyOwner {\n        return CallLib.multicall(calls);\n    }\n\n    // solhint-disable-next-line no-empty-blocks\n    receive() external payable {}\n}\n"
      },
      "contracts/middleware/liquidity-layer/adapters/CircleBridgeAdapter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {Router} from \"../../../client/Router.sol\";\n\nimport {ITokenMessenger} from \"../interfaces/circle/ITokenMessenger.sol\";\nimport {ICircleMessageTransmitter} from \"../interfaces/circle/ICircleMessageTransmitter.sol\";\nimport {ILiquidityLayerAdapter} from \"../interfaces/ILiquidityLayerAdapter.sol\";\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract CircleBridgeAdapter is ILiquidityLayerAdapter, Router {\n    using SafeERC20 for IERC20;\n\n    /// @notice The TokenMessenger contract.\n    ITokenMessenger public tokenMessenger;\n\n    /// @notice The Circle MessageTransmitter contract.\n    ICircleMessageTransmitter public circleMessageTransmitter;\n\n    /// @notice The LiquidityLayerRouter contract.\n    address public liquidityLayerRouter;\n\n    /// @notice Hyperlane domain => Circle domain.\n    /// ATM, known Circle domains are Ethereum = 0 and Avalanche = 1.\n    /// Note this could result in ambiguity between the Circle domain being\n    /// Ethereum or unknown.\n    mapping(uint32 => uint32) public hyperlaneDomainToCircleDomain;\n\n    /// @notice Token symbol => address of token on local chain.\n    mapping(string => IERC20) public tokenSymbolToAddress;\n\n    /// @notice Local chain token address => token symbol.\n    mapping(address => string) public tokenAddressToSymbol;\n\n    /**\n     * @notice Emits the nonce of the Circle message when a token is bridged.\n     * @param nonce The nonce of the Circle message.\n     */\n    event BridgedToken(uint64 nonce);\n\n    /**\n     * @notice Emitted when the Hyperlane domain to Circle domain mapping is updated.\n     * @param hyperlaneDomain The Hyperlane domain.\n     * @param circleDomain The Circle domain.\n     */\n    event DomainAdded(uint32 indexed hyperlaneDomain, uint32 circleDomain);\n\n    /**\n     * @notice Emitted when a local token and its token symbol have been added.\n     */\n    event TokenAdded(address indexed token, string indexed symbol);\n\n    /**\n     * @notice Emitted when a local token and its token symbol have been removed.\n     */\n    event TokenRemoved(address indexed token, string indexed symbol);\n\n    modifier onlyLiquidityLayerRouter() {\n        require(msg.sender == liquidityLayerRouter, \"!liquidityLayerRouter\");\n        _;\n    }\n\n    constructor(address _mailbox) Router(_mailbox) {}\n\n    /**\n     * @param _owner The new owner.\n     * @param _tokenMessenger The TokenMessenger contract.\n     * @param _circleMessageTransmitter The Circle MessageTransmitter contract.\n     * @param _liquidityLayerRouter The LiquidityLayerRouter contract.\n     */\n    function initialize(\n        address _owner,\n        address _tokenMessenger,\n        address _circleMessageTransmitter,\n        address _liquidityLayerRouter\n    ) external initializer {\n        __Ownable_init();\n        _transferOwnership(_owner);\n\n        tokenMessenger = ITokenMessenger(_tokenMessenger);\n        circleMessageTransmitter = ICircleMessageTransmitter(\n            _circleMessageTransmitter\n        );\n        liquidityLayerRouter = _liquidityLayerRouter;\n    }\n\n    function sendTokens(\n        uint32 _destinationDomain,\n        bytes32, // _recipientAddress, unused\n        address _token,\n        uint256 _amount\n    ) external onlyLiquidityLayerRouter returns (bytes memory) {\n        string memory _tokenSymbol = tokenAddressToSymbol[_token];\n        require(\n            bytes(_tokenSymbol).length > 0,\n            \"CircleBridgeAdapter: Unknown token\"\n        );\n\n        uint32 _circleDomain = hyperlaneDomainToCircleDomain[\n            _destinationDomain\n        ];\n        bytes32 _remoteRouter = _mustHaveRemoteRouter(_destinationDomain);\n\n        // Approve the token to Circle. We assume that the LiquidityLayerRouter\n        // has already transferred the token to this contract.\n        require(\n            IERC20(_token).approve(address(tokenMessenger), _amount),\n            \"!approval\"\n        );\n\n        uint64 _nonce = tokenMessenger.depositForBurn(\n            _amount,\n            _circleDomain,\n            _remoteRouter, // Mint to the remote router\n            _token\n        );\n\n        emit BridgedToken(_nonce);\n        return abi.encode(_nonce, _tokenSymbol);\n    }\n\n    // Returns the token and amount sent\n    function receiveTokens(\n        uint32 _originDomain, // Hyperlane domain\n        address _recipient,\n        uint256 _amount,\n        bytes calldata _adapterData // The adapter data from the message\n    ) external onlyLiquidityLayerRouter returns (address, uint256) {\n        _mustHaveRemoteRouter(_originDomain);\n        // The origin Circle domain\n        uint32 _originCircleDomain = hyperlaneDomainToCircleDomain[\n            _originDomain\n        ];\n        // Get the token symbol and nonce of the transfer from the _adapterData\n        (uint64 _nonce, string memory _tokenSymbol) = abi.decode(\n            _adapterData,\n            (uint64, string)\n        );\n\n        // Require the circle message to have been processed\n        bytes32 _nonceId = _circleNonceId(_originCircleDomain, _nonce);\n        require(\n            circleMessageTransmitter.usedNonces(_nonceId),\n            \"Circle message not processed yet\"\n        );\n\n        IERC20 _token = tokenSymbolToAddress[_tokenSymbol];\n        require(\n            address(_token) != address(0),\n            \"CircleBridgeAdapter: Unknown token\"\n        );\n\n        // Transfer the token out to the recipient\n        // Circle doesn't charge any fee, so we can safely transfer out the\n        // exact amount that was bridged over.\n        _token.safeTransfer(_recipient, _amount);\n\n        return (address(_token), _amount);\n    }\n\n    // This contract is only a Router to be aware of remote router addresses,\n    // and doesn't actually send/handle Hyperlane messages directly\n    function _handle(\n        uint32, // origin\n        bytes32, // sender\n        bytes calldata // message\n    ) internal pure override {\n        revert(\"No messages expected\");\n    }\n\n    function addDomain(\n        uint32 _hyperlaneDomain,\n        uint32 _circleDomain\n    ) external onlyOwner {\n        hyperlaneDomainToCircleDomain[_hyperlaneDomain] = _circleDomain;\n\n        emit DomainAdded(_hyperlaneDomain, _circleDomain);\n    }\n\n    function addToken(\n        address _token,\n        string calldata _tokenSymbol\n    ) external onlyOwner {\n        require(\n            _token != address(0) && bytes(_tokenSymbol).length > 0,\n            \"Cannot add default values\"\n        );\n\n        // Require the token and token symbol to be unset.\n        address _existingToken = address(tokenSymbolToAddress[_tokenSymbol]);\n        require(_existingToken == address(0), \"token symbol already has token\");\n\n        string memory _existingSymbol = tokenAddressToSymbol[_token];\n        require(\n            bytes(_existingSymbol).length == 0,\n            \"token already has token symbol\"\n        );\n\n        tokenAddressToSymbol[_token] = _tokenSymbol;\n        tokenSymbolToAddress[_tokenSymbol] = IERC20(_token);\n\n        emit TokenAdded(_token, _tokenSymbol);\n    }\n\n    function removeToken(\n        address _token,\n        string calldata _tokenSymbol\n    ) external onlyOwner {\n        // Require the provided token and token symbols match what's in storage.\n        address _existingToken = address(tokenSymbolToAddress[_tokenSymbol]);\n        require(_existingToken == _token, \"Token mismatch\");\n\n        string memory _existingSymbol = tokenAddressToSymbol[_token];\n        require(\n            keccak256(bytes(_existingSymbol)) == keccak256(bytes(_tokenSymbol)),\n            \"Token symbol mismatch\"\n        );\n\n        // Delete them from storage.\n        delete tokenSymbolToAddress[_tokenSymbol];\n        delete tokenAddressToSymbol[_token];\n\n        emit TokenRemoved(_token, _tokenSymbol);\n    }\n\n    /**\n     * @notice Gets the Circle nonce ID by hashing _originCircleDomain and _nonce.\n     * @param _originCircleDomain Domain of chain where the transfer originated\n     * @param _nonce The unique identifier for the message from source to\n              destination\n     * @return hash of source and nonce\n     */\n    function _circleNonceId(\n        uint32 _originCircleDomain,\n        uint64 _nonce\n    ) internal pure returns (bytes32) {\n        return keccak256(abi.encodePacked(_originCircleDomain, _nonce));\n    }\n}\n"
      },
      "contracts/middleware/liquidity-layer/adapters/PortalAdapter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {Router} from \"../../../client/Router.sol\";\n\nimport {IPortalTokenBridge} from \"../interfaces/portal/IPortalTokenBridge.sol\";\nimport {ILiquidityLayerAdapter} from \"../interfaces/ILiquidityLayerAdapter.sol\";\nimport {TypeCasts} from \"../../../libs/TypeCasts.sol\";\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\n\ncontract PortalAdapter is ILiquidityLayerAdapter, Router {\n    /// @notice The Portal TokenBridge contract.\n    IPortalTokenBridge public portalTokenBridge;\n\n    /// @notice The LiquidityLayerRouter contract.\n    address public liquidityLayerRouter;\n\n    /// @notice Hyperlane domain => Wormhole domain.\n    mapping(uint32 => uint16) public hyperlaneDomainToWormholeDomain;\n    /// @notice transferId => token address\n    mapping(bytes32 => address) public portalTransfersProcessed;\n\n    // We could technically use Portal's sequence number here but it doesn't\n    // get passed through, so we would have to parse the VAA twice\n    // 224 bits should be large enough and allows us to pack into a single slot\n    // with a Hyperlane domain\n    uint224 public nonce = 0;\n\n    constructor(address _mailbox) Router(_mailbox) {}\n\n    /**\n     * @notice Emits the nonce of the Portal message when a token is bridged.\n     * @param nonce The nonce of the Portal message.\n     * @param portalSequence The sequence of the Portal message.\n     * @param destination The hyperlane domain of the destination\n     */\n    event BridgedToken(\n        uint256 nonce,\n        uint64 portalSequence,\n        uint32 destination\n    );\n\n    /**\n     * @notice Emitted when the Hyperlane domain to Wormhole domain mapping is updated.\n     * @param hyperlaneDomain The Hyperlane domain.\n     * @param wormholeDomain The Wormhole domain.\n     */\n    event DomainAdded(uint32 indexed hyperlaneDomain, uint32 wormholeDomain);\n\n    modifier onlyLiquidityLayerRouter() {\n        require(msg.sender == liquidityLayerRouter, \"!liquidityLayerRouter\");\n        _;\n    }\n\n    /**\n     * @param _owner The new owner.\n     * @param _portalTokenBridge The Portal TokenBridge contract.\n     * @param _liquidityLayerRouter The LiquidityLayerRouter contract.\n     */\n    function initialize(\n        address _owner,\n        address _portalTokenBridge,\n        address _liquidityLayerRouter\n    ) public initializer {\n        // Transfer ownership of the contract to deployer\n        _transferOwnership(_owner);\n\n        portalTokenBridge = IPortalTokenBridge(_portalTokenBridge);\n        liquidityLayerRouter = _liquidityLayerRouter;\n    }\n\n    /**\n     * Sends tokens as requested by the router\n     * @param _destinationDomain The hyperlane domain of the destination\n     * @param _token The token address\n     * @param _amount The amount of tokens to send\n     */\n    function sendTokens(\n        uint32 _destinationDomain,\n        bytes32, // _recipientAddress, unused\n        address _token,\n        uint256 _amount\n    ) external onlyLiquidityLayerRouter returns (bytes memory) {\n        nonce = nonce + 1;\n        uint16 _wormholeDomain = hyperlaneDomainToWormholeDomain[\n            _destinationDomain\n        ];\n\n        bytes32 _remoteRouter = _mustHaveRemoteRouter(_destinationDomain);\n\n        // Approve the token to Portal. We assume that the LiquidityLayerRouter\n        // has already transferred the token to this contract.\n        require(\n            IERC20(_token).approve(address(portalTokenBridge), _amount),\n            \"!approval\"\n        );\n\n        uint64 _portalSequence = portalTokenBridge.transferTokensWithPayload(\n            _token,\n            _amount,\n            _wormholeDomain,\n            _remoteRouter,\n            // Nonce for grouping Portal messages in the same tx, not relevant for us\n            // https://book.wormhole.com/technical/evm/coreLayer.html#emitting-a-vaa\n            0,\n            // Portal Payload used in completeTransfer\n            abi.encode(localDomain, nonce)\n        );\n\n        emit BridgedToken(nonce, _portalSequence, _destinationDomain);\n        return abi.encode(nonce);\n    }\n\n    /**\n     * Sends the tokens to the recipient as requested by the router\n     * @param _originDomain The hyperlane domain of the origin\n     * @param _recipient The address of the recipient\n     * @param _amount The amount of tokens to send\n     * @param _adapterData The adapter data from the origin chain, containing the nonce\n     */\n    function receiveTokens(\n        uint32 _originDomain, // Hyperlane domain\n        address _recipient,\n        uint256 _amount,\n        bytes calldata _adapterData // The adapter data from the message\n    ) external onlyLiquidityLayerRouter returns (address, uint256) {\n        // Get the nonce information from the adapterData\n        uint224 _nonce = abi.decode(_adapterData, (uint224));\n\n        address _tokenAddress = portalTransfersProcessed[\n            transferId(_originDomain, _nonce)\n        ];\n\n        require(\n            _tokenAddress != address(0x0),\n            \"Portal Transfer has not yet been completed\"\n        );\n\n        IERC20 _token = IERC20(_tokenAddress);\n\n        // Transfer the token out to the recipient\n        // TODO: use safeTransfer\n        // Portal doesn't charge any fee, so we can safely transfer out the\n        // exact amount that was bridged over.\n        require(_token.transfer(_recipient, _amount), \"!transfer out\");\n        return (_tokenAddress, _amount);\n    }\n\n    /**\n     * Completes the Portal transfer which sends the funds to this adapter.\n     * The router can call receiveTokens to move those funds to the ultimate recipient.\n     * @param encodedVm The VAA from the Wormhole Guardians\n     */\n    function completeTransfer(bytes memory encodedVm) public {\n        bytes memory _tokenBridgeTransferWithPayload = portalTokenBridge\n            .completeTransferWithPayload(encodedVm);\n        IPortalTokenBridge.TransferWithPayload\n            memory _transfer = portalTokenBridge.parseTransferWithPayload(\n                _tokenBridgeTransferWithPayload\n            );\n\n        (uint32 _originDomain, uint224 _nonce) = abi.decode(\n            _transfer.payload,\n            (uint32, uint224)\n        );\n\n        // Logic taken from here https://github.com/wormhole-foundation/wormhole/blob/dev.v2/ethereum/contracts/bridge/Bridge.sol#L503\n        address tokenAddress = _transfer.tokenChain ==\n            hyperlaneDomainToWormholeDomain[localDomain]\n            ? TypeCasts.bytes32ToAddress(_transfer.tokenAddress)\n            : portalTokenBridge.wrappedAsset(\n                _transfer.tokenChain,\n                _transfer.tokenAddress\n            );\n\n        portalTransfersProcessed[\n            transferId(_originDomain, _nonce)\n        ] = tokenAddress;\n    }\n\n    // This contract is only a Router to be aware of remote router addresses,\n    // and doesn't actually send/handle Hyperlane messages directly\n    function _handle(\n        uint32, // origin\n        bytes32, // sender\n        bytes calldata // message\n    ) internal pure override {\n        revert(\"No messages expected\");\n    }\n\n    function addDomain(\n        uint32 _hyperlaneDomain,\n        uint16 _wormholeDomain\n    ) external onlyOwner {\n        hyperlaneDomainToWormholeDomain[_hyperlaneDomain] = _wormholeDomain;\n\n        emit DomainAdded(_hyperlaneDomain, _wormholeDomain);\n    }\n\n    /**\n     * The key that is used to track fulfilled Portal transfers\n     * @param _hyperlaneDomain The hyperlane of the origin\n     * @param _nonce The nonce of the adapter on the origin\n     */\n    function transferId(\n        uint32 _hyperlaneDomain,\n        uint224 _nonce\n    ) public pure returns (bytes32) {\n        return bytes32(abi.encodePacked(_hyperlaneDomain, _nonce));\n    }\n}\n"
      },
      "contracts/middleware/liquidity-layer/interfaces/circle/ICircleMessageTransmitter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\ninterface ICircleMessageTransmitter {\n    /**\n     * @notice Receive a message. Messages with a given nonce\n     * can only be broadcast once for a (sourceDomain, destinationDomain)\n     * pair. The message body of a valid message is passed to the\n     * specified recipient for further processing.\n     *\n     * @dev Attestation format:\n     * A valid attestation is the concatenated 65-byte signature(s) of exactly\n     * `thresholdSignature` signatures, in increasing order of attester address.\n     * ***If the attester addresses recovered from signatures are not in\n     * increasing order, signature verification will fail.***\n     * If incorrect number of signatures or duplicate signatures are supplied,\n     * signature verification will fail.\n     *\n     * Message format:\n     * Field Bytes Type Index\n     * version 4 uint32 0\n     * sourceDomain 4 uint32 4\n     * destinationDomain 4 uint32 8\n     * nonce 8 uint64 12\n     * sender 32 bytes32 20\n     * recipient 32 bytes32 52\n     * messageBody dynamic bytes 84\n     * @param _message Message bytes\n     * @param _attestation Concatenated 65-byte signature(s) of `_message`, in increasing order\n     * of the attester address recovered from signatures.\n     * @return success bool, true if successful\n     */\n    function receiveMessage(\n        bytes memory _message,\n        bytes calldata _attestation\n    ) external returns (bool success);\n\n    function usedNonces(bytes32 _nonceId) external view returns (bool);\n}\n"
      },
      "contracts/middleware/liquidity-layer/interfaces/circle/ITokenMessenger.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\ninterface ITokenMessenger {\n    event MessageSent(bytes message);\n\n    /**\n     * @notice Deposits and burns tokens from sender to be minted on destination domain.\n     * Emits a `DepositForBurn` event.\n     * @dev reverts if:\n     * - given burnToken is not supported\n     * - given destinationDomain has no TokenMessenger registered\n     * - transferFrom() reverts. For example, if sender's burnToken balance or approved allowance\n     * to this contract is less than `amount`.\n     * - burn() reverts. For example, if `amount` is 0.\n     * - MessageTransmitter returns false or reverts.\n     * @param _amount amount of tokens to burn\n     * @param _destinationDomain destination domain (ETH = 0, AVAX = 1)\n     * @param _mintRecipient address of mint recipient on destination domain\n     * @param _burnToken address of contract to burn deposited tokens, on local domain\n     * @return _nonce unique nonce reserved by message\n     */\n    function depositForBurn(\n        uint256 _amount,\n        uint32 _destinationDomain,\n        bytes32 _mintRecipient,\n        address _burnToken\n    ) external returns (uint64 _nonce);\n\n    /**\n     * @notice Deposits and burns tokens from sender to be minted on destination domain. The mint\n     * on the destination domain must be called by `_destinationCaller`.\n     * WARNING: if the `_destinationCaller` does not represent a valid address as bytes32, then it will not be possible\n     * to broadcast the message on the destination domain. This is an advanced feature, and the standard\n     * depositForBurn() should be preferred for use cases where a specific destination caller is not required.\n     * Emits a `DepositForBurn` event.\n     * @dev reverts if:\n     * - given destinationCaller is zero address\n     * - given burnToken is not supported\n     * - given destinationDomain has no TokenMessenger registered\n     * - transferFrom() reverts. For example, if sender's burnToken balance or approved allowance\n     * to this contract is less than `amount`.\n     * - burn() reverts. For example, if `amount` is 0.\n     * - MessageTransmitter returns false or reverts.\n     * @param _amount amount of tokens to burn\n     * @param _destinationDomain destination domain\n     * @param _mintRecipient address of mint recipient on destination domain\n     * @param _burnToken address of contract to burn deposited tokens, on local domain\n     * @param _destinationCaller caller on the destination domain, as bytes32\n     * @return _nonce unique nonce reserved by message\n     */\n    function depositForBurnWithCaller(\n        uint256 _amount,\n        uint32 _destinationDomain,\n        bytes32 _mintRecipient,\n        address _burnToken,\n        bytes32 _destinationCaller\n    ) external returns (uint64 _nonce);\n}\n"
      },
      "contracts/middleware/liquidity-layer/interfaces/ILiquidityLayerAdapter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\ninterface ILiquidityLayerAdapter {\n    function sendTokens(\n        uint32 _destinationDomain,\n        bytes32 _recipientAddress,\n        address _token,\n        uint256 _amount\n    ) external returns (bytes memory _adapterData);\n\n    function receiveTokens(\n        uint32 _originDomain, // Hyperlane domain\n        address _recipientAddress,\n        uint256 _amount,\n        bytes calldata _adapterData // The adapter data from the message\n    ) external returns (address, uint256);\n}\n"
      },
      "contracts/middleware/liquidity-layer/interfaces/portal/IPortalTokenBridge.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\n// Portal's interface from their docs\ninterface IPortalTokenBridge {\n    struct Transfer {\n        uint8 payloadID;\n        uint256 amount;\n        bytes32 tokenAddress;\n        uint16 tokenChain;\n        bytes32 to;\n        uint16 toChain;\n        uint256 fee;\n    }\n\n    struct TransferWithPayload {\n        uint8 payloadID;\n        uint256 amount;\n        bytes32 tokenAddress;\n        uint16 tokenChain;\n        bytes32 to;\n        uint16 toChain;\n        bytes32 fromAddress;\n        bytes payload;\n    }\n\n    struct AssetMeta {\n        uint8 payloadID;\n        bytes32 tokenAddress;\n        uint16 tokenChain;\n        uint8 decimals;\n        bytes32 symbol;\n        bytes32 name;\n    }\n\n    struct RegisterChain {\n        bytes32 module;\n        uint8 action;\n        uint16 chainId;\n        uint16 emitterChainID;\n        bytes32 emitterAddress;\n    }\n\n    struct UpgradeContract {\n        bytes32 module;\n        uint8 action;\n        uint16 chainId;\n        bytes32 newContract;\n    }\n\n    struct RecoverChainId {\n        bytes32 module;\n        uint8 action;\n        uint256 evmChainId;\n        uint16 newChainId;\n    }\n\n    event ContractUpgraded(\n        address indexed oldContract,\n        address indexed newContract\n    );\n\n    function transferTokensWithPayload(\n        address token,\n        uint256 amount,\n        uint16 recipientChain,\n        bytes32 recipient,\n        uint32 nonce,\n        bytes memory payload\n    ) external payable returns (uint64 sequence);\n\n    function completeTransferWithPayload(\n        bytes memory encodedVm\n    ) external returns (bytes memory);\n\n    function parseTransferWithPayload(\n        bytes memory encoded\n    ) external pure returns (TransferWithPayload memory transfer);\n\n    function wrappedAsset(\n        uint16 tokenChainId,\n        bytes32 tokenAddress\n    ) external view returns (address);\n\n    function isWrappedAsset(address token) external view returns (bool);\n}\n"
      },
      "contracts/middleware/liquidity-layer/LiquidityLayerRouter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {Router} from \"../../client/Router.sol\";\n\nimport {ILiquidityLayerRouter} from \"../../interfaces/ILiquidityLayerRouter.sol\";\nimport {ICircleMessageTransmitter} from \"./interfaces/circle/ICircleMessageTransmitter.sol\";\nimport {ILiquidityLayerAdapter} from \"./interfaces/ILiquidityLayerAdapter.sol\";\nimport {ILiquidityLayerMessageRecipient} from \"../../interfaces/ILiquidityLayerMessageRecipient.sol\";\n\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ncontract LiquidityLayerRouter is Router, ILiquidityLayerRouter {\n    using SafeERC20 for IERC20;\n\n    // Token bridge => adapter address\n    mapping(string => address) public liquidityLayerAdapters;\n\n    event LiquidityLayerAdapterSet(string indexed bridge, address adapter);\n\n    constructor(address _mailbox) Router(_mailbox) {}\n\n    /**\n     * @notice Initializes the Router contract with Hyperlane core contracts and the address of the interchain security module.\n     * @param _interchainGasPaymaster The address of the interchain gas paymaster contract.\n     * @param _interchainSecurityModule The address of the interchain security module contract.\n     * @param _owner The address with owner privileges.\n     */\n    function initialize(\n        address _interchainGasPaymaster,\n        address _interchainSecurityModule,\n        address _owner\n    ) external initializer {\n        _MailboxClient_initialize(\n            _interchainGasPaymaster,\n            _interchainSecurityModule,\n            _owner\n        );\n    }\n\n    function dispatchWithTokens(\n        uint32 _destinationDomain,\n        bytes32 _recipientAddress,\n        address _token,\n        uint256 _amount,\n        string calldata _bridge,\n        bytes calldata _messageBody\n    ) external returns (bytes32) {\n        ILiquidityLayerAdapter _adapter = _getAdapter(_bridge);\n\n        // Transfer the tokens to the adapter\n        IERC20(_token).safeTransferFrom(msg.sender, address(_adapter), _amount);\n\n        // Reverts if the bridge was unsuccessful.\n        // Gets adapter-specific data that is encoded into the message\n        // ultimately sent via Hyperlane.\n        bytes memory _adapterData = _adapter.sendTokens(\n            _destinationDomain,\n            _recipientAddress,\n            _token,\n            _amount\n        );\n\n        // The user's message \"wrapped\" with metadata required by this middleware\n        bytes memory _messageWithMetadata = abi.encode(\n            TypeCasts.addressToBytes32(msg.sender),\n            _recipientAddress, // The \"user\" recipient\n            _amount, // The amount of the tokens sent over the bridge\n            _bridge, // The destination token bridge ID\n            _adapterData, // The adapter-specific data\n            _messageBody // The \"user\" message\n        );\n\n        // Dispatch the _messageWithMetadata to the destination's LiquidityLayerRouter.\n        return _dispatch(_destinationDomain, _messageWithMetadata);\n    }\n\n    // Handles a message from an enrolled remote LiquidityLayerRouter\n    function _handle(\n        uint32 _origin,\n        bytes32, // _sender, unused\n        bytes calldata _message\n    ) internal override {\n        // Decode the message with metadata, \"unwrapping\" the user's message body\n        (\n            bytes32 _originalSender,\n            bytes32 _userRecipientAddress,\n            uint256 _amount,\n            string memory _bridge,\n            bytes memory _adapterData,\n            bytes memory _userMessageBody\n        ) = abi.decode(\n                _message,\n                (bytes32, bytes32, uint256, string, bytes, bytes)\n            );\n\n        ILiquidityLayerMessageRecipient _userRecipient = ILiquidityLayerMessageRecipient(\n                TypeCasts.bytes32ToAddress(_userRecipientAddress)\n            );\n\n        // Reverts if the adapter hasn't received the bridged tokens yet\n        (address _token, uint256 _receivedAmount) = _getAdapter(_bridge)\n            .receiveTokens(\n                _origin,\n                address(_userRecipient),\n                _amount,\n                _adapterData\n            );\n\n        if (_userMessageBody.length > 0) {\n            _userRecipient.handleWithTokens(\n                _origin,\n                _originalSender,\n                _userMessageBody,\n                _token,\n                _receivedAmount\n            );\n        }\n    }\n\n    function setLiquidityLayerAdapter(\n        string calldata _bridge,\n        address _adapter\n    ) external onlyOwner {\n        liquidityLayerAdapters[_bridge] = _adapter;\n        emit LiquidityLayerAdapterSet(_bridge, _adapter);\n    }\n\n    function _getAdapter(\n        string memory _bridge\n    ) internal view returns (ILiquidityLayerAdapter _adapter) {\n        _adapter = ILiquidityLayerAdapter(liquidityLayerAdapters[_bridge]);\n        // Require the adapter to have been set\n        require(address(_adapter) != address(0), \"No adapter found for bridge\");\n    }\n}\n"
      },
      "contracts/mock/MockCircleMessageTransmitter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {ICircleMessageTransmitter} from \"../middleware/liquidity-layer/interfaces/circle/ICircleMessageTransmitter.sol\";\nimport {MockToken} from \"./MockToken.sol\";\n\ncontract MockCircleMessageTransmitter is ICircleMessageTransmitter {\n    mapping(bytes32 => bool) processedNonces;\n    MockToken token;\n\n    constructor(MockToken _token) {\n        token = _token;\n    }\n\n    function receiveMessage(\n        bytes memory,\n        bytes calldata\n    ) external pure returns (bool success) {\n        success = true;\n    }\n\n    function hashSourceAndNonce(\n        uint32 _source,\n        uint64 _nonce\n    ) public pure returns (bytes32) {\n        return keccak256(abi.encodePacked(_source, _nonce));\n    }\n\n    function process(\n        bytes32 _nonceId,\n        address _recipient,\n        uint256 _amount\n    ) public {\n        processedNonces[_nonceId] = true;\n        token.mint(_recipient, _amount);\n    }\n\n    function usedNonces(bytes32 _nonceId) external view returns (bool) {\n        return processedNonces[_nonceId];\n    }\n}\n"
      },
      "contracts/mock/MockCircleTokenMessenger.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {ITokenMessenger} from \"../middleware/liquidity-layer/interfaces/circle/ITokenMessenger.sol\";\nimport {MockToken} from \"./MockToken.sol\";\n\ncontract MockCircleTokenMessenger is ITokenMessenger {\n    uint64 public nextNonce = 0;\n    MockToken token;\n\n    constructor(MockToken _token) {\n        token = _token;\n    }\n\n    function depositForBurn(\n        uint256 _amount,\n        uint32,\n        bytes32,\n        address _burnToken\n    ) external returns (uint64 _nonce) {\n        nextNonce = nextNonce + 1;\n        _nonce = nextNonce;\n        require(address(token) == _burnToken);\n        token.transferFrom(msg.sender, address(this), _amount);\n        token.burn(_amount);\n    }\n\n    function depositForBurnWithCaller(\n        uint256,\n        uint32,\n        bytes32,\n        address,\n        bytes32\n    ) external returns (uint64 _nonce) {\n        nextNonce = nextNonce + 1;\n        _nonce = nextNonce;\n    }\n}\n"
      },
      "contracts/mock/MockERC5164.sol": {
        "content": "// SPDX-License-Identifier: MIT or Apache-2.0\npragma solidity ^0.8.13;\n\nimport {IMessageDispatcher} from \"../interfaces/hooks/IMessageDispatcher.sol\";\n\ncontract MockMessageDispatcher is IMessageDispatcher {\n    function dispatchMessage(\n        uint256 toChainId,\n        address to,\n        bytes calldata data\n    ) external returns (bytes32) {\n        bytes32 messageId = keccak256(abi.encodePacked(toChainId, to, data));\n\n        // simulate a successful dispatch\n        emit MessageDispatched(messageId, msg.sender, toChainId, to, data);\n\n        return messageId;\n    }\n}\n\ncontract MockMessageExecutor {\n    event MessageIdExecuted(\n        uint256 indexed fromChainId,\n        bytes32 indexed messageId\n    );\n}\n"
      },
      "contracts/mock/MockHyperlaneEnvironment.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport \"./MockMailbox.sol\";\nimport \"../test/TestInterchainGasPaymaster.sol\";\nimport \"../test/TestIsm.sol\";\n\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\n\ncontract MockHyperlaneEnvironment {\n    uint32 originDomain;\n    uint32 destinationDomain;\n\n    mapping(uint32 => MockMailbox) public mailboxes;\n    mapping(uint32 => TestInterchainGasPaymaster) public igps;\n    mapping(uint32 => IInterchainSecurityModule) public isms;\n\n    constructor(uint32 _originDomain, uint32 _destinationDomain) {\n        originDomain = _originDomain;\n        destinationDomain = _destinationDomain;\n\n        MockMailbox originMailbox = new MockMailbox(_originDomain);\n        MockMailbox destinationMailbox = new MockMailbox(_destinationDomain);\n\n        originMailbox.addRemoteMailbox(_destinationDomain, destinationMailbox);\n        destinationMailbox.addRemoteMailbox(_originDomain, originMailbox);\n\n        isms[originDomain] = new TestIsm();\n        isms[destinationDomain] = new TestIsm();\n\n        originMailbox.setDefaultIsm(address(isms[originDomain]));\n        destinationMailbox.setDefaultIsm(address(isms[destinationDomain]));\n\n        originMailbox.transferOwnership(msg.sender);\n        destinationMailbox.transferOwnership(msg.sender);\n\n        mailboxes[_originDomain] = originMailbox;\n        mailboxes[_destinationDomain] = destinationMailbox;\n    }\n\n    function processNextPendingMessage() public {\n        mailboxes[destinationDomain].processNextInboundMessage();\n    }\n\n    function processNextPendingMessageFromDestination() public {\n        mailboxes[originDomain].processNextInboundMessage();\n    }\n}\n"
      },
      "contracts/mock/MockMailbox.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {Versioned} from \"../upgrade/Versioned.sol\";\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\nimport {Message} from \"../libs/Message.sol\";\nimport {IMessageRecipient} from \"../interfaces/IMessageRecipient.sol\";\nimport {IInterchainSecurityModule, ISpecifiesInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\nimport {Mailbox} from \"../Mailbox.sol\";\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\n\nimport {TestIsm} from \"../test/TestIsm.sol\";\nimport {TestPostDispatchHook} from \"../test/TestPostDispatchHook.sol\";\n\ncontract MockMailbox is Mailbox {\n    using Message for bytes;\n\n    uint32 public inboundUnprocessedNonce = 0;\n    uint32 public inboundProcessedNonce = 0;\n\n    mapping(uint32 => MockMailbox) public remoteMailboxes;\n    mapping(uint256 => bytes) public inboundMessages;\n\n    constructor(uint32 _domain) Mailbox(_domain) {\n        TestIsm ism = new TestIsm();\n        defaultIsm = ism;\n\n        TestPostDispatchHook hook = new TestPostDispatchHook();\n        defaultHook = hook;\n        requiredHook = hook;\n\n        _transferOwnership(msg.sender);\n        _disableInitializers();\n    }\n\n    function addRemoteMailbox(uint32 _domain, MockMailbox _mailbox) external {\n        remoteMailboxes[_domain] = _mailbox;\n    }\n\n    function dispatch(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata messageBody,\n        bytes calldata metadata,\n        IPostDispatchHook hook\n    ) public payable override returns (bytes32) {\n        bytes memory message = _buildMessage(\n            destinationDomain,\n            recipientAddress,\n            messageBody\n        );\n        bytes32 id = super.dispatch(\n            destinationDomain,\n            recipientAddress,\n            messageBody,\n            metadata,\n            hook\n        );\n\n        MockMailbox _destinationMailbox = remoteMailboxes[destinationDomain];\n        require(\n            address(_destinationMailbox) != address(0),\n            \"Missing remote mailbox\"\n        );\n        _destinationMailbox.addInboundMessage(message);\n\n        return id;\n    }\n\n    function addInboundMessage(bytes calldata message) external {\n        inboundMessages[inboundUnprocessedNonce] = message;\n        inboundUnprocessedNonce++;\n    }\n\n    function processNextInboundMessage() public {\n        bytes memory _message = inboundMessages[inboundProcessedNonce];\n        Mailbox(address(this)).process(\"\", _message);\n        inboundProcessedNonce++;\n    }\n}\n"
      },
      "contracts/mock/MockPortalBridge.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {IPortalTokenBridge} from \"../middleware/liquidity-layer/interfaces/portal/IPortalTokenBridge.sol\";\nimport {MockToken} from \"./MockToken.sol\";\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\n\ncontract MockPortalBridge is IPortalTokenBridge {\n    uint256 nextNonce = 0;\n    MockToken token;\n\n    constructor(MockToken _token) {\n        token = _token;\n    }\n\n    function transferTokensWithPayload(\n        address,\n        uint256 amount,\n        uint16,\n        bytes32,\n        uint32,\n        bytes memory\n    ) external payable returns (uint64 sequence) {\n        nextNonce = nextNonce + 1;\n        token.transferFrom(msg.sender, address(this), amount);\n        token.burn(amount);\n        return uint64(nextNonce);\n    }\n\n    function wrappedAsset(uint16, bytes32) external view returns (address) {\n        return address(token);\n    }\n\n    function isWrappedAsset(address) external pure returns (bool) {\n        return true;\n    }\n\n    function completeTransferWithPayload(\n        bytes memory encodedVm\n    ) external returns (bytes memory) {\n        (uint32 _originDomain, uint224 _nonce, uint256 _amount) = abi.decode(\n            encodedVm,\n            (uint32, uint224, uint256)\n        );\n\n        token.mint(msg.sender, _amount);\n        // Format it so that parseTransferWithPayload returns the desired payload\n        return\n            abi.encode(\n                TypeCasts.addressToBytes32(address(token)),\n                adapterData(_originDomain, _nonce, address(token))\n            );\n    }\n\n    function parseTransferWithPayload(\n        bytes memory encoded\n    ) external pure returns (TransferWithPayload memory transfer) {\n        (bytes32 tokenAddress, bytes memory payload) = abi.decode(\n            encoded,\n            (bytes32, bytes)\n        );\n        transfer.payload = payload;\n        transfer.tokenAddress = tokenAddress;\n    }\n\n    function adapterData(\n        uint32 _originDomain,\n        uint224 _nonce,\n        address _token\n    ) public pure returns (bytes memory) {\n        return\n            abi.encode(\n                _originDomain,\n                _nonce,\n                TypeCasts.addressToBytes32(_token)\n            );\n    }\n\n    function mockPortalVaa(\n        uint32 _originDomain,\n        uint224 _nonce,\n        uint256 _amount\n    ) public pure returns (bytes memory) {\n        return abi.encode(_originDomain, _nonce, _amount);\n    }\n}\n"
      },
      "contracts/mock/MockToken.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {ERC20Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\";\n\ncontract MockToken is ERC20Upgradeable {\n    function mint(address account, uint256 amount) external {\n        _mint(account, amount);\n    }\n\n    function burn(uint256 _amount) external {\n        _burn(msg.sender, _amount);\n    }\n}\n"
      },
      "contracts/test/ERC20Test.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\n\ncontract ERC20Test is ERC20 {\n    uint8 public immutable _decimals;\n\n    constructor(\n        string memory name,\n        string memory symbol,\n        uint256 totalSupply,\n        uint8 __decimals\n    ) ERC20(name, symbol) {\n        _decimals = __decimals;\n        _mint(msg.sender, totalSupply);\n    }\n\n    function decimals() public view override returns (uint8) {\n        return _decimals;\n    }\n\n    function mint(uint256 amount) public {\n        _mint(msg.sender, amount);\n    }\n\n    function mintTo(address account, uint256 amount) public {\n        _mint(account, amount);\n    }\n}\n"
      },
      "contracts/test/ERC4626/ERC4626Test.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\nimport \"@openzeppelin/contracts/token/ERC20/ERC20.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC20.sol\";\n\ncontract ERC4626Test is ERC4626 {\n    constructor(\n        address _asset,\n        string memory _name,\n        string memory _symbol\n    ) ERC4626(IERC20(_asset)) ERC20(_name, _symbol) {}\n}\n"
      },
      "contracts/test/ERC721Test.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport \"@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol\";\n\ncontract ERC721Test is ERC721Enumerable {\n    constructor(\n        string memory name,\n        string memory symbol,\n        uint256 _mintAmount\n    ) ERC721(name, symbol) {\n        for (uint256 i = 0; i < _mintAmount; i++) {\n            _mint(msg.sender, i);\n        }\n    }\n\n    function _baseURI() internal pure override returns (string memory) {\n        return \"TEST-BASE-URI\";\n    }\n}\n"
      },
      "contracts/test/LightTestRecipient.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport \"./TestRecipient.sol\";\n\ncontract LightTestRecipient is TestRecipient {\n    // solhint-disable-next-line no-empty-blocks\n    function handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _data\n    ) external payable override {\n        // do nothing\n    }\n}\n"
      },
      "contracts/test/TestGasRouter.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport \"../client/GasRouter.sol\";\n\ncontract TestGasRouter is GasRouter {\n    constructor(address _mailbox) GasRouter(_mailbox) {}\n\n    function dispatch(uint32 _destination, bytes memory _msg) external payable {\n        _dispatch(_destination, _msg);\n    }\n\n    function _handle(uint32, bytes32, bytes calldata) internal pure override {}\n}\n"
      },
      "contracts/test/TestInterchainGasPaymaster.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\n// ============ Internal Imports ============\nimport {InterchainGasPaymaster} from \"../hooks/igp/InterchainGasPaymaster.sol\";\n\ncontract TestInterchainGasPaymaster is InterchainGasPaymaster {\n    uint256 public constant gasPrice = 10;\n\n    constructor() {\n        initialize(msg.sender, msg.sender);\n    }\n\n    function quoteGasPayment(\n        uint32,\n        uint256 gasAmount\n    ) public pure override returns (uint256) {\n        return gasPrice * gasAmount;\n    }\n\n    function getDefaultGasUsage() public pure returns (uint256) {\n        return DEFAULT_GAS_USAGE;\n    }\n}\n"
      },
      "contracts/test/TestIsm.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport {IInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\n\ncontract TestIsm is IInterchainSecurityModule {\n    uint8 public moduleType = uint8(Types.NULL);\n\n    bool verifyResult = true;\n\n    function setVerify(bool _verify) public {\n        verifyResult = _verify;\n    }\n\n    function verify(bytes calldata, bytes calldata) public view returns (bool) {\n        return verifyResult;\n    }\n}\n"
      },
      "contracts/test/TestLayerZeroTreasury.sol": {
        "content": "// SPDX-License-Identifier: UNLICENSED\n\npragma solidity ^0.8.0;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract LayerZeroTreasuryMock is Ownable {\n    function withdraw() external onlyOwner {\n        //withdraw\n    }\n\n    function withdrawAlt() external onlyOwner {\n        //withdraw token\n    }\n}\n"
      },
      "contracts/test/TestLiquidityLayerMessageRecipient.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {ILiquidityLayerMessageRecipient} from \"../interfaces/ILiquidityLayerMessageRecipient.sol\";\n\ncontract TestLiquidityLayerMessageRecipient is ILiquidityLayerMessageRecipient {\n    event HandledWithTokens(\n        uint32 origin,\n        bytes32 sender,\n        bytes message,\n        address token,\n        uint256 amount\n    );\n\n    function handleWithTokens(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message,\n        address _token,\n        uint256 _amount\n    ) external {\n        emit HandledWithTokens(_origin, _sender, _message, _token, _amount);\n    }\n}\n"
      },
      "contracts/test/TestMailbox.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {Mailbox} from \"../Mailbox.sol\";\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\nimport {Message} from \"../libs/Message.sol\";\nimport {MerkleLib} from \"../libs/Merkle.sol\";\nimport {IMessageRecipient} from \"../interfaces/IMessageRecipient.sol\";\n\ncontract TestMailbox is Mailbox {\n    using TypeCasts for bytes32;\n\n    constructor(uint32 _localDomain) Mailbox(_localDomain) {\n        _transferOwnership(msg.sender);\n    }\n\n    function testHandle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes32 _recipient,\n        bytes calldata _body\n    ) external {\n        IMessageRecipient(_recipient.bytes32ToAddress()).handle(\n            _origin,\n            _sender,\n            _body\n        );\n    }\n\n    function buildOutboundMessage(\n        uint32 destinationDomain,\n        bytes32 recipientAddress,\n        bytes calldata body\n    ) external view returns (bytes memory) {\n        return _buildMessage(destinationDomain, recipientAddress, body);\n    }\n\n    function buildInboundMessage(\n        uint32 originDomain,\n        bytes32 recipientAddress,\n        bytes32 senderAddress,\n        bytes calldata body\n    ) external view returns (bytes memory) {\n        return\n            Message.formatMessage(\n                VERSION,\n                nonce,\n                originDomain,\n                senderAddress,\n                localDomain,\n                recipientAddress,\n                body\n            );\n    }\n\n    function updateLatestDispatchedId(bytes32 _id) external {\n        latestDispatchedId = _id;\n    }\n}\n"
      },
      "contracts/test/TestMerkle.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\nimport {MerkleLib} from \"../libs/Merkle.sol\";\n\ncontract TestMerkle {\n    using MerkleLib for MerkleLib.Tree;\n\n    MerkleLib.Tree public tree;\n\n    // solhint-disable-next-line no-empty-blocks\n    constructor() {}\n\n    function insert(bytes32 _node) external {\n        tree.insert(_node);\n    }\n\n    function branchRoot(\n        bytes32 _leaf,\n        bytes32[32] calldata _proof,\n        uint256 _index\n    ) external pure returns (bytes32 _node) {\n        return MerkleLib.branchRoot(_leaf, _proof, _index);\n    }\n\n    /**\n     * @notice Returns the number of inserted leaves in the tree\n     */\n    function count() public view returns (uint256) {\n        return tree.count;\n    }\n\n    function root() public view returns (bytes32) {\n        return tree.root();\n    }\n}\n"
      },
      "contracts/test/TestMerkleTreeHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {MerkleLib} from \"../libs/Merkle.sol\";\nimport {MerkleTreeHook} from \"../hooks/MerkleTreeHook.sol\";\n\ncontract TestMerkleTreeHook is MerkleTreeHook {\n    using MerkleLib for MerkleLib.Tree;\n\n    constructor(address _mailbox) MerkleTreeHook(_mailbox) {}\n\n    function proof() external view returns (bytes32[32] memory) {\n        bytes32[32] memory _zeroes = MerkleLib.zeroHashes();\n        uint256 _index = _tree.count - 1;\n        bytes32[32] memory _proof;\n\n        for (uint256 i = 0; i < 32; i++) {\n            uint256 _ithBit = (_index >> i) & 0x01;\n            if (_ithBit == 1) {\n                _proof[i] = _tree.branch[i];\n            } else {\n                _proof[i] = _zeroes[i];\n            }\n        }\n        return _proof;\n    }\n\n    function insert(bytes32 _id) external {\n        _tree.insert(_id);\n    }\n}\n"
      },
      "contracts/test/TestMessage.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport {Message} from \"../libs/Message.sol\";\n\ncontract TestMessage {\n    using Message for bytes;\n\n    function version(\n        bytes calldata _message\n    ) external pure returns (uint32 _version) {\n        return _message.version();\n    }\n\n    function nonce(\n        bytes calldata _message\n    ) external pure returns (uint256 _nonce) {\n        return _message.nonce();\n    }\n\n    function body(\n        bytes calldata _message\n    ) external pure returns (bytes calldata _body) {\n        return _message.body();\n    }\n\n    function origin(\n        bytes calldata _message\n    ) external pure returns (uint32 _origin) {\n        return _message.origin();\n    }\n\n    function sender(\n        bytes calldata _message\n    ) external pure returns (bytes32 _sender) {\n        return _message.sender();\n    }\n\n    function destination(\n        bytes calldata _message\n    ) external pure returns (uint32 _destination) {\n        return _message.destination();\n    }\n\n    function recipient(\n        bytes calldata _message\n    ) external pure returns (bytes32 _recipient) {\n        return _message.recipient();\n    }\n\n    function recipientAddress(\n        bytes calldata _message\n    ) external pure returns (address _recipient) {\n        return _message.recipientAddress();\n    }\n\n    function id(bytes calldata _message) external pure returns (bytes32) {\n        return _message.id();\n    }\n}\n"
      },
      "contracts/test/TestPostDispatchHook.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\nimport {AbstractPostDispatchHook} from \"../hooks/libs/AbstractPostDispatchHook.sol\";\n\ncontract TestPostDispatchHook is AbstractPostDispatchHook {\n    // ============ Public Storage ============\n\n    // test fees for quoteDispatch\n    uint256 public fee = 0;\n\n    // ============ External Functions ============\n\n    /// @inheritdoc IPostDispatchHook\n    function hookType() external pure override returns (uint8) {\n        return uint8(IPostDispatchHook.Types.UNUSED);\n    }\n\n    function supportsMetadata(\n        bytes calldata\n    ) public pure override returns (bool) {\n        return true;\n    }\n\n    function setFee(uint256 _fee) external {\n        fee = _fee;\n    }\n\n    // ============ Internal functions ============\n    function _postDispatch(\n        bytes calldata,\n        /*metadata*/\n        bytes calldata /*message*/\n    ) internal pure override {\n        // test - empty\n    }\n\n    function _quoteDispatch(\n        bytes calldata,\n        /*metadata*/\n        bytes calldata /*message*/\n    ) internal view override returns (uint256) {\n        return fee;\n    }\n}\n"
      },
      "contracts/test/TestQuery.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity ^0.8.13;\n\nimport {InterchainQueryRouter} from \"../middleware/InterchainQueryRouter.sol\";\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\nimport {CallLib} from \"../middleware/libs/Call.sol\";\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\ncontract TestQuery {\n    InterchainQueryRouter public router;\n\n    event Owner(uint256, address);\n\n    constructor(address _router) {\n        router = InterchainQueryRouter(_router);\n    }\n\n    /**\n     * @dev Fetches owner of InterchainQueryRouter on provided domain and passes along with provided secret to `this.receiveRouterOwner`\n     */\n    function queryRouterOwner(uint32 domain, uint256 secret) external {\n        address target = TypeCasts.bytes32ToAddress(router.routers(domain));\n        CallLib.StaticCallWithCallback[]\n            memory calls = new CallLib.StaticCallWithCallback[](1);\n        calls[0] = CallLib.build(\n            target,\n            abi.encodeWithSelector(Ownable.owner.selector),\n            abi.encodeWithSelector(this.receiveRouterOwner.selector, secret)\n        );\n        router.query(domain, calls);\n    }\n\n    /**\n     * @dev `msg.sender` must be restricted to `this.router` to prevent any local account from spoofing query data.\n     */\n    function receiveRouterOwner(uint256 secret, address owner) external {\n        require(msg.sender == address(router), \"TestQuery: not from router\");\n        emit Owner(secret, owner);\n    }\n}\n"
      },
      "contracts/test/TestQuerySender.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {InterchainQueryRouter} from \"../middleware/InterchainQueryRouter.sol\";\nimport {CallLib} from \"../middleware/libs/Call.sol\";\n\ncontract TestQuerySender {\n    InterchainQueryRouter queryRouter;\n\n    address public lastAddressResult;\n    uint256 public lastUint256Result;\n    bytes32 public lastBytes32Result;\n\n    event ReceivedAddressResult(address result);\n    event ReceivedUint256Result(uint256 result);\n    event ReceivedBytes32Result(bytes32 result);\n\n    function initialize(address _queryRouterAddress) external {\n        queryRouter = InterchainQueryRouter(_queryRouterAddress);\n    }\n\n    function queryAddress(\n        uint32 _destinationDomain,\n        address _target,\n        bytes calldata _targetData,\n        uint256 _gasAmount\n    ) external payable {\n        queryAndPayFor(\n            _destinationDomain,\n            _target,\n            _targetData,\n            this.handleQueryAddressResult.selector,\n            _gasAmount\n        );\n    }\n\n    function handleQueryAddressResult(address _result) external {\n        emit ReceivedAddressResult(_result);\n        lastAddressResult = _result;\n    }\n\n    function queryUint256(\n        uint32 _destinationDomain,\n        address _target,\n        bytes calldata _targetData,\n        uint256 _gasAmount\n    ) external payable {\n        queryAndPayFor(\n            _destinationDomain,\n            _target,\n            _targetData,\n            this.handleQueryUint256Result.selector,\n            _gasAmount\n        );\n    }\n\n    function handleQueryUint256Result(uint256 _result) external {\n        emit ReceivedUint256Result(_result);\n        lastUint256Result = _result;\n    }\n\n    function queryBytes32(\n        uint32 _destinationDomain,\n        address _target,\n        bytes calldata _targetData,\n        uint256 _gasAmount\n    ) external payable {\n        queryAndPayFor(\n            _destinationDomain,\n            _target,\n            _targetData,\n            this.handleQueryBytes32Result.selector,\n            _gasAmount\n        );\n    }\n\n    function handleQueryBytes32Result(bytes32 _result) external {\n        emit ReceivedBytes32Result(_result);\n        lastBytes32Result = _result;\n    }\n\n    function queryAndPayFor(\n        uint32 _destinationDomain,\n        address _target,\n        bytes calldata _targetData,\n        bytes4 _callbackSelector,\n        uint256 /*_gasAmount*/\n    ) internal {\n        queryRouter.query(\n            _destinationDomain,\n            _target,\n            _targetData,\n            abi.encodePacked(_callbackSelector)\n        );\n    }\n}\n"
      },
      "contracts/test/TestRecipient.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\nimport {IMessageRecipient} from \"../interfaces/IMessageRecipient.sol\";\nimport {IInterchainSecurityModule, ISpecifiesInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\n\ncontract TestRecipient is\n    Ownable,\n    IMessageRecipient,\n    ISpecifiesInterchainSecurityModule\n{\n    IInterchainSecurityModule public interchainSecurityModule;\n    bytes32 public lastSender;\n    bytes public lastData;\n\n    address public lastCaller;\n    string public lastCallMessage;\n\n    event ReceivedMessage(\n        uint32 indexed origin,\n        bytes32 indexed sender,\n        uint256 indexed value,\n        string message\n    );\n\n    event ReceivedCall(address indexed caller, uint256 amount, string message);\n\n    function handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _data\n    ) external payable virtual override {\n        emit ReceivedMessage(_origin, _sender, msg.value, string(_data));\n        lastSender = _sender;\n        lastData = _data;\n    }\n\n    function fooBar(uint256 amount, string calldata message) external {\n        emit ReceivedCall(msg.sender, amount, message);\n        lastCaller = msg.sender;\n        lastCallMessage = message;\n    }\n\n    function setInterchainSecurityModule(address _ism) external onlyOwner {\n        interchainSecurityModule = IInterchainSecurityModule(_ism);\n    }\n}\n"
      },
      "contracts/test/TestRouter.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\nimport \"../client/Router.sol\";\n\ncontract TestRouter is Router {\n    event InitializeOverload();\n\n    constructor(address _mailbox) Router(_mailbox) {}\n\n    function initialize(\n        address _hook,\n        address _interchainSecurityModule\n    ) public initializer {\n        _MailboxClient_initialize(_hook, _interchainSecurityModule, msg.sender);\n    }\n\n    function _handle(uint32, bytes32, bytes calldata) internal pure override {}\n\n    function isRemoteRouter(\n        uint32 _domain,\n        bytes32 _potentialRemoteRouter\n    ) external view returns (bool) {\n        return _isRemoteRouter(_domain, _potentialRemoteRouter);\n    }\n\n    function mustHaveRemoteRouter(\n        uint32 _domain\n    ) external view returns (bytes32) {\n        return _mustHaveRemoteRouter(_domain);\n    }\n\n    function dispatch(uint32 _destination, bytes memory _msg) external payable {\n        _dispatch(_destination, _msg);\n    }\n}\n"
      },
      "contracts/test/TestSendReceiver.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TypeCasts} from \"../libs/TypeCasts.sol\";\n\nimport {IInterchainGasPaymaster} from \"../interfaces/IInterchainGasPaymaster.sol\";\nimport {IMessageRecipient} from \"../interfaces/IMessageRecipient.sol\";\nimport {IMailbox} from \"../interfaces/IMailbox.sol\";\nimport {IPostDispatchHook} from \"../interfaces/hooks/IPostDispatchHook.sol\";\nimport {IInterchainSecurityModule, ISpecifiesInterchainSecurityModule} from \"../interfaces/IInterchainSecurityModule.sol\";\n\nimport {MailboxClient} from \"../client/MailboxClient.sol\";\n\ncontract TestSendReceiver is IMessageRecipient {\n    using TypeCasts for address;\n\n    uint256 public constant HANDLE_GAS_AMOUNT = 50_000;\n\n    event Handled(bytes32 blockHash);\n\n    function dispatchToSelf(\n        IMailbox _mailbox,\n        uint32 _destinationDomain,\n        bytes calldata _messageBody\n    ) external payable {\n        // TODO: handle topping up?\n        _mailbox.dispatch{value: msg.value}(\n            _destinationDomain,\n            address(this).addressToBytes32(),\n            _messageBody\n        );\n    }\n\n    function dispatchToSelf(\n        IMailbox _mailbox,\n        uint32 _destinationDomain,\n        bytes calldata _messageBody,\n        IPostDispatchHook hook\n    ) external payable {\n        // TODO: handle topping up?\n        _mailbox.dispatch{value: msg.value}(\n            _destinationDomain,\n            address(this).addressToBytes32(),\n            _messageBody,\n            bytes(\"\"),\n            hook\n        );\n    }\n\n    function handle(uint32, bytes32, bytes calldata) external payable override {\n        bytes32 blockHash = previousBlockHash();\n        bool isBlockHashEndIn0 = uint256(blockHash) % 16 == 0;\n        require(!isBlockHashEndIn0, \"block hash ends in 0\");\n        emit Handled(blockHash);\n    }\n\n    function previousBlockHash() internal view returns (bytes32) {\n        return blockhash(block.number - 1);\n    }\n}\n"
      },
      "contracts/test/TestTokenRecipient.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nimport {ILiquidityLayerMessageRecipient} from \"../interfaces/ILiquidityLayerMessageRecipient.sol\";\n\ncontract TestTokenRecipient is ILiquidityLayerMessageRecipient {\n    bytes32 public lastSender;\n    bytes public lastData;\n    address public lastToken;\n    uint256 public lastAmount;\n\n    address public lastCaller;\n    string public lastCallMessage;\n\n    event ReceivedMessage(\n        uint32 indexed origin,\n        bytes32 indexed sender,\n        string message,\n        address token,\n        uint256 amount\n    );\n\n    event ReceivedCall(address indexed caller, uint256 amount, string message);\n\n    function handleWithTokens(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _data,\n        address _token,\n        uint256 _amount\n    ) external override {\n        emit ReceivedMessage(_origin, _sender, string(_data), _token, _amount);\n        lastSender = _sender;\n        lastData = _data;\n        lastToken = _token;\n        lastAmount = _amount;\n    }\n\n    function fooBar(uint256 amount, string calldata message) external {\n        emit ReceivedCall(msg.sender, amount, message);\n        lastCaller = msg.sender;\n        lastCallMessage = message;\n    }\n}\n"
      },
      "contracts/token/extensions/FastHypERC20.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {HypERC20} from \"../HypERC20.sol\";\nimport {FastTokenRouter} from \"../libs/FastTokenRouter.sol\";\nimport {TokenRouter} from \"../libs/TokenRouter.sol\";\n\nimport {ERC20Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\";\n\n/**\n * @title Hyperlane ERC20 Token Router that extends ERC20 with remote transfer functionality.\n * @author Abacus Works\n * @dev Supply on each chain is not constant but the aggregate supply across all chains is.\n */\ncontract FastHypERC20 is FastTokenRouter, HypERC20 {\n    constructor(\n        uint8 __decimals,\n        address _mailbox\n    ) HypERC20(__decimals, _mailbox) {}\n\n    /**\n     * @dev delegates transfer logic to `_transferTo`.\n     * @inheritdoc TokenRouter\n     */\n    function _handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message\n    ) internal virtual override(FastTokenRouter, TokenRouter) {\n        FastTokenRouter._handle(_origin, _sender, _message);\n    }\n\n    /**\n     * @dev Mints `_amount` of tokens to `_recipient`.\n     * @inheritdoc FastTokenRouter\n     */\n    function _fastTransferTo(\n        address _recipient,\n        uint256 _amount\n    ) internal override {\n        _mint(_recipient, _amount);\n    }\n\n    /**\n     * @dev Burns `_amount` of tokens from `_recipient`.\n     * @inheritdoc FastTokenRouter\n     */\n    function _fastRecieveFrom(\n        address _sender,\n        uint256 _amount\n    ) internal override {\n        _burn(_sender, _amount);\n    }\n\n    function balanceOf(\n        address _account\n    ) public view virtual override(HypERC20, TokenRouter) returns (uint256) {\n        return ERC20Upgradeable.balanceOf(_account);\n    }\n}\n"
      },
      "contracts/token/extensions/FastHypERC20Collateral.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {HypERC20Collateral} from \"../HypERC20Collateral.sol\";\nimport {FastTokenRouter} from \"../libs/FastTokenRouter.sol\";\nimport {TokenRouter} from \"../libs/TokenRouter.sol\";\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/**\n * @title Hyperlane ERC20 Token Collateral that wraps an existing ERC20 with remote transfer functionality.\n * @author Abacus Works\n */\ncontract FastHypERC20Collateral is FastTokenRouter, HypERC20Collateral {\n    using SafeERC20 for IERC20;\n\n    /**\n     * @notice Constructor\n     * @param erc20 Address of the token to keep as collateral\n     */\n    constructor(\n        address erc20,\n        address _mailbox\n    ) HypERC20Collateral(erc20, _mailbox) {}\n\n    /**\n     * @dev delegates transfer logic to `_transferTo`.\n     * @inheritdoc FastTokenRouter\n     */\n    function _handle(\n        uint32 _origin,\n        bytes32 _sender,\n        bytes calldata _message\n    ) internal virtual override(FastTokenRouter, TokenRouter) {\n        FastTokenRouter._handle(_origin, _sender, _message);\n    }\n\n    /**\n     * @dev Transfers `_amount` of `wrappedToken` to `_recipient`.\n     * @inheritdoc FastTokenRouter\n     */\n    function _fastTransferTo(\n        address _recipient,\n        uint256 _amount\n    ) internal override {\n        wrappedToken.safeTransfer(_recipient, _amount);\n    }\n\n    /**\n     * @dev Transfers in `_amount` of `wrappedToken` from `_recipient`.\n     * @inheritdoc FastTokenRouter\n     */\n    function _fastRecieveFrom(\n        address _sender,\n        uint256 _amount\n    ) internal override {\n        wrappedToken.safeTransferFrom(_sender, address(this), _amount);\n    }\n}\n"
      },
      "contracts/token/extensions/HypERC721URICollateral.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {HypERC721Collateral} from \"../HypERC721Collateral.sol\";\n\nimport {IERC721MetadataUpgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol\";\n\n/**\n * @title Hyperlane ERC721 Token Collateral that wraps an existing ERC721 with remote transfer and URI relay functionality.\n * @author Abacus Works\n */\ncontract HypERC721URICollateral is HypERC721Collateral {\n    // solhint-disable-next-line no-empty-blocks\n    constructor(\n        address erc721,\n        address _mailbox\n    ) HypERC721Collateral(erc721, _mailbox) {}\n\n    /**\n     * @dev Transfers `_tokenId` of `wrappedToken` from `msg.sender` to this contract.\n     * @return The URI of `_tokenId` on `wrappedToken`.\n     * @inheritdoc HypERC721Collateral\n     */\n    function _transferFromSender(\n        uint256 _tokenId\n    ) internal override returns (bytes memory) {\n        HypERC721Collateral._transferFromSender(_tokenId);\n        return\n            bytes(\n                IERC721MetadataUpgradeable(address(wrappedToken)).tokenURI(\n                    _tokenId\n                )\n            );\n    }\n}\n"
      },
      "contracts/token/extensions/HypERC721URIStorage.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {HypERC721} from \"../HypERC721.sol\";\n\nimport {ERC721URIStorageUpgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol\";\nimport {ERC721EnumerableUpgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol\";\nimport {ERC721Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\nimport {IERC721Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\n\n/**\n * @title Hyperlane ERC721 Token that extends ERC721URIStorage with remote transfer and URI relay functionality.\n * @author Abacus Works\n */\ncontract HypERC721URIStorage is HypERC721, ERC721URIStorageUpgradeable {\n    constructor(address _mailbox) HypERC721(_mailbox) {}\n\n    function balanceOf(\n        address account\n    )\n        public\n        view\n        override(HypERC721, ERC721Upgradeable, IERC721Upgradeable)\n        returns (uint256)\n    {\n        return HypERC721.balanceOf(account);\n    }\n\n    /**\n     * @return _tokenURI The URI of `_tokenId`.\n     * @inheritdoc HypERC721\n     */\n    function _transferFromSender(\n        uint256 _tokenId\n    ) internal override returns (bytes memory _tokenURI) {\n        _tokenURI = bytes(tokenURI(_tokenId)); // requires minted\n        HypERC721._transferFromSender(_tokenId);\n    }\n\n    /**\n     * @dev Sets the URI for `_tokenId` to `_tokenURI`.\n     * @inheritdoc HypERC721\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _tokenId,\n        bytes calldata _tokenURI\n    ) internal override {\n        HypERC721._transferTo(_recipient, _tokenId, _tokenURI);\n        _setTokenURI(_tokenId, string(_tokenURI)); // requires minted\n    }\n\n    function tokenURI(\n        uint256 tokenId\n    )\n        public\n        view\n        override(ERC721Upgradeable, ERC721URIStorageUpgradeable)\n        returns (string memory)\n    {\n        return ERC721URIStorageUpgradeable.tokenURI(tokenId);\n    }\n\n    function _beforeTokenTransfer(\n        address from,\n        address to,\n        uint256 tokenId,\n        uint256 batchSize\n    ) internal override(ERC721EnumerableUpgradeable, ERC721Upgradeable) {\n        ERC721EnumerableUpgradeable._beforeTokenTransfer(\n            from,\n            to,\n            tokenId,\n            batchSize\n        );\n    }\n\n    function supportsInterface(\n        bytes4 interfaceId\n    )\n        public\n        view\n        override(ERC721EnumerableUpgradeable, ERC721URIStorageUpgradeable)\n        returns (bool)\n    {\n        return ERC721EnumerableUpgradeable.supportsInterface(interfaceId);\n    }\n\n    function _burn(\n        uint256 tokenId\n    ) internal override(ERC721URIStorageUpgradeable, ERC721Upgradeable) {\n        ERC721URIStorageUpgradeable._burn(tokenId);\n    }\n}\n"
      },
      "contracts/token/extensions/HypNativeScaled.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {HypNative} from \"../HypNative.sol\";\nimport {TokenRouter} from \"../libs/TokenRouter.sol\";\n\n/**\n * @title Hyperlane Native Token that scales native value by a fixed factor for consistency with other tokens.\n * @dev The scale factor multiplies the `message.amount` to the local native token amount.\n *      Conversely, it divides the local native `msg.value` amount by `scale` to encode the `message.amount`.\n * @author Abacus Works\n */\ncontract HypNativeScaled is HypNative {\n    uint256 public immutable scale;\n\n    constructor(uint256 _scale, address _mailbox) HypNative(_mailbox) {\n        scale = _scale;\n    }\n\n    /**\n     * @inheritdoc HypNative\n     * @dev Sends scaled `msg.value` (divided by `scale`) to `_recipient`.\n     */\n    function transferRemote(\n        uint32 _destination,\n        bytes32 _recipient,\n        uint256 _amount\n    ) public payable override returns (bytes32 messageId) {\n        require(msg.value >= _amount, \"Native: amount exceeds msg.value\");\n        uint256 gasPayment = msg.value - _amount;\n        uint256 scaledAmount = _amount / scale;\n        return\n            _transferRemote(_destination, _recipient, scaledAmount, gasPayment);\n    }\n\n    /**\n     * @dev Sends scaled `_amount` (multiplied by `scale`) to `_recipient`.\n     * @inheritdoc TokenRouter\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _amount,\n        bytes calldata metadata // no metadata\n    ) internal override {\n        uint256 scaledAmount = _amount * scale;\n        HypNative._transferTo(_recipient, scaledAmount, metadata);\n    }\n}\n"
      },
      "contracts/token/HypERC20.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TokenRouter} from \"./libs/TokenRouter.sol\";\n\nimport {ERC20Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol\";\n\n/**\n * @title Hyperlane ERC20 Token Router that extends ERC20 with remote transfer functionality.\n * @author Abacus Works\n * @dev Supply on each chain is not constant but the aggregate supply across all chains is.\n */\ncontract HypERC20 is ERC20Upgradeable, TokenRouter {\n    uint8 private immutable _decimals;\n\n    constructor(uint8 __decimals, address _mailbox) TokenRouter(_mailbox) {\n        _decimals = __decimals;\n    }\n\n    /**\n     * @notice Initializes the Hyperlane router, ERC20 metadata, and mints initial supply to deployer.\n     * @param _totalSupply The initial supply of the token.\n     * @param _name The name of the token.\n     * @param _symbol The symbol of the token.\n     */\n    function initialize(\n        uint256 _totalSupply,\n        string memory _name,\n        string memory _symbol,\n        address _hook,\n        address _interchainSecurityModule,\n        address _owner\n    ) external initializer {\n        // Initialize ERC20 metadata\n        __ERC20_init(_name, _symbol);\n        _mint(msg.sender, _totalSupply);\n        _MailboxClient_initialize(_hook, _interchainSecurityModule, _owner);\n    }\n\n    function decimals() public view override returns (uint8) {\n        return _decimals;\n    }\n\n    function balanceOf(\n        address _account\n    )\n        public\n        view\n        virtual\n        override(TokenRouter, ERC20Upgradeable)\n        returns (uint256)\n    {\n        return ERC20Upgradeable.balanceOf(_account);\n    }\n\n    /**\n     * @dev Burns `_amount` of token from `msg.sender` balance.\n     * @inheritdoc TokenRouter\n     */\n    function _transferFromSender(\n        uint256 _amount\n    ) internal override returns (bytes memory) {\n        _burn(msg.sender, _amount);\n        return bytes(\"\"); // no metadata\n    }\n\n    /**\n     * @dev Mints `_amount` of token to `_recipient` balance.\n     * @inheritdoc TokenRouter\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _amount,\n        bytes calldata // no metadata\n    ) internal virtual override {\n        _mint(_recipient, _amount);\n    }\n}\n"
      },
      "contracts/token/HypERC20Collateral.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TokenRouter} from \"./libs/TokenRouter.sol\";\nimport {TokenMessage} from \"./libs/TokenMessage.sol\";\nimport {MailboxClient} from \"../client/MailboxClient.sol\";\n\nimport {IERC20} from \"@openzeppelin/contracts/token/ERC20/IERC20.sol\";\nimport {SafeERC20} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\n/**\n * @title Hyperlane ERC20 Token Collateral that wraps an existing ERC20 with remote transfer functionality.\n * @author Abacus Works\n */\ncontract HypERC20Collateral is TokenRouter {\n    using SafeERC20 for IERC20;\n\n    IERC20 public immutable wrappedToken;\n\n    /**\n     * @notice Constructor\n     * @param erc20 Address of the token to keep as collateral\n     */\n    constructor(address erc20, address _mailbox) TokenRouter(_mailbox) {\n        wrappedToken = IERC20(erc20);\n    }\n\n    function initialize(\n        address _hook,\n        address _interchainSecurityModule,\n        address _owner\n    ) public virtual initializer {\n        _MailboxClient_initialize(_hook, _interchainSecurityModule, _owner);\n    }\n\n    function balanceOf(\n        address _account\n    ) external view override returns (uint256) {\n        return wrappedToken.balanceOf(_account);\n    }\n\n    /**\n     * @dev Transfers `_amount` of `wrappedToken` from `msg.sender` to this contract.\n     * @inheritdoc TokenRouter\n     */\n    function _transferFromSender(\n        uint256 _amount\n    ) internal virtual override returns (bytes memory) {\n        wrappedToken.safeTransferFrom(msg.sender, address(this), _amount);\n        return bytes(\"\"); // no metadata\n    }\n\n    /**\n     * @dev Transfers `_amount` of `wrappedToken` from this contract to `_recipient`.\n     * @inheritdoc TokenRouter\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _amount,\n        bytes calldata // no metadata\n    ) internal virtual override {\n        wrappedToken.safeTransfer(_recipient, _amount);\n    }\n}\n"
      },
      "contracts/token/HypERC20CollateralVaultDeposit.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\nimport \"@openzeppelin/contracts/token/ERC20/extensions/ERC4626.sol\";\nimport {HypERC20Collateral} from \"./HypERC20Collateral.sol\";\n\n/**\n * @title Hyperlane ERC20 Token Collateral with deposits collateral to a vault\n * @author ltyu\n */\ncontract HypERC20CollateralVaultDeposit is HypERC20Collateral {\n    // Address of the ERC4626 compatible vault\n    ERC4626 public immutable vault;\n\n    // Internal balance of total asset deposited\n    uint256 public assetDeposited;\n\n    event ExcessSharesSwept(uint256 amount, uint256 assetsRedeemed);\n\n    constructor(\n        ERC4626 _vault,\n        address _mailbox\n    ) HypERC20Collateral(_vault.asset(), _mailbox) {\n        vault = _vault;\n    }\n\n    function initialize(\n        address _hook,\n        address _interchainSecurityModule,\n        address _owner\n    ) public override initializer {\n        wrappedToken.approve(address(vault), type(uint256).max);\n        _MailboxClient_initialize(_hook, _interchainSecurityModule, _owner);\n    }\n\n    /**\n     * @dev Transfers `_amount` of `wrappedToken` from `msg.sender` to this contract, and deposit into vault\n     * @inheritdoc HypERC20Collateral\n     */\n    function _transferFromSender(\n        uint256 _amount\n    ) internal override returns (bytes memory metadata) {\n        metadata = super._transferFromSender(_amount);\n        _depositIntoVault(_amount);\n    }\n\n    /**\n     * @dev Deposits into the vault and increment assetDeposited\n     * @param _amount amount to deposit into vault\n     */\n    function _depositIntoVault(uint256 _amount) internal {\n        assetDeposited += _amount;\n        vault.deposit(_amount, address(this));\n    }\n\n    /**\n     * @dev Transfers `_amount` of `wrappedToken` from this contract to `_recipient`, and withdraws from vault\n     * @inheritdoc HypERC20Collateral\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _amount,\n        bytes calldata\n    ) internal virtual override {\n        _withdrawFromVault(_amount, _recipient);\n    }\n\n    /**\n     * @dev Withdraws from the vault and decrement assetDeposited\n     * @param _amount amount to withdraw from vault\n     * @param _recipient address to deposit withdrawn underlying to\n     */\n    function _withdrawFromVault(uint256 _amount, address _recipient) internal {\n        assetDeposited -= _amount;\n        vault.withdraw(_amount, _recipient, address(this));\n    }\n\n    /**\n     * @notice Allows the owner to redeem excess shares\n     */\n    function sweep() external onlyOwner {\n        uint256 excessShares = vault.maxRedeem(address(this)) -\n            vault.convertToShares(assetDeposited);\n        uint256 assetsRedeemed = vault.redeem(\n            excessShares,\n            owner(),\n            address(this)\n        );\n        emit ExcessSharesSwept(excessShares, assetsRedeemed);\n    }\n}\n"
      },
      "contracts/token/HypERC721.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TokenRouter} from \"./libs/TokenRouter.sol\";\n\nimport {IERC721Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport {ERC721Upgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol\";\nimport {ERC721EnumerableUpgradeable} from \"@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol\";\n\n/**\n * @title Hyperlane ERC721 Token Router that extends ERC721 with remote transfer functionality.\n * @author Abacus Works\n */\ncontract HypERC721 is ERC721EnumerableUpgradeable, TokenRouter {\n    constructor(address _mailbox) TokenRouter(_mailbox) {}\n\n    /**\n     * @notice Initializes the Hyperlane router, ERC721 metadata, and mints initial supply to deployer.\n     * @param _mintAmount The amount of NFTs to mint to `msg.sender`.\n     * @param _name The name of the token.\n     * @param _symbol The symbol of the token.\n     * @param _hook The post-dispatch hook contract.\n       @param _interchainSecurityModule The interchain security module contract.\n       @param _owner The this contract.\n     */\n    function initialize(\n        uint256 _mintAmount,\n        string memory _name,\n        string memory _symbol,\n        address _hook,\n        address _interchainSecurityModule,\n        address _owner\n    ) external initializer {\n        _MailboxClient_initialize(_hook, _interchainSecurityModule, _owner);\n        __ERC721_init(_name, _symbol);\n        for (uint256 i = 0; i < _mintAmount; i++) {\n            _safeMint(msg.sender, i);\n        }\n    }\n\n    function balanceOf(\n        address _account\n    )\n        public\n        view\n        virtual\n        override(TokenRouter, ERC721Upgradeable, IERC721Upgradeable)\n        returns (uint256)\n    {\n        return ERC721Upgradeable.balanceOf(_account);\n    }\n\n    /**\n     * @dev Asserts `msg.sender` is owner and burns `_tokenId`.\n     * @inheritdoc TokenRouter\n     */\n    function _transferFromSender(\n        uint256 _tokenId\n    ) internal virtual override returns (bytes memory) {\n        require(ownerOf(_tokenId) == msg.sender, \"!owner\");\n        _burn(_tokenId);\n        return bytes(\"\"); // no metadata\n    }\n\n    /**\n     * @dev Mints `_tokenId` to `_recipient`.\n     * @inheritdoc TokenRouter\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _tokenId,\n        bytes calldata // no metadata\n    ) internal virtual override {\n        _safeMint(_recipient, _tokenId);\n    }\n}\n"
      },
      "contracts/token/HypERC721Collateral.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TokenRouter} from \"./libs/TokenRouter.sol\";\nimport {TokenMessage} from \"./libs/TokenMessage.sol\";\n\nimport {IERC721} from \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\n\n/**\n * @title Hyperlane ERC721 Token Collateral that wraps an existing ERC721 with remote transfer functionality.\n * @author Abacus Works\n */\ncontract HypERC721Collateral is TokenRouter {\n    IERC721 public immutable wrappedToken;\n\n    /**\n     * @notice Constructor\n     * @param erc721 Address of the token to keep as collateral\n     */\n    constructor(address erc721, address _mailbox) TokenRouter(_mailbox) {\n        wrappedToken = IERC721(erc721);\n    }\n\n    /**\n     * @notice Initializes the Hyperlane router\n     * @param _hook The post-dispatch hook contract.\n       @param _interchainSecurityModule The interchain security module contract.\n       @param _owner The this contract.\n     */\n    function initialize(\n        address _hook,\n        address _interchainSecurityModule,\n        address _owner\n    ) public virtual initializer {\n        _MailboxClient_initialize(_hook, _interchainSecurityModule, _owner);\n    }\n\n    function ownerOf(uint256 _tokenId) external view returns (address) {\n        return IERC721(wrappedToken).ownerOf(_tokenId);\n    }\n\n    /**\n     * @dev Returns the balance of `_account` for `wrappedToken`.\n     * @inheritdoc TokenRouter\n     */\n    function balanceOf(\n        address _account\n    ) external view override returns (uint256) {\n        return IERC721(wrappedToken).balanceOf(_account);\n    }\n\n    /**\n     * @dev Transfers `_tokenId` of `wrappedToken` from `msg.sender` to this contract.\n     * @inheritdoc TokenRouter\n     */\n    function _transferFromSender(\n        uint256 _tokenId\n    ) internal virtual override returns (bytes memory) {\n        // safeTransferFrom not used here because recipient is this contract\n        wrappedToken.transferFrom(msg.sender, address(this), _tokenId);\n        return bytes(\"\"); // no metadata\n    }\n\n    /**\n     * @dev Transfers `_tokenId` of `wrappedToken` from this contract to `_recipient`.\n     * @inheritdoc TokenRouter\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _tokenId,\n        bytes calldata // no metadata\n    ) internal override {\n        wrappedToken.safeTransferFrom(address(this), _recipient, _tokenId);\n    }\n}\n"
      },
      "contracts/token/HypNative.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TokenRouter} from \"./libs/TokenRouter.sol\";\nimport {TokenMessage} from \"./libs/TokenMessage.sol\";\nimport {Address} from \"@openzeppelin/contracts/utils/Address.sol\";\n\n/**\n * @title Hyperlane Native Token Router that extends ERC20 with remote transfer functionality.\n * @author Abacus Works\n * @dev Supply on each chain is not constant but the aggregate supply across all chains is.\n */\ncontract HypNative is TokenRouter {\n    /**\n     * @dev Emitted when native tokens are donated to the contract.\n     * @param sender The address of the sender.\n     * @param amount The amount of native tokens donated.\n     */\n    event Donation(address indexed sender, uint256 amount);\n\n    constructor(address _mailbox) TokenRouter(_mailbox) {}\n\n    /**\n     * @notice Initializes the Hyperlane router\n     * @param _hook The post-dispatch hook contract.\n       @param _interchainSecurityModule The interchain security module contract.\n       @param _owner The this contract.\n     */\n    function initialize(\n        address _hook,\n        address _interchainSecurityModule,\n        address _owner\n    ) public initializer {\n        _MailboxClient_initialize(_hook, _interchainSecurityModule, _owner);\n    }\n\n    /**\n     * @inheritdoc TokenRouter\n     * @dev uses (`msg.value` - `_amount`) as interchain gas payment and `msg.sender` as refund address.\n     */\n    function transferRemote(\n        uint32 _destination,\n        bytes32 _recipient,\n        uint256 _amount\n    ) public payable virtual override returns (bytes32 messageId) {\n        require(msg.value >= _amount, \"Native: amount exceeds msg.value\");\n        uint256 gasPayment = msg.value - _amount;\n        return _transferRemote(_destination, _recipient, _amount, gasPayment);\n    }\n\n    function balanceOf(\n        address _account\n    ) external view override returns (uint256) {\n        return _account.balance;\n    }\n\n    /**\n     * @inheritdoc TokenRouter\n     * @dev No-op because native amount is transferred in `msg.value`\n     * @dev Compiler will not include this in the bytecode.\n     */\n    function _transferFromSender(\n        uint256\n    ) internal pure override returns (bytes memory) {\n        return bytes(\"\"); // no metadata\n    }\n\n    /**\n     * @dev Sends `_amount` of native token to `_recipient` balance.\n     * @inheritdoc TokenRouter\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _amount,\n        bytes calldata // no metadata\n    ) internal virtual override {\n        Address.sendValue(payable(_recipient), _amount);\n    }\n\n    receive() external payable {\n        emit Donation(msg.sender, msg.value);\n    }\n}\n"
      },
      "contracts/token/libs/FastTokenRouter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\n\nimport {TokenMessage} from \"./TokenMessage.sol\";\nimport {TokenRouter} from \"./TokenRouter.sol\";\n\n/**\n * @title Common FastTokenRouter functionality for ERC20 Tokens with remote transfer support.\n * @author Abacus Works\n */\nabstract contract FastTokenRouter is TokenRouter {\n    using TypeCasts for bytes32;\n    using TokenMessage for bytes;\n\n    uint256 public fastTransferId;\n    // maps `fastTransferId` to the filler address.\n    mapping(bytes32 => address) filledFastTransfers;\n\n    /**\n     * @dev delegates transfer logic to `_transferTo`.\n     * @inheritdoc TokenRouter\n     */\n    function _handle(\n        uint32 _origin,\n        bytes32,\n        bytes calldata _message\n    ) internal virtual override {\n        bytes32 recipient = _message.recipient();\n        uint256 amount = _message.amount();\n        bytes calldata metadata = _message.metadata();\n        _transferTo(recipient.bytes32ToAddress(), amount, _origin, metadata);\n        emit ReceivedTransferRemote(_origin, recipient, amount);\n    }\n\n    /**\n     * @dev Transfers `_amount` of token to `_recipient`/`fastFiller` who provided LP.\n     * @dev Called by `handle` after message decoding.\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _amount,\n        uint32 _origin,\n        bytes calldata _metadata\n    ) internal virtual {\n        address _tokenRecipient = _getTokenRecipient(\n            _recipient,\n            _amount,\n            _origin,\n            _metadata\n        );\n\n        _fastTransferTo(_tokenRecipient, _amount);\n    }\n\n    /**\n     * @dev allows an external user to full an unfilled fast transfer order.\n     * @param _recipient The recipient of the wrapped token on base chain.\n     * @param _amount The amount of wrapped tokens that is being bridged.\n     * @param _fastFee The fee the bridging entity will pay.\n     * @param _fastTransferId Id assigned on the remote chain to uniquely identify the transfer.\n     */\n    function fillFastTransfer(\n        address _recipient,\n        uint256 _amount,\n        uint256 _fastFee,\n        uint32 _origin,\n        uint256 _fastTransferId\n    ) external virtual {\n        bytes32 filledFastTransfersKey = _getFastTransfersKey(\n            _origin,\n            _fastTransferId,\n            _amount,\n            _fastFee,\n            _recipient\n        );\n        require(\n            filledFastTransfers[filledFastTransfersKey] == address(0),\n            \"request already filled\"\n        );\n\n        filledFastTransfers[filledFastTransfersKey] = msg.sender;\n\n        _fastRecieveFrom(msg.sender, _amount - _fastFee);\n        _fastTransferTo(_recipient, _amount - _fastFee);\n    }\n\n    /**\n     * @dev Transfers `_amountOrId` token to `_recipient` on `_destination` domain.\n     * @dev Delegates transfer logic to `_fastTransferFromSender` implementation.\n     * @dev Emits `SentTransferRemote` event on the origin chain.\n     * @param _destination The identifier of the destination chain.\n     * @param _recipient The address of the recipient on the destination chain.\n     * @param _amountOrId The amount or identifier of tokens to be sent to the remote recipient.\n     * @return messageId The identifier of the dispatched message.\n     */\n    function fastTransferRemote(\n        uint32 _destination,\n        bytes32 _recipient,\n        uint256 _amountOrId,\n        uint256 _fastFee\n    ) public payable virtual returns (bytes32 messageId) {\n        uint256 _fastTransferId = fastTransferId + 1;\n        fastTransferId = _fastTransferId;\n        bytes memory metadata = _fastTransferFromSender(\n            _amountOrId,\n            _fastFee,\n            _fastTransferId\n        );\n\n        messageId = _dispatch(\n            _destination,\n            TokenMessage.format(_recipient, _amountOrId, metadata)\n        );\n        emit SentTransferRemote(_destination, _recipient, _amountOrId);\n    }\n\n    /**\n     * @dev Burns `_amount` of token from `msg.sender` balance.\n     * @dev Pays `_fastFee` of tokens to LP on source chain.\n     * @dev Returns `fastFee` as bytes in the form of metadata.\n     */\n    function _fastTransferFromSender(\n        uint256 _amount,\n        uint256 _fastFee,\n        uint256 _fastTransferId\n    ) internal virtual returns (bytes memory) {\n        _fastRecieveFrom(msg.sender, _amount);\n        return abi.encode(_fastFee, _fastTransferId);\n    }\n\n    /**\n     * @dev returns an address that indicates who should receive the bridged tokens.\n     * @dev if _fastFees was included and someone filled the order before the mailbox made the contract call, the filler gets the funds.\n     */\n    function _getTokenRecipient(\n        address _recipient,\n        uint256 _amount,\n        uint32 _origin,\n        bytes calldata _metadata\n    ) internal view returns (address) {\n        if (_metadata.length == 0) {\n            return _recipient;\n        }\n\n        // decode metadata to extract `_fastFee` and `_fastTransferId`.\n        (uint256 _fastFee, uint256 _fastTransferId) = abi.decode(\n            _metadata,\n            (uint256, uint256)\n        );\n\n        address _fillerAddress = filledFastTransfers[\n            _getFastTransfersKey(\n                _origin,\n                _fastTransferId,\n                _amount,\n                _fastFee,\n                _recipient\n            )\n        ];\n        if (_fillerAddress != address(0)) {\n            return _fillerAddress;\n        }\n\n        return _recipient;\n    }\n\n    /**\n     * @dev generates the key for storing the filler address of fast transfers.\n     */\n    function _getFastTransfersKey(\n        uint32 _origin,\n        uint256 _fastTransferId,\n        uint256 _amount,\n        uint256 _fastFee,\n        address _recipient\n    ) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encodePacked(\n                    _origin,\n                    _fastTransferId,\n                    _amount,\n                    _fastFee,\n                    _recipient\n                )\n            );\n    }\n\n    /**\n     * @dev Should transfer `_amount` of tokens to `_recipient`.\n     * @dev The implementation is delegated.\n     */\n    function _fastTransferTo(\n        address _recipient,\n        uint256 _amount\n    ) internal virtual;\n\n    /**\n     * @dev Should collect `amount` of tokens from `_sender`.\n     * @dev The implementation is delegated.\n     */\n    function _fastRecieveFrom(\n        address _sender,\n        uint256 _amount\n    ) internal virtual;\n}\n"
      },
      "contracts/token/libs/TokenMessage.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.8.0;\n\nlibrary TokenMessage {\n    function format(\n        bytes32 _recipient,\n        uint256 _amount,\n        bytes memory _metadata\n    ) internal pure returns (bytes memory) {\n        return abi.encodePacked(_recipient, _amount, _metadata);\n    }\n\n    function recipient(bytes calldata message) internal pure returns (bytes32) {\n        return bytes32(message[0:32]);\n    }\n\n    function amount(bytes calldata message) internal pure returns (uint256) {\n        return uint256(bytes32(message[32:64]));\n    }\n\n    // alias for ERC721\n    function tokenId(bytes calldata message) internal pure returns (uint256) {\n        return amount(message);\n    }\n\n    function metadata(\n        bytes calldata message\n    ) internal pure returns (bytes calldata) {\n        return message[64:];\n    }\n}\n"
      },
      "contracts/token/libs/TokenRouter.sol": {
        "content": "// SPDX-License-Identifier: Apache-2.0\npragma solidity >=0.8.0;\n\nimport {GasRouter} from \"../../client/GasRouter.sol\";\nimport {MailboxClient} from \"../../client/MailboxClient.sol\";\nimport {TypeCasts} from \"../../libs/TypeCasts.sol\";\nimport {TokenMessage} from \"./TokenMessage.sol\";\n\n/**\n * @title Hyperlane Token Router that extends Router with abstract token (ERC20/ERC721) remote transfer functionality.\n * @author Abacus Works\n */\nabstract contract TokenRouter is GasRouter {\n    using TypeCasts for bytes32;\n    using TypeCasts for address;\n    using TokenMessage for bytes;\n\n    /**\n     * @dev Emitted on `transferRemote` when a transfer message is dispatched.\n     * @param destination The identifier of the destination chain.\n     * @param recipient The address of the recipient on the destination chain.\n     * @param amount The amount of tokens burnt on the origin chain.\n     */\n    event SentTransferRemote(\n        uint32 indexed destination,\n        bytes32 indexed recipient,\n        uint256 amount\n    );\n\n    /**\n     * @dev Emitted on `_handle` when a transfer message is processed.\n     * @param origin The identifier of the origin chain.\n     * @param recipient The address of the recipient on the destination chain.\n     * @param amount The amount of tokens minted on the destination chain.\n     */\n    event ReceivedTransferRemote(\n        uint32 indexed origin,\n        bytes32 indexed recipient,\n        uint256 amount\n    );\n\n    constructor(address _mailbox) GasRouter(_mailbox) {}\n\n    /**\n     * @notice Transfers `_amountOrId` token to `_recipient` on `_destination` domain.\n     * @dev Delegates transfer logic to `_transferFromSender` implementation.\n     * @dev Emits `SentTransferRemote` event on the origin chain.\n     * @param _destination The identifier of the destination chain.\n     * @param _recipient The address of the recipient on the destination chain.\n     * @param _amountOrId The amount or identifier of tokens to be sent to the remote recipient.\n     * @return messageId The identifier of the dispatched message.\n     */\n    function transferRemote(\n        uint32 _destination,\n        bytes32 _recipient,\n        uint256 _amountOrId\n    ) external payable virtual returns (bytes32 messageId) {\n        return\n            _transferRemote(_destination, _recipient, _amountOrId, msg.value);\n    }\n\n    /**\n     * @notice Transfers `_amountOrId` token to `_recipient` on `_destination` domain.\n     * @dev Delegates transfer logic to `_transferFromSender` implementation.\n     * @dev Emits `SentTransferRemote` event on the origin chain.\n     * @param _destination The identifier of the destination chain.\n     * @param _recipient The address of the recipient on the destination chain.\n     * @param _amountOrId The amount or identifier of tokens to be sent to the remote recipient.\n     * @param _gasPayment The amount of native token to pay for interchain gas.\n     * @return messageId The identifier of the dispatched message.\n     */\n    function _transferRemote(\n        uint32 _destination,\n        bytes32 _recipient,\n        uint256 _amountOrId,\n        uint256 _gasPayment\n    ) internal returns (bytes32 messageId) {\n        bytes memory metadata = _transferFromSender(_amountOrId);\n        messageId = _dispatch(\n            _destination,\n            _gasPayment,\n            TokenMessage.format(_recipient, _amountOrId, metadata)\n        );\n        emit SentTransferRemote(_destination, _recipient, _amountOrId);\n    }\n\n    /**\n     * @dev Should transfer `_amountOrId` of tokens from `msg.sender` to this token router.\n     * @dev Called by `transferRemote` before message dispatch.\n     * @dev Optionally returns `metadata` associated with the transfer to be passed in message.\n     */\n    function _transferFromSender(\n        uint256 _amountOrId\n    ) internal virtual returns (bytes memory metadata);\n\n    /**\n     * @notice Returns the balance of `account` on this token router.\n     * @param account The address to query the balance of.\n     * @return The balance of `account`.\n     */\n    function balanceOf(address account) external virtual returns (uint256);\n\n    /**\n     * @dev Mints tokens to recipient when router receives transfer message.\n     * @dev Emits `ReceivedTransferRemote` event on the destination chain.\n     * @param _origin The identifier of the origin chain.\n     * @param _message The encoded remote transfer message containing the recipient address and amount.\n     */\n    function _handle(\n        uint32 _origin,\n        bytes32,\n        bytes calldata _message\n    ) internal virtual override {\n        bytes32 recipient = _message.recipient();\n        uint256 amount = _message.amount();\n        bytes calldata metadata = _message.metadata();\n        _transferTo(recipient.bytes32ToAddress(), amount, metadata);\n        emit ReceivedTransferRemote(_origin, recipient, amount);\n    }\n\n    /**\n     * @dev Should transfer `_amountOrId` of tokens from this token router to `_recipient`.\n     * @dev Called by `handle` after message decoding.\n     * @dev Optionally handles `metadata` associated with transfer passed in message.\n     */\n    function _transferTo(\n        address _recipient,\n        uint256 _amountOrId,\n        bytes calldata metadata\n    ) internal virtual;\n}\n"
      },
      "contracts/upgrade/ProxyAdmin.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/transparent/ProxyAdmin.sol)\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol\";\n"
      },
      "contracts/upgrade/TimelockController.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (governance/TimelockController.sol)\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/governance/TimelockController.sol\";\n"
      },
      "contracts/upgrade/TransparentUpgradeableProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.7.0) (proxy/transparent/TransparentUpgradeableProxy.sol)\n\npragma solidity ^0.8.0;\n\nimport \"@openzeppelin/contracts/proxy/transparent/TransparentUpgradeableProxy.sol\";\n"
      },
      "contracts/upgrade/Versioned.sol": {
        "content": "// SPDX-License-Identifier: MIT OR Apache-2.0\npragma solidity >=0.6.11;\n\n/**\n * @title Versioned\n * @notice Version getter for contracts\n **/\ncontract Versioned {\n    uint8 public constant VERSION = 3;\n}\n"
      }
    },
    "settings": {
      "optimizer": {
        "enabled": true,
        "runs": 999999
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    }
  }}