creation_sourcecode: {{
    "language": "Solidity",
    "settings": {
      "evmVersion": "istanbul",
      "libraries": {},
      "metadata": {
        "bytecodeHash": "ipfs",
        "useLiteralContent": true
      },
      "optimizer": {
        "enabled": true,
        "runs": 200
      },
      "remappings": [],
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      }
    },
    "sources": {
      "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/ContextUpgradeable.sol\";\nimport \"../proxy/Initializable.sol\";\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 initializer {\n        __Context_init_unchained();\n        __Ownable_init_unchained();\n    }\n\n    function __Ownable_init_unchained() internal initializer {\n        address msgSender = _msgSender();\n        _owner = msgSender;\n        emit OwnershipTransferred(address(0), msgSender);\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 called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = 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        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n    uint256[49] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/drafts/EIP712Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\nimport \"../proxy/Initializable.sol\";\n\n/**\n * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.\n *\n * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,\n * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding\n * they need in their contracts using a combination of `abi.encode` and `keccak256`.\n *\n * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding\n * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA\n * ({_hashTypedDataV4}).\n *\n * The implementation of the domain separator was designed to be as efficient as possible while still properly updating\n * the chain id to protect against replay attacks on an eventual fork of the chain.\n *\n * NOTE: This contract implements the version of the encoding known as \"v4\", as implemented by the JSON RPC method\n * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].\n *\n * _Available since v3.4._\n */\nabstract contract EIP712Upgradeable is Initializable {\n    /* solhint-disable var-name-mixedcase */\n    bytes32 private _HASHED_NAME;\n    bytes32 private _HASHED_VERSION;\n    bytes32 private constant _TYPE_HASH = keccak256(\"EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)\");\n    /* solhint-enable var-name-mixedcase */\n\n    /**\n     * @dev Initializes the domain separator and parameter caches.\n     *\n     * The meaning of `name` and `version` is specified in\n     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:\n     *\n     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.\n     * - `version`: the current major version of the signing domain.\n     *\n     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart\n     * contract upgrade].\n     */\n    function __EIP712_init(string memory name, string memory version) internal initializer {\n        __EIP712_init_unchained(name, version);\n    }\n\n    function __EIP712_init_unchained(string memory name, string memory version) internal initializer {\n        bytes32 hashedName = keccak256(bytes(name));\n        bytes32 hashedVersion = keccak256(bytes(version));\n        _HASHED_NAME = hashedName;\n        _HASHED_VERSION = hashedVersion;\n    }\n\n    /**\n     * @dev Returns the domain separator for the current chain.\n     */\n    function _domainSeparatorV4() internal view returns (bytes32) {\n        return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());\n    }\n\n    function _buildDomainSeparator(bytes32 typeHash, bytes32 name, bytes32 version) private view returns (bytes32) {\n        return keccak256(\n            abi.encode(\n                typeHash,\n                name,\n                version,\n                _getChainId(),\n                address(this)\n            )\n        );\n    }\n\n    /**\n     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this\n     * function returns the hash of the fully encoded EIP712 message for this domain.\n     *\n     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:\n     *\n     * ```solidity\n     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(\n     *     keccak256(\"Mail(address to,string contents)\"),\n     *     mailTo,\n     *     keccak256(bytes(mailContents))\n     * )));\n     * address signer = ECDSA.recover(digest, signature);\n     * ```\n     */\n    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {\n        return keccak256(abi.encodePacked(\"\\x19\\x01\", _domainSeparatorV4(), structHash));\n    }\n\n    function _getChainId() private view returns (uint256 chainId) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            chainId := chainid()\n        }\n    }\n\n    /**\n     * @dev The hash of the name parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712NameHash() internal virtual view returns (bytes32) {\n        return _HASHED_NAME;\n    }\n\n    /**\n     * @dev The hash of the version parameter for the EIP712 domain.\n     *\n     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs\n     * are a concern.\n     */\n    function _EIP712VersionHash() internal virtual view returns (bytes32) {\n        return _HASHED_VERSION;\n    }\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/introspection/IERC165Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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/math/SafeMathUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMathUpgradeable {\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        uint256 c = a + b;\n        if (c < a) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b > a) return (false, 0);\n        return (true, a - b);\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) return (true, 0);\n        uint256 c = a * b;\n        if (c / a != b) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a / b);\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a % b);\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b <= a, \"SafeMath: subtraction overflow\");\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (a == 0) return 0;\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: division by zero\");\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: modulo by zero\");\n        return a % b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {trySub}.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryDiv}.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting with custom message when dividing by zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryMod}.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a % b;\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/proxy/Initializable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\n// solhint-disable-next-line compiler-version\npragma solidity >=0.4.24 <0.8.0;\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 a proxied contract can't have 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 * 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 {UpgradeableProxy-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 */\nabstract contract Initializable {\n\n    /**\n     * @dev Indicates that the contract has been initialized.\n     */\n    bool 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 Modifier to protect an initializer function from being invoked twice.\n     */\n    modifier initializer() {\n        require(_initializing || _isConstructor() || !_initialized, \"Initializable: contract is already initialized\");\n\n        bool isTopLevelCall = !_initializing;\n        if (isTopLevelCall) {\n            _initializing = true;\n            _initialized = true;\n        }\n\n        _;\n\n        if (isTopLevelCall) {\n            _initializing = false;\n        }\n    }\n\n    /// @dev Returns true if and only if the function is running in the constructor\n    function _isConstructor() private view returns (bool) {\n        return !AddressUpgradeable.isContract(address(this));\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"../../introspection/IERC165Upgradeable.sol\";\n\n/**\n * @dev Required interface of an ERC1155 compliant contract, as defined in the\n * https://eips.ethereum.org/EIPS/eip-1155[EIP].\n *\n * _Available since v3.1._\n */\ninterface IERC1155Upgradeable is IERC165Upgradeable {\n    /**\n     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.\n     */\n    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);\n\n    /**\n     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all\n     * transfers.\n     */\n    event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);\n\n    /**\n     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to\n     * `approved`.\n     */\n    event ApprovalForAll(address indexed account, address indexed operator, bool approved);\n\n    /**\n     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.\n     *\n     * If an {URI} event was emitted for `id`, the standard\n     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value\n     * returned by {IERC1155MetadataURI-uri}.\n     */\n    event URI(string value, uint256 indexed id);\n\n    /**\n     * @dev Returns the amount of tokens of token type `id` owned by `account`.\n     *\n     * Requirements:\n     *\n     * - `account` cannot be the zero address.\n     */\n    function balanceOf(address account, uint256 id) external view returns (uint256);\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.\n     *\n     * Requirements:\n     *\n     * - `accounts` and `ids` must have the same length.\n     */\n    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory);\n\n    /**\n     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,\n     *\n     * Emits an {ApprovalForAll} event.\n     *\n     * Requirements:\n     *\n     * - `operator` cannot be the caller.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.\n     *\n     * See {setApprovalForAll}.\n     */\n    function isApprovedForAll(address account, address operator) external view returns (bool);\n\n    /**\n     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.\n     *\n     * Emits a {TransferSingle} event.\n     *\n     * Requirements:\n     *\n     * - `to` cannot be the zero address.\n     * - If the caller is not `from`, it must be have been approved to spend ``from``'s tokens via {setApprovalForAll}.\n     * - `from` must have a balance of tokens of type `id` of at least `amount`.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the\n     * acceptance magic value.\n     */\n    function safeTransferFrom(address from, address to, uint256 id, uint256 amount, bytes calldata data) external;\n\n    /**\n     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.\n     *\n     * Emits a {TransferBatch} event.\n     *\n     * Requirements:\n     *\n     * - `ids` and `amounts` must have the same length.\n     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the\n     * acceptance magic value.\n     */\n    function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data) external;\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Upgradeable {\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 `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);\n\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"
      },
      "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"../../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`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.\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 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 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 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    /**\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"
      },
      "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        // solhint-disable-next-line no-inline-assembly\n        assembly { size := extcodesize(account) }\n        return size > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value\n        (bool success, ) = recipient.call{ value: amount }(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain`call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n      return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data, string memory errorMessage) 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(address target, bytes memory data, uint256 value, string memory errorMessage) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.call{ value: value }(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        // solhint-disable-next-line avoid-low-level-calls\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return _verifyCallResult(success, returndata, errorMessage);\n    }\n\n    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                // solhint-disable-next-line no-inline-assembly\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
      },
      "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\nimport \"../proxy/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 GSN 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 initializer {\n        __Context_init_unchained();\n    }\n\n    function __Context_init_unchained() internal initializer {\n    }\n    function _msgSender() internal view virtual returns (address payable) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes memory) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n    uint256[50] private __gap;\n}\n"
      },
      "@openzeppelin/contracts/access/Ownable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../utils/Context.sol\";\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 () internal {\n        address msgSender = _msgSender();\n        _owner = msgSender;\n        emit OwnershipTransferred(address(0), msgSender);\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 called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        emit OwnershipTransferred(_owner, address(0));\n        _owner = 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        emit OwnershipTransferred(_owner, newOwner);\n        _owner = newOwner;\n    }\n}\n"
      },
      "@openzeppelin/contracts/introspection/ERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./IERC165.sol\";\n\n/**\n * @dev Implementation of the {IERC165} interface.\n *\n * Contracts may inherit from this and call {_registerInterface} to declare\n * their support of an interface.\n */\nabstract contract ERC165 is IERC165 {\n    /*\n     * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7\n     */\n    bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;\n\n    /**\n     * @dev Mapping of interface ids to whether or not it's supported.\n     */\n    mapping(bytes4 => bool) private _supportedInterfaces;\n\n    constructor () internal {\n        // Derived contracts need only register support for their own interfaces,\n        // we register support for ERC165 itself here\n        _registerInterface(_INTERFACE_ID_ERC165);\n    }\n\n    /**\n     * @dev See {IERC165-supportsInterface}.\n     *\n     * Time complexity O(1), guaranteed to always use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {\n        return _supportedInterfaces[interfaceId];\n    }\n\n    /**\n     * @dev Registers the contract as an implementer of the interface defined by\n     * `interfaceId`. Support of the actual ERC165 interface is automatic and\n     * registering its interface id is not required.\n     *\n     * See {IERC165-supportsInterface}.\n     *\n     * Requirements:\n     *\n     * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).\n     */\n    function _registerInterface(bytes4 interfaceId) internal virtual {\n        require(interfaceId != 0xffffffff, \"ERC165: invalid interface id\");\n        _supportedInterfaces[interfaceId] = true;\n    }\n}\n"
      },
      "@openzeppelin/contracts/introspection/IERC165.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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/math/SafeMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Wrappers over Solidity's arithmetic operations with added overflow\n * checks.\n *\n * Arithmetic operations in Solidity wrap on overflow. This can easily result\n * in bugs, because programmers usually assume that an overflow raises an\n * error, which is the standard behavior in high level programming languages.\n * `SafeMath` restores this intuition by reverting the transaction when an\n * operation overflows.\n *\n * Using this library instead of the unchecked operations eliminates an entire\n * class of bugs, so it's recommended to use it always.\n */\nlibrary SafeMath {\n    /**\n     * @dev Returns the addition of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        uint256 c = a + b;\n        if (c < a) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the substraction of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b > a) return (false, 0);\n        return (true, a - b);\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, with an overflow flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522\n        if (a == 0) return (true, 0);\n        uint256 c = a * b;\n        if (c / a != b) return (false, 0);\n        return (true, c);\n    }\n\n    /**\n     * @dev Returns the division of two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a / b);\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.\n     *\n     * _Available since v3.4._\n     */\n    function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {\n        if (b == 0) return (false, 0);\n        return (true, a % b);\n    }\n\n    /**\n     * @dev Returns the addition of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `+` operator.\n     *\n     * Requirements:\n     *\n     * - Addition cannot overflow.\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a, \"SafeMath: addition overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting on\n     * overflow (when the result is negative).\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b <= a, \"SafeMath: subtraction overflow\");\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the multiplication of two unsigned integers, reverting on\n     * overflow.\n     *\n     * Counterpart to Solidity's `*` operator.\n     *\n     * Requirements:\n     *\n     * - Multiplication cannot overflow.\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        if (a == 0) return 0;\n        uint256 c = a * b;\n        require(c / a == b, \"SafeMath: multiplication overflow\");\n        return c;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting on\n     * division by zero. The result is rounded towards zero.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: division by zero\");\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting when dividing by zero.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b > 0, \"SafeMath: modulo by zero\");\n        return a % b;\n    }\n\n    /**\n     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on\n     * overflow (when the result is negative).\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {trySub}.\n     *\n     * Counterpart to Solidity's `-` operator.\n     *\n     * Requirements:\n     *\n     * - Subtraction cannot overflow.\n     */\n    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b <= a, errorMessage);\n        return a - b;\n    }\n\n    /**\n     * @dev Returns the integer division of two unsigned integers, reverting with custom message on\n     * division by zero. The result is rounded towards zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryDiv}.\n     *\n     * Counterpart to Solidity's `/` operator. Note: this function uses a\n     * `revert` opcode (which leaves remaining gas untouched) while Solidity\n     * uses an invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a / b;\n    }\n\n    /**\n     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),\n     * reverting with custom message when dividing by zero.\n     *\n     * CAUTION: This function is deprecated because it requires allocating memory for the error\n     * message unnecessarily. For custom revert reasons use {tryMod}.\n     *\n     * Counterpart to Solidity's `%` operator. This function uses a `revert`\n     * opcode (which leaves remaining gas untouched) while Solidity uses an\n     * invalid opcode to revert (consuming all remaining gas).\n     *\n     * Requirements:\n     *\n     * - The divisor cannot be zero.\n     */\n    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {\n        require(b > 0, errorMessage);\n        return a % b;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC1155/ERC1155Holder.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./ERC1155Receiver.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\ncontract ERC1155Holder is ERC1155Receiver {\n    function onERC1155Received(address, address, uint256, uint256, bytes memory) public virtual override returns (bytes4) {\n        return this.onERC1155Received.selector;\n    }\n\n    function onERC1155BatchReceived(address, address, uint256[] memory, uint256[] memory, bytes memory) public virtual override returns (bytes4) {\n        return this.onERC1155BatchReceived.selector;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC1155/ERC1155Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./IERC1155Receiver.sol\";\nimport \"../../introspection/ERC165.sol\";\n\n/**\n * @dev _Available since v3.1._\n */\nabstract contract ERC1155Receiver is ERC165, IERC1155Receiver {\n    constructor() internal {\n        _registerInterface(\n            ERC1155Receiver(address(0)).onERC1155Received.selector ^\n            ERC1155Receiver(address(0)).onERC1155BatchReceived.selector\n        );\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"../../introspection/IERC165.sol\";\n\n/**\n * _Available since v3.1._\n */\ninterface IERC1155Receiver is IERC165 {\n\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        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        @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    )\n        external\n        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. 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        @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    )\n        external\n        returns(bytes4);\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/ERC721Holder.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\nimport \"./IERC721Receiver.sol\";\n\n  /**\n   * @dev Implementation of the {IERC721Receiver} interface.\n   *\n   * Accepts all token transfers. \n   * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.\n   */\ncontract ERC721Holder is IERC721Receiver {\n\n    /**\n     * @dev See {IERC721Receiver-onERC721Received}.\n     *\n     * Always returns `IERC721Receiver.onERC721Received.selector`.\n     */\n    function onERC721Received(address, address, uint256, bytes memory) public virtual override returns (bytes4) {\n        return this.onERC721Received.selector;\n    }\n}\n"
      },
      "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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 `IERC721.onERC721Received.selector`.\n     */\n    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);\n}\n"
      },
      "@openzeppelin/contracts/utils/Context.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <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 GSN 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 payable) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes memory) {\n        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691\n        return msg.data;\n    }\n}\n"
      },
      "@rarible/exchange-interfaces/contracts/IAssetMatcher.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\n\ninterface IAssetMatcher {\n    function matchAssets(\n        LibAsset.AssetType memory leftAssetType,\n        LibAsset.AssetType memory rightAssetType\n    ) external view returns (LibAsset.AssetType memory);\n}\n"
      },
      "@rarible/exchange-interfaces/contracts/IERC20TransferProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\npragma abicoder v2;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\ninterface IERC20TransferProxy {\n    function erc20safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) external;\n}\n"
      },
      "@rarible/exchange-interfaces/contracts/INftTransferProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\npragma abicoder v2;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol\";\n\ninterface INftTransferProxy {\n    function erc721safeTransferFrom(IERC721Upgradeable token, address from, address to, uint256 tokenId) external;\n\n    function erc1155safeTransferFrom(IERC1155Upgradeable token, address from, address to, uint256 id, uint256 value, bytes calldata data) external;\n}\n"
      },
      "@rarible/exchange-interfaces/contracts/IRoyaltiesProvider.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\npragma abicoder v2;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\ninterface IRoyaltiesProvider {\n    function getRoyalties(address token, uint tokenId) external returns (LibPart.Part[] memory);\n}\n"
      },
      "@rarible/exchange-interfaces/contracts/ITransferProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\npragma abicoder v2;\n\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\n\ninterface ITransferProxy {\n    function transfer(LibAsset.Asset calldata asset, address from, address to) external;\n}\n"
      },
      "@rarible/exchange-v2/contracts/AssetMatcher.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/exchange-interfaces/contracts/IAssetMatcher.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nabstract contract AssetMatcher is Initializable, OwnableUpgradeable {\n\n    bytes constant EMPTY = \"\";\n    mapping(bytes4 => address) internal matchers;\n\n    event MatcherChange(bytes4 indexed assetType, address matcher);\n\n    function setAssetMatcher(bytes4 assetType, address matcher) external onlyOwner {\n        matchers[assetType] = matcher;\n        emit MatcherChange(assetType, matcher);\n    }\n\n    function matchAssets(LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType) internal view returns (LibAsset.AssetType memory) {\n        LibAsset.AssetType memory result = matchAssetOneSide(leftAssetType, rightAssetType);\n        if (result.assetClass == 0) {\n            return matchAssetOneSide(rightAssetType, leftAssetType);\n        } else {\n            return result;\n        }\n    }\n\n    function matchAssetOneSide(LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType) private view returns (LibAsset.AssetType memory) {\n        bytes4 classLeft = leftAssetType.assetClass;\n        bytes4 classRight = rightAssetType.assetClass;\n        if (classLeft == LibAsset.ETH_ASSET_CLASS) {\n            if (classRight == LibAsset.ETH_ASSET_CLASS) {\n                return leftAssetType;\n            }\n            return LibAsset.AssetType(0, EMPTY);\n        }\n        if (classLeft == LibAsset.ERC20_ASSET_CLASS) {\n            if (classRight == LibAsset.ERC20_ASSET_CLASS) {\n                return simpleMatch(leftAssetType, rightAssetType);\n            }\n            return LibAsset.AssetType(0, EMPTY);\n        }\n        if (classLeft == LibAsset.ERC721_ASSET_CLASS) {\n            if (classRight == LibAsset.ERC721_ASSET_CLASS) {\n                return simpleMatch(leftAssetType, rightAssetType);\n            }\n            return LibAsset.AssetType(0, EMPTY);\n        }\n        if (classLeft == LibAsset.ERC1155_ASSET_CLASS) {\n            if (classRight == LibAsset.ERC1155_ASSET_CLASS) {\n                return simpleMatch(leftAssetType, rightAssetType);\n            }\n            return LibAsset.AssetType(0, EMPTY);\n        }\n        address matcher = matchers[classLeft];\n        if (matcher != address(0)) {\n            return IAssetMatcher(matcher).matchAssets(leftAssetType, rightAssetType);\n        }\n        if (classLeft == classRight) {\n            return simpleMatch(leftAssetType, rightAssetType);\n        }\n        revert(\"not found IAssetMatcher\");\n    }\n\n    function simpleMatch(LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType) private pure returns (LibAsset.AssetType memory) {\n        bytes32 leftHash = keccak256(leftAssetType.data);\n        bytes32 rightHash = keccak256(rightAssetType.data);\n        if (leftHash == rightHash) {\n            return leftAssetType;\n        }\n        return LibAsset.AssetType(0, EMPTY);\n    }\n\n    uint256[49] private __gap;\n}\n"
      },
      "@rarible/exchange-v2/contracts/ExchangeV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"./ExchangeV2Core.sol\";\nimport \"@rarible/transfer-manager/contracts/RaribleTransferManager.sol\";\n\ncontract ExchangeV2 is ExchangeV2Core, RaribleTransferManager {\n    function __ExchangeV2_init(\n        address _transferProxy,\n        address _erc20TransferProxy,\n        uint newProtocolFee,\n        address newDefaultFeeReceiver,\n        IRoyaltiesProvider newRoyaltiesProvider\n    ) external initializer {\n        __Context_init_unchained();\n        __Ownable_init_unchained();\n        __TransferExecutor_init_unchained(_transferProxy, _erc20TransferProxy);\n        __RaribleTransferManager_init_unchained(newProtocolFee, newDefaultFeeReceiver, newRoyaltiesProvider);\n        __OrderValidator_init_unchained();\n    }\n\n}\n"
      },
      "@rarible/exchange-v2/contracts/ExchangeV2Core.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"./libraries/LibFill.sol\";\nimport \"./libraries/LibOrderData.sol\";\nimport \"./libraries/LibDirectTransfer.sol\";\nimport \"./OrderValidator.sol\";\nimport \"./AssetMatcher.sol\";\n\nimport \"@rarible/transfer-manager/contracts/TransferExecutor.sol\";\nimport \"@rarible/transfer-manager/contracts/interfaces/ITransferManager.sol\";\nimport \"@rarible/transfer-manager/contracts/lib/LibDeal.sol\";\n\nabstract contract ExchangeV2Core is Initializable, OwnableUpgradeable, AssetMatcher, TransferExecutor, OrderValidator, ITransferManager {\n    using SafeMathUpgradeable for uint;\n    using LibTransfer for address;\n\n    uint256 private constant UINT256_MAX = type(uint256).max;\n\n    //state of the orders\n    mapping(bytes32 => uint) public fills;\n\n    //events\n    event Cancel(bytes32 hash);\n    event Match(bytes32 leftHash, bytes32 rightHash, uint newLeftFill, uint newRightFill);\n\n    function cancel(LibOrder.Order memory order) external {\n        require(_msgSender() == order.maker, \"not a maker\");\n        require(order.salt != 0, \"0 salt can't be used\");\n        bytes32 orderKeyHash = LibOrder.hashKey(order);\n        fills[orderKeyHash] = UINT256_MAX;\n        emit Cancel(orderKeyHash);\n    }\n\n    /**\n     * @dev function, generate sellOrder and buyOrder from parameters and call validateAndMatch() for purchase transaction\n \n    */\n\n    function directPurchase(\n        LibDirectTransfer.Purchase calldata direct\n    ) external payable{\n        LibAsset.AssetType memory paymentAssetType = getPaymentAssetType(direct.paymentToken);\n                \n        LibOrder.Order memory sellOrder = LibOrder.Order(\n            direct.sellOrderMaker,\n            LibAsset.Asset(\n                LibAsset.AssetType(\n                    direct.nftAssetClass,\n                    direct.nftData\n                ),\n                direct.sellOrderNftAmount\n            ),\n            address(0),\n            LibAsset.Asset(\n                paymentAssetType,\n                direct.sellOrderPaymentAmount\n            ),\n            direct.sellOrderSalt,\n            direct.sellOrderStart,\n            direct.sellOrderEnd,\n            direct.sellOrderDataType,\n            direct.sellOrderData\n        );\n\n        LibOrder.Order memory buyOrder = LibOrder.Order(\n            address(0),\n            LibAsset.Asset(\n                paymentAssetType,\n                direct.buyOrderPaymentAmount\n            ),\n            address(0),\n            LibAsset.Asset(\n                LibAsset.AssetType(\n                    direct.nftAssetClass,\n                    direct.nftData\n                ),\n                direct.buyOrderNftAmount\n            ),\n            0,\n            0,\n            0,\n            direct.sellOrderDataType,\n            direct.buyOrderData\n        );\n\n        validateFull(sellOrder, direct.sellOrderSignature);\n\n        matchAndTransfer(sellOrder, buyOrder);\n    }\n\n    /**\n     * @dev function, generate sellOrder and buyOrder from parameters and call validateAndMatch() for accept bid transaction\n     * @param direct struct with parameters for accept bid operation\n     */\n    function directAcceptBid(\n        LibDirectTransfer.AcceptBid calldata direct\n    ) external payable {\n        LibAsset.AssetType memory paymentAssetType = getPaymentAssetType(direct.paymentToken);\n\n        LibOrder.Order memory buyOrder = LibOrder.Order(\n            direct.bidMaker,\n            LibAsset.Asset(\n                paymentAssetType,\n                direct.bidPaymentAmount\n            ),\n            address(0),\n            LibAsset.Asset(\n                LibAsset.AssetType(\n                    direct.nftAssetClass,\n                    direct.nftData\n                ),\n                direct.bidNftAmount\n            ),\n            direct.bidSalt,\n            direct.bidStart,\n            direct.bidEnd,\n            direct.bidDataType,\n            direct.bidData\n        );\n\n        LibOrder.Order memory sellOrder = LibOrder.Order(\n            address(0),\n            LibAsset.Asset(\n                LibAsset.AssetType(\n                    direct.nftAssetClass,\n                    direct.nftData\n                ),\n                direct.sellOrderNftAmount\n            ),\n            address(0),\n            LibAsset.Asset(\n                paymentAssetType,\n                direct.sellOrderPaymentAmount\n            ),\n            0,\n            0,\n            0,\n            direct.bidDataType,\n            direct.sellOrderData\n        );\n\n        validateFull(buyOrder, direct.bidSignature);\n\n        matchAndTransfer(sellOrder, buyOrder);\n    }\n\n    function matchOrders(\n        LibOrder.Order memory orderLeft,\n        bytes memory signatureLeft,\n        LibOrder.Order memory orderRight,\n        bytes memory signatureRight\n    ) external payable {\n        validateOrders(orderLeft, signatureLeft, orderRight, signatureRight);\n        matchAndTransfer(orderLeft, orderRight);\n    }\n\n    /**\n      * @dev function, validate orders\n      * @param orderLeft left order\n      * @param signatureLeft order left signature\n      * @param orderRight right order\n      * @param signatureRight order right signature\n      */\n    function validateOrders(LibOrder.Order memory orderLeft, bytes memory signatureLeft, LibOrder.Order memory orderRight, bytes memory signatureRight) internal view {\n        validateFull(orderLeft, signatureLeft);\n        validateFull(orderRight, signatureRight);\n        if (orderLeft.taker != address(0)) {\n            if (orderRight.maker != address(0))\n                require(orderRight.maker == orderLeft.taker, \"leftOrder.taker verification failed\");\n        }\n        if (orderRight.taker != address(0)) {\n            if (orderLeft.maker != address(0))\n                require(orderRight.taker == orderLeft.maker, \"rightOrder.taker verification failed\");\n        }\n    }\n\n    /**\n        @notice matches valid orders and transfers their assets\n        @param orderLeft the left order of the match\n        @param orderRight the right order of the match\n    */\n    function matchAndTransfer(LibOrder.Order memory orderLeft, LibOrder.Order memory orderRight) internal {\n        (LibAsset.AssetType memory makeMatch, LibAsset.AssetType memory takeMatch) = matchAssets(orderLeft, orderRight);\n\n        (LibOrderData.GenericOrderData memory leftOrderData, LibOrderData.GenericOrderData memory rightOrderData, LibFill.FillResult memory newFill) =\n            parseOrdersSetFillEmitMatch(orderLeft, orderRight);\n\n        (uint totalMakeValue, uint totalTakeValue) = doTransfers(\n            LibDeal.DealSide({\n                asset: LibAsset.Asset({\n                    assetType: makeMatch,\n                    value: newFill.leftValue\n                }),\n                payouts: leftOrderData.payouts,\n                originFees: leftOrderData.originFees,\n                proxy: proxies[makeMatch.assetClass],\n                from: orderLeft.maker\n            }), \n            LibDeal.DealSide({\n                asset: LibAsset.Asset( \n                    takeMatch,\n                    newFill.rightValue\n                ),\n                payouts: rightOrderData.payouts,\n                originFees: rightOrderData.originFees,\n                proxy: proxies[takeMatch.assetClass],\n                from: orderRight.maker\n            }),\n            LibFeeSide.getFeeSide(makeMatch.assetClass, takeMatch.assetClass)\n        );\n        if (makeMatch.assetClass == LibAsset.ETH_ASSET_CLASS) {\n            require(takeMatch.assetClass != LibAsset.ETH_ASSET_CLASS);\n            require(msg.value >= totalMakeValue, \"not enough eth\");\n            if (msg.value > totalMakeValue) {\n                address(msg.sender).transferEth(msg.value.sub(totalMakeValue));\n            }\n        } else if (takeMatch.assetClass == LibAsset.ETH_ASSET_CLASS) {\n            require(msg.value >= totalTakeValue, \"not enough eth\");\n            if (msg.value > totalTakeValue) {\n                address(msg.sender).transferEth(msg.value.sub(totalTakeValue));\n            }\n        }\n    }\n\n    function parseOrdersSetFillEmitMatch(\n        LibOrder.Order memory orderLeft,\n        LibOrder.Order memory orderRight\n    ) internal returns (LibOrderData.GenericOrderData memory leftOrderData, LibOrderData.GenericOrderData memory rightOrderData, LibFill.FillResult memory newFill) {\n        bytes32 leftOrderKeyHash = LibOrder.hashKey(orderLeft);\n        bytes32 rightOrderKeyHash = LibOrder.hashKey(orderRight);\n\n        address msgSender = _msgSender();\n        if (orderLeft.maker == address(0)) {\n            orderLeft.maker = msgSender;\n        }\n        if (orderRight.maker == address(0)) {\n            orderRight.maker = msgSender;\n        }\n\n        leftOrderData = LibOrderData.parse(orderLeft);\n        rightOrderData = LibOrderData.parse(orderRight);\n\n        newFill = setFillEmitMatch(\n            orderLeft,\n            orderRight,\n            leftOrderKeyHash,\n            rightOrderKeyHash,\n            leftOrderData.isMakeFill,\n            rightOrderData.isMakeFill\n        );\n    }\n\n    /**\n        @notice calculates fills for the matched orders and set them in \"fills\" mapping\n        @param orderLeft left order of the match\n        @param orderRight right order of the match\n        @param leftMakeFill true if the left orders uses make-side fills, false otherwise\n        @param rightMakeFill true if the right orders uses make-side fills, false otherwise\n        @return returns change in orders' fills by the match \n    */\n    function setFillEmitMatch(\n        LibOrder.Order memory orderLeft,\n        LibOrder.Order memory orderRight,\n        bytes32 leftOrderKeyHash,\n        bytes32 rightOrderKeyHash,\n        bool leftMakeFill,\n        bool rightMakeFill\n    ) internal returns (LibFill.FillResult memory) {\n        uint leftOrderFill = getOrderFill(orderLeft.salt, leftOrderKeyHash);\n        uint rightOrderFill = getOrderFill(orderRight.salt, rightOrderKeyHash);\n        LibFill.FillResult memory newFill = LibFill.fillOrder(orderLeft, orderRight, leftOrderFill, rightOrderFill, leftMakeFill, rightMakeFill);\n\n        if (orderLeft.makeAsset.value != 0 || orderRight.takeAsset.value != 0) {\n            require(newFill.leftValue > 0, \"nothing to fill\");\n        }\n        if (orderLeft.takeAsset.value != 0 || orderRight.makeAsset.value != 0) {\n            require(newFill.rightValue > 0, \"nothing to fill\");\n        }\n\n        if (orderLeft.salt != 0) {\n            if (leftMakeFill) {\n                fills[leftOrderKeyHash] = leftOrderFill.add(newFill.leftValue);\n            } else {\n                fills[leftOrderKeyHash] = leftOrderFill.add(newFill.rightValue);\n            }\n        }\n\n        if (orderRight.salt != 0) {\n            if (rightMakeFill) {\n                fills[rightOrderKeyHash] = rightOrderFill.add(newFill.rightValue);\n            } else {\n                fills[rightOrderKeyHash] = rightOrderFill.add(newFill.leftValue);\n            }\n        }\n\n        emit Match(leftOrderKeyHash, rightOrderKeyHash, newFill.rightValue, newFill.leftValue);\n\n        return newFill;\n    }\n\n    function getOrderFill(uint salt, bytes32 hash) internal view returns (uint fill) {\n        if (salt == 0) {\n            fill = 0;\n        } else {\n            fill = fills[hash];\n        }\n    }\n\n    function matchAssets(LibOrder.Order memory orderLeft, LibOrder.Order memory orderRight) internal view returns (LibAsset.AssetType memory makeMatch, LibAsset.AssetType memory takeMatch) {\n        makeMatch = matchAssets(orderLeft.makeAsset.assetType, orderRight.takeAsset.assetType);\n        require(makeMatch.assetClass != 0, \"assets don't match\");\n        takeMatch = matchAssets(orderLeft.takeAsset.assetType, orderRight.makeAsset.assetType);\n        require(takeMatch.assetClass != 0, \"assets don't match\");\n    }\n\n    function validateFull(LibOrder.Order memory order, bytes memory signature) internal view {\n        LibOrder.validateOrderTime(order);\n        validate(order, signature);\n    }\n\n    function getPaymentAssetType(address token) internal pure returns(LibAsset.AssetType memory){\n        LibAsset.AssetType memory result;\n        if(token == address(0)) {\n            result.assetClass = LibAsset.ETH_ASSET_CLASS;\n        } else {\n            result.assetClass = LibAsset.ERC20_ASSET_CLASS;\n            result.data = abi.encode(token);\n        }\n        return result;\n    }\n\n    uint256[49] private __gap;\n}\n"
      },
      "@rarible/exchange-v2/contracts/OrderValidator.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"./libraries/LibOrder.sol\";\n\nimport \"@rarible/lib-signature/contracts/IERC1271.sol\";\nimport \"@rarible/lib-signature/contracts/LibSignature.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/drafts/EIP712Upgradeable.sol\";\n\nabstract contract OrderValidator is Initializable, ContextUpgradeable, EIP712Upgradeable {\n    using LibSignature for bytes32;\n    using AddressUpgradeable for address;\n    \n    bytes4 constant internal MAGICVALUE = 0x1626ba7e;\n\n    function __OrderValidator_init_unchained() internal initializer {\n        __EIP712_init_unchained(\"Exchange\", \"2\");\n    }\n\n    function validate(LibOrder.Order memory order, bytes memory signature) internal view {\n        if (order.salt == 0) {\n            if (order.maker != address(0)) {\n                require(_msgSender() == order.maker, \"maker is not tx sender\");\n            }\n        } else {\n            if (_msgSender() != order.maker) {\n                bytes32 hash = LibOrder.hash(order);\n                // if maker is contract checking ERC1271 signature\n                if (order.maker.isContract()) {\n                    require(\n                        IERC1271(order.maker).isValidSignature(_hashTypedDataV4(hash), signature) == MAGICVALUE,\n                        \"contract order signature verification error\"\n                    );\n                } else {\n                    // if maker is not contract then checking ECDSA signature\n                    if (_hashTypedDataV4(hash).recover(signature) != order.maker) {\n                        revert(\"order signature verification error\");\n                    } else {\n                        require (order.maker != address(0), \"no maker\");\n                    }\n                }\n            }\n        }\n    }\n\n    uint256[50] private __gap;\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibDirectTransfer.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\n\nlibrary LibDirectTransfer { //LibDirectTransfers\n    /*All buy parameters need for create buyOrder and sellOrder*/\n    struct Purchase {\n        address sellOrderMaker; //\n        uint256 sellOrderNftAmount;\n        bytes4 nftAssetClass;\n        bytes nftData;\n        uint256 sellOrderPaymentAmount;\n        address paymentToken;\n        uint256 sellOrderSalt;\n        uint sellOrderStart;\n        uint sellOrderEnd;\n        bytes4 sellOrderDataType;\n        bytes sellOrderData;\n        bytes sellOrderSignature;\n\n        uint256 buyOrderPaymentAmount;\n        uint256 buyOrderNftAmount;\n        bytes buyOrderData;\n    }\n\n    /*All accept bid parameters need for create buyOrder and sellOrder*/\n    struct AcceptBid {\n        address bidMaker; //\n        uint256 bidNftAmount;\n        bytes4 nftAssetClass;\n        bytes nftData;\n        uint256 bidPaymentAmount;\n        address paymentToken;\n        uint256 bidSalt;\n        uint bidStart;\n        uint bidEnd;\n        bytes4 bidDataType;\n        bytes bidData;\n        bytes bidSignature;\n\n        uint256 sellOrderPaymentAmount;\n        uint256 sellOrderNftAmount;\n        bytes sellOrderData;\n    }\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibFill.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"./LibOrder.sol\";\n\nlibrary LibFill {\n    struct FillResult {\n        uint leftValue;\n        uint rightValue;\n    }\n\n    struct IsMakeFill {\n        bool leftMake;\n        bool rightMake;\n    }\n\n    /**\n     * @dev Should return filled values\n     * @param leftOrder left order\n     * @param rightOrder right order\n     * @param leftOrderFill current fill of the left order (0 if order is unfilled)\n     * @param rightOrderFill current fill of the right order (0 if order is unfilled)\n     * @param leftIsMakeFill true if left orders fill is calculated from the make side, false if from the take side\n     * @param rightIsMakeFill true if right orders fill is calculated from the make side, false if from the take side\n     * @return tuple representing fill of both assets\n     */\n    function fillOrder(LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint leftOrderFill, uint rightOrderFill, bool leftIsMakeFill, bool rightIsMakeFill) internal pure returns (FillResult memory) {\n        (uint leftMakeValue, uint leftTakeValue) = LibOrder.calculateRemaining(leftOrder, leftOrderFill, leftIsMakeFill);\n        (uint rightMakeValue, uint rightTakeValue) = LibOrder.calculateRemaining(rightOrder, rightOrderFill, rightIsMakeFill);\n\n        //We have 3 cases here:\n        if (rightTakeValue > leftMakeValue || (rightTakeValue == leftMakeValue && leftMakeValue == 0)) { //1nd: left order should be fully filled\n            return fillLeft(leftMakeValue, leftTakeValue, rightOrder.makeAsset.value, rightOrder.takeAsset.value);\n        }//2st: right order should be fully filled or 3d: both should be fully filled if required values are the same\n        return fillRight(leftOrder.makeAsset.value, leftOrder.takeAsset.value, rightMakeValue, rightTakeValue);\n    }\n\n    function fillRight(uint leftMakeValue, uint leftTakeValue, uint rightMakeValue, uint rightTakeValue) internal pure returns (FillResult memory result) {\n        uint makerValue = LibMath.safeGetPartialAmountFloor(rightTakeValue, leftMakeValue, leftTakeValue);\n        require(makerValue <= rightMakeValue, \"fillRight: unable to fill\");\n        return FillResult(rightTakeValue, makerValue);\n    }\n\n    function fillLeft(uint leftMakeValue, uint leftTakeValue, uint rightMakeValue, uint rightTakeValue) internal pure returns (FillResult memory result) {\n        uint rightTake = LibMath.safeGetPartialAmountFloor(leftTakeValue, rightMakeValue, rightTakeValue);\n        require(rightTake <= leftMakeValue, \"fillLeft: unable to fill\");\n        return FillResult(leftMakeValue, leftTakeValue);\n    }\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibMath.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\";\n\nlibrary LibMath {\n    using SafeMathUpgradeable for uint;\n\n    /// @dev Calculates partial value given a numerator and denominator rounded down.\n    ///      Reverts if rounding error is >= 0.1%\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to calculate partial of.\n    /// @return partialAmount value of target rounded down.\n    function safeGetPartialAmountFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    ) internal pure returns (uint256 partialAmount) {\n        if (isRoundingErrorFloor(numerator, denominator, target)) {\n            revert(\"rounding error\");\n        }\n        partialAmount = numerator.mul(target).div(denominator);\n    }\n\n    /// @dev Checks if rounding error >= 0.1% when rounding down.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to multiply with numerator/denominator.\n    /// @return isError Rounding error is present.\n    function isRoundingErrorFloor(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    ) internal pure returns (bool isError) {\n        if (denominator == 0) {\n            revert(\"division by zero\");\n        }\n\n        // The absolute rounding error is the difference between the rounded\n        // value and the ideal value. The relative rounding error is the\n        // absolute rounding error divided by the absolute value of the\n        // ideal value. This is undefined when the ideal value is zero.\n        //\n        // The ideal value is `numerator * target / denominator`.\n        // Let's call `numerator * target % denominator` the remainder.\n        // The absolute error is `remainder / denominator`.\n        //\n        // When the ideal value is zero, we require the absolute error to\n        // be zero. Fortunately, this is always the case. The ideal value is\n        // zero iff `numerator == 0` and/or `target == 0`. In this case the\n        // remainder and absolute error are also zero.\n        if (target == 0 || numerator == 0) {\n            return false;\n        }\n\n        // Otherwise, we want the relative rounding error to be strictly\n        // less than 0.1%.\n        // The relative error is `remainder / (numerator * target)`.\n        // We want the relative error less than 1 / 1000:\n        //        remainder / (numerator * target)  <  1 / 1000\n        // or equivalently:\n        //        1000 * remainder  <  numerator * target\n        // so we have a rounding error iff:\n        //        1000 * remainder  >=  numerator * target\n        uint256 remainder = mulmod(\n            target,\n            numerator,\n            denominator\n        );\n        isError = remainder.mul(1000) >= numerator.mul(target);\n    }\n\n    function safeGetPartialAmountCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    ) internal pure returns (uint256 partialAmount) {\n        if (isRoundingErrorCeil(numerator, denominator, target)) {\n            revert(\"rounding error\");\n        }\n        partialAmount = numerator.mul(target).add(denominator.sub(1)).div(denominator);\n    }\n\n    /// @dev Checks if rounding error >= 0.1% when rounding up.\n    /// @param numerator Numerator.\n    /// @param denominator Denominator.\n    /// @param target Value to multiply with numerator/denominator.\n    /// @return isError Rounding error is present.\n    function isRoundingErrorCeil(\n        uint256 numerator,\n        uint256 denominator,\n        uint256 target\n    ) internal pure returns (bool isError) {\n        if (denominator == 0) {\n            revert(\"division by zero\");\n        }\n\n        // See the comments in `isRoundingError`.\n        if (target == 0 || numerator == 0) {\n            // When either is zero, the ideal value and rounded value are zero\n            // and there is no rounding error. (Although the relative error\n            // is undefined.)\n            return false;\n        }\n        // Compute remainder as before\n        uint256 remainder = mulmod(\n            target,\n            numerator,\n            denominator\n        );\n        remainder = denominator.sub(remainder) % denominator;\n        isError = remainder.mul(1000) >= numerator.mul(target);\n        return isError;\n    }\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibOrder.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\n\nimport \"./LibMath.sol\";\nimport \"./LibOrderDataV3.sol\";\nimport \"./LibOrderDataV2.sol\";\nimport \"./LibOrderDataV1.sol\";\n\nlibrary LibOrder {\n    using SafeMathUpgradeable for uint;\n\n    bytes32 constant ORDER_TYPEHASH = keccak256(\n        \"Order(address maker,Asset makeAsset,address taker,Asset takeAsset,uint256 salt,uint256 start,uint256 end,bytes4 dataType,bytes data)Asset(AssetType assetType,uint256 value)AssetType(bytes4 assetClass,bytes data)\"\n    );\n\n    bytes4 constant DEFAULT_ORDER_TYPE = 0xffffffff;\n\n    struct Order {\n        address maker;\n        LibAsset.Asset makeAsset;\n        address taker;\n        LibAsset.Asset takeAsset;\n        uint salt;\n        uint start;\n        uint end;\n        bytes4 dataType;\n        bytes data;\n    }\n\n    /**\n     * @dev Calculate remaining make and take values of the order (after partial filling real make and take decrease)\n     * @param order initial order to calculate remaining values for\n     * @param fill current fill of the left order (0 if order is unfilled)\n     * @param isMakeFill true if order fill is calculated from the make side, false if from the take side\n     * @return makeValue remaining make value of the order. if fill = 0 then it's order's make value\n     * @return takeValue remaining take value of the order. if fill = 0 then it's order's take value\n     */\n    function calculateRemaining(Order memory order, uint fill, bool isMakeFill) internal pure returns (uint makeValue, uint takeValue) {\n        if (isMakeFill) {\n            makeValue = order.makeAsset.value.sub(fill);\n            takeValue = LibMath.safeGetPartialAmountFloor(order.takeAsset.value, order.makeAsset.value, makeValue);\n        } else {\n            takeValue = order.takeAsset.value.sub(fill);\n            makeValue = LibMath.safeGetPartialAmountFloor(order.makeAsset.value, order.takeAsset.value, takeValue); \n        } \n    }\n\n    function hashKey(Order memory order) internal pure returns (bytes32) {\n        if (order.dataType == LibOrderDataV1.V1 || order.dataType == DEFAULT_ORDER_TYPE) {\n            return keccak256(abi.encode(\n                order.maker,\n                LibAsset.hash(order.makeAsset.assetType),\n                LibAsset.hash(order.takeAsset.assetType),\n                order.salt\n            ));\n        } else {\n            //order.data is in hash for V2, V3 and all new order\n            return keccak256(abi.encode(\n                order.maker,\n                LibAsset.hash(order.makeAsset.assetType),\n                LibAsset.hash(order.takeAsset.assetType),\n                order.salt,\n                order.data\n            ));\n        }\n    }\n\n    function hash(Order memory order) internal pure returns (bytes32) {\n        return keccak256(abi.encode(\n                ORDER_TYPEHASH,\n                order.maker,\n                LibAsset.hash(order.makeAsset),\n                order.taker,\n                LibAsset.hash(order.takeAsset),\n                order.salt,\n                order.start,\n                order.end,\n                order.dataType,\n                keccak256(order.data)\n            ));\n    }\n\n    function validateOrderTime(LibOrder.Order memory order) internal view {\n        require(order.start == 0 || order.start < block.timestamp, \"Order start validation failed\");\n        require(order.end == 0 || order.end > block.timestamp, \"Order end validation failed\");\n    }\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibOrderData.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"./LibOrder.sol\";\n\nlibrary LibOrderData {\n\n    struct GenericOrderData {\n        LibPart.Part[] payouts;\n        LibPart.Part[] originFees;\n        bool isMakeFill;\n    } \n\n    function parse(LibOrder.Order memory order) pure internal returns (GenericOrderData memory dataOrder) {\n        if (order.dataType == LibOrderDataV1.V1) {\n            LibOrderDataV1.DataV1 memory data = abi.decode(order.data, (LibOrderDataV1.DataV1));\n            dataOrder.payouts = data.payouts;\n            dataOrder.originFees = data.originFees;\n        } else if (order.dataType == LibOrderDataV2.V2) {\n            LibOrderDataV2.DataV2 memory data = abi.decode(order.data, (LibOrderDataV2.DataV2));\n            dataOrder.payouts = data.payouts;\n            dataOrder.originFees = data.originFees;\n            dataOrder.isMakeFill = data.isMakeFill;\n        } else if (order.dataType == 0xffffffff) {\n        } else {\n            revert(\"Unknown Order data type\");\n        }\n        if (dataOrder.payouts.length == 0) {\n            dataOrder.payouts = payoutSet(order.maker);\n        }\n    }\n\n    function payoutSet(address orderAddress) pure internal returns (LibPart.Part[] memory) {\n        LibPart.Part[] memory payout = new LibPart.Part[](1);\n        payout[0].account = payable(orderAddress);\n        payout[0].value = 10000;\n        return payout;\n    }\n\n    function parseOriginFeeData(uint dataFirst, uint dataSecond) internal pure returns(LibPart.Part[] memory) {\n        LibPart.Part[] memory originFee;\n\n        if (dataFirst > 0 && dataSecond > 0){\n            originFee = new LibPart.Part[](2);\n\n            originFee[0] = uintToLibPart(dataFirst);\n            originFee[1] = uintToLibPart(dataSecond);\n        }\n\n        if (dataFirst > 0 && dataSecond == 0) {\n            originFee = new LibPart.Part[](1);\n\n            originFee[0] = uintToLibPart(dataFirst);\n        }\n\n        if (dataFirst == 0 && dataSecond > 0) {\n            originFee = new LibPart.Part[](1);\n\n            originFee[0] = uintToLibPart(dataSecond);\n        }\n\n        return originFee;\n    }\n\n    function parsePayouts(uint data) internal pure returns(LibPart.Part[] memory) {\n        LibPart.Part[] memory payouts;\n\n        if (data > 0) {\n            payouts = new LibPart.Part[](1);\n            payouts[0] = uintToLibPart(data);\n        }\n\n        return payouts;\n    }\n\n    /**\n        @notice converts uint to LibPart.Part\n        @param data address and value encoded in uint (first 12 bytes )\n        @return result LibPart.Part \n     */\n    function uintToLibPart(uint data) internal pure returns(LibPart.Part memory result) {\n        if (data > 0){\n            result.account = payable(address(data));\n            result.value = uint96(data >> 160);\n        }\n    }\n\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibOrderDataV1.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\nlibrary LibOrderDataV1 {\n    bytes4 constant public V1 = bytes4(keccak256(\"V1\"));\n\n    struct DataV1 {\n        LibPart.Part[] payouts;\n        LibPart.Part[] originFees;\n    }\n\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibOrderDataV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\nlibrary LibOrderDataV2 {\n    bytes4 constant public V2 = bytes4(keccak256(\"V2\"));\n\n    struct DataV2 {\n        LibPart.Part[] payouts;\n        LibPart.Part[] originFees;\n        bool isMakeFill;\n    }\n\n}\n"
      },
      "@rarible/exchange-v2/contracts/libraries/LibOrderDataV3.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\n/// @dev deprecated\nlibrary LibOrderDataV3 {\n    bytes4 constant public V3_SELL = bytes4(keccak256(\"V3_SELL\"));\n    bytes4 constant public V3_BUY = bytes4(keccak256(\"V3_BUY\"));\n\n    struct DataV3_SELL {\n        uint payouts;\n        uint originFeeFirst;\n        uint originFeeSecond;\n        uint maxFeesBasePoint;\n        bytes32 marketplaceMarker;\n    }\n\n    struct DataV3_BUY {\n        uint payouts;\n        uint originFeeFirst;\n        uint originFeeSecond;\n        bytes32 marketplaceMarker;\n    }\n\n}\n"
      },
      "@rarible/exchange-wrapper/contracts/RaribleExchangeWrapper.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/transfer-manager/contracts/lib/LibTransfer.sol\";\nimport \"@rarible/lib-bp/contracts/BpLibrary.sol\";\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\nimport \"@openzeppelin/contracts/math/SafeMath.sol\";\n\nimport \"@openzeppelin/contracts/token/ERC721/ERC721Holder.sol\";\nimport \"@openzeppelin/contracts/token/ERC1155/ERC1155Holder.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol\";\n\nimport \"./interfaces/IWyvernExchange.sol\";\nimport \"./interfaces/IExchangeV2.sol\";\nimport \"./interfaces/ISeaPort.sol\";\nimport \"./interfaces/Ix2y2.sol\";\nimport \"./interfaces/ILooksRare.sol\";\nimport \"./interfaces/IBlur.sol\";\n\nimport \"./libraries/IsPausable.sol\";\n\ncontract RaribleExchangeWrapper is Ownable, ERC721Holder, ERC1155Holder, IsPausable {\n    using LibTransfer for address;\n    using BpLibrary for uint;\n    using SafeMath for uint;\n\n    //marketplaces\n    address public immutable wyvernExchange;\n    address public immutable exchangeV2;\n    address public immutable seaPort_1_1;\n    address public immutable x2y2;\n    address public immutable looksRare;\n    address public immutable sudoswap;\n    address public immutable seaPort_1_4;\n    address public immutable looksRareV2;\n    address public immutable blur;\n    address public immutable seaPort_1_5;\n    address public immutable seaPort_1_6;\n\n    //currencties\n    address public immutable weth;\n\n    //constants\n    uint256 private constant UINT256_MAX = type(uint256).max;\n\n    event Execution(bool result);\n\n    enum Markets {\n        ExchangeV2,//0\n        WyvernExchange,//1\n        SeaPort_1_1,//2\n        X2Y2,//3\n        LooksRareOrders,//4\n        SudoSwap,//5\n        SeaPort_1_4,//6\n        LooksRareV2,//7\n        Blur,//8\n        SeaPort_1_5,//9\n        SeaPort_1_6//10\n    }\n\n    enum AdditionalDataTypes {\n        NoAdditionalData,\n        RoyaltiesAdditionalData\n    }\n\n    enum Currencies {\n        ETH,\n        WETH\n    }\n\n    /**\n        @notice struct for the purchase data\n        @param marketId - market key from Markets enum (what market to use)\n        @param amount - eth price (amount of eth that needs to be send to the marketplace)\n        @param fees - 2 fees (in base points) that are going to be taken on top of order amount encoded in 1 uint256\n                        bytes (25,26) used for currency (0 - ETH, 1 - WETH erc-20)\n                        bytes (27,28) used for dataType\n                        bytes (29,30) used for the first value (goes to feeRecipientFirst)\n                        bytes (31,32) are used for the second value (goes to feeRecipientSecond)\n        @param data - data for market call\n     */\n    struct PurchaseDetails {\n        Markets marketId;\n        uint256 amount;\n        uint fees;\n        bytes data;\n    }\n\n    /**\n        @notice struct for the data with additional Ddta\n        @param data - data for market call\n        @param additionalRoyalties - array additional Royalties (in base points plus address Royalty recipient)\n     */\n    struct AdditionalData {\n        bytes data;\n        uint[] additionalRoyalties;\n    }\n\n    constructor(\n        address[11] memory marketplaces,\n        //address _wyvernExchange, 0\n        //address _exchangeV2, 1\n        //address _seaPort_1_1, 2\n        //address _x2y2, 3\n        //address _looksRare, 4\n        //address _sudoswap, 5\n        //address _seaPort_1_4, 6\n        //address _looksRareV2, 7\n        //address _blur, 8\n        //address _seaPort_1_5, 9\n        //address _seaPort_1_6, 10\n        address _weth,\n        address[] memory transferProxies\n    ) {\n        wyvernExchange = marketplaces[0];\n        exchangeV2 = marketplaces[1];\n        seaPort_1_1 = marketplaces[2];\n        x2y2 = marketplaces[3];\n        looksRare = marketplaces[4];\n        sudoswap = marketplaces[5];\n        seaPort_1_4 = marketplaces[6];\n        looksRareV2 = marketplaces[7];\n        blur = marketplaces[8];\n        seaPort_1_5 = marketplaces[9];\n        seaPort_1_6 = marketplaces[10];\n\n        weth = _weth;\n\n        for (uint i = 0; i < transferProxies.length; ++i) {\n            if (_weth != address(0)){\n                IERC20Upgradeable(_weth).approve(transferProxies[i], UINT256_MAX);\n            }\n        }\n    }\n\n    /**\n        @notice executes a single purchase\n        @param purchaseDetails - deatails about the purchase (more info in PurchaseDetails struct)\n        @param feeRecipientFirst - address of the first fee recipient\n        @param feeRecipientSecond - address of the second fee recipient\n     */\n    function singlePurchase(PurchaseDetails memory purchaseDetails, address feeRecipientFirst, address feeRecipientSecond) external payable {\n        requireNotPaused();\n        \n        //amount of WETH needed for purchases: \n        uint wethAmountNeeded = getAmountOfWethForPurchase(purchaseDetails);\n        \n        //transfer WETH to this contract (if needed)\n        if (wethAmountNeeded > 0) {\n            IERC20Upgradeable(weth).transferFrom(_msgSender(), address(this), wethAmountNeeded);\n        }\n\n        Currencies currency = getCurrency(purchaseDetails.fees);\n        bool success;\n        uint firstFeeAmount;\n        uint secondFeeAmount;\n\n        if (currency == Currencies.ETH) {\n            (success, firstFeeAmount, secondFeeAmount) = purchase(purchaseDetails, false);\n            transferFeeETH(firstFeeAmount, feeRecipientFirst);\n            transferFeeETH(secondFeeAmount, feeRecipientSecond);\n        } else if (currency == Currencies.WETH) {\n            (success, firstFeeAmount, secondFeeAmount) = purchaseWETH(purchaseDetails, false);\n            transferFeeWETH(firstFeeAmount, feeRecipientFirst);\n            transferFeeWETH(secondFeeAmount, feeRecipientSecond);\n        } else {\n            revert(\"Unknown purchase currency\");\n        }\n        \n        emit Execution(success);\n        \n        //transfer ETH change\n        transferChange();\n        //transfer WETH change\n        if (wethAmountNeeded > 0) {\n            transferChangeWETH();\n        }\n    }\n\n    /**\n        @notice executes an array of purchases\n        @param purchaseDetails - array of deatails about the purchases (more info in PurchaseDetails struct)\n        @param feeRecipientFirst - address of the first fee recipient\n        @param feeRecipientSecond - address of the second fee recipient\n        @param allowFail - true if fails while executing orders are allowed, false if fail of a single order means fail of the whole batch\n     */\n    \n    function bulkPurchase(PurchaseDetails[] memory purchaseDetails, address feeRecipientFirst, address feeRecipientSecond, bool allowFail) external payable {\n        requireNotPaused();\n\n        uint sumFirstFeesETH = 0;\n        uint sumSecondFeesETH = 0;\n        uint sumFirstFeesWETH = 0;\n        uint sumSecondFeesWETH = 0;\n        bool result = false;\n\n        //amount of WETH needed for purchases: \n        uint wethAmountNeeded = 0;\n        for (uint i = 0; i < purchaseDetails.length; ++i) {\n            wethAmountNeeded = wethAmountNeeded + getAmountOfWethForPurchase(purchaseDetails[i]);\n        }\n\n        //transfer WETH to this contract (if needed)\n        if (wethAmountNeeded > 0) {\n            IERC20Upgradeable(weth).transferFrom(_msgSender(), address(this), wethAmountNeeded);\n        }\n\n        for (uint i = 0; i < purchaseDetails.length; ++i) {\n            Currencies currency = getCurrency(purchaseDetails[i].fees);\n            bool success;\n            uint firstFeeAmount;\n            uint secondFeeAmount;\n\n            if (currency == Currencies.ETH) {\n                (success, firstFeeAmount, secondFeeAmount) = purchase(purchaseDetails[i], allowFail);\n            \n                sumFirstFeesETH = sumFirstFeesETH.add(firstFeeAmount);\n                sumSecondFeesETH = sumSecondFeesETH.add(secondFeeAmount);\n            } else if (currency == Currencies.WETH) {\n                (success, firstFeeAmount, secondFeeAmount) = purchaseWETH(purchaseDetails[i], allowFail);\n            \n                sumFirstFeesWETH = sumFirstFeesWETH.add(firstFeeAmount);\n                sumSecondFeesWETH = sumSecondFeesWETH.add(secondFeeAmount);\n            } else {\n                revert(\"Unknown purchase currency\");\n            }\n            \n            result = result || success;\n            emit Execution(success);\n        }\n\n        require(result, \"no successful executions\");\n\n        //pay fees in ETH  \n        transferFeeETH(sumFirstFeesETH, feeRecipientFirst);\n        transferFeeETH(sumSecondFeesETH, feeRecipientSecond);\n\n        //pay fees in WETH\n        transferFeeWETH(sumFirstFeesWETH, feeRecipientFirst);\n        transferFeeWETH(sumSecondFeesWETH, feeRecipientSecond);\n\n        //transfer ETH change\n        transferChange();\n        //transfer WETH change\n        if (wethAmountNeeded > 0) {\n            transferChangeWETH();\n        }\n    }\n\n    /**\n        @notice executes one purchase in ETH\n        @param purchaseDetails - details about the purchase\n        @param allowFail - true if errors are handled, false if revert on errors\n        @return result false if execution failed, true if succeded\n        @return firstFeeAmount amount of the first fee of the purchase, 0 if failed\n        @return secondFeeAmount amount of the second fee of the purchase, 0 if failed\n     */\n    function purchase(PurchaseDetails memory purchaseDetails, bool allowFail) internal returns(bool, uint, uint) {\n        (bytes memory marketData, uint[] memory additionalRoyalties) = getDataAndAdditionalData (purchaseDetails.data, purchaseDetails.fees, purchaseDetails.marketId);\n        uint paymentAmount = purchaseDetails.amount;\n        if (purchaseDetails.marketId == Markets.SeaPort_1_1){\n            (bool success,) = address(seaPort_1_1).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_1 failed\");\n            }\n        } else if (purchaseDetails.marketId == Markets.WyvernExchange) {\n            (bool success,) = address(wyvernExchange).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase wyvernExchange failed\");\n            }\n        } else if (purchaseDetails.marketId == Markets.ExchangeV2) {\n            (bool success,) = address(exchangeV2).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase rarible failed\");\n            }\n        } else if (purchaseDetails.marketId == Markets.X2Y2) {\n            Ix2y2.RunInput memory input = abi.decode(marketData, (Ix2y2.RunInput));\n\n            if (allowFail) {\n                try Ix2y2(x2y2).run{value : paymentAmount}(input) {\n                } catch {\n                    return (false, 0, 0);\n                }\n            } else {\n                Ix2y2(x2y2).run{value : paymentAmount}(input);\n            }\n\n            //for every element in input.details[] getting\n            // order = input.details[i].orderIdx\n            // and from that order getting item = input.details[i].itemId\n            for (uint i = 0; i < input.details.length; ++i) {\n                uint orderId = input.details[i].orderIdx;\n                uint itemId = input.details[i].itemIdx;\n                bytes memory data = input.orders[orderId].items[itemId].data;\n                {\n                    if (input.orders[orderId].dataMask.length > 0 && input.details[i].dataReplacement.length > 0) {\n                        _arrayReplace(data, input.details[i].dataReplacement, input.orders[orderId].dataMask);\n                    }\n                }\n\n                // 1 = erc-721\n                if (input.orders[orderId].delegateType == 1) {\n                    Ix2y2.Pair721[] memory pairs = abi.decode(data, (Ix2y2.Pair721[]));\n\n                    for (uint256 j = 0; j < pairs.length; j++) {\n                        Ix2y2.Pair721 memory p = pairs[j];\n                        IERC721Upgradeable(address(p.token)).safeTransferFrom(address(this), _msgSender(), p.tokenId);\n                    }\n                } else if (input.orders[orderId].delegateType == 2) {\n                    // 2 = erc-1155\n                    Ix2y2.Pair1155[] memory pairs = abi.decode(data, (Ix2y2.Pair1155[]));\n\n                    for (uint256 j = 0; j < pairs.length; j++) {\n                        Ix2y2.Pair1155 memory p = pairs[j];\n                        IERC1155Upgradeable(address(p.token)).safeTransferFrom(address(this),  _msgSender(), p.tokenId, p.amount, \"\");\n                    }\n                } else {\n                    revert(\"unknown delegateType x2y2\");\n                }\n            }\n        } else if (purchaseDetails.marketId == Markets.LooksRareOrders) {\n            (LibLooksRare.TakerOrder memory takerOrder, LibLooksRare.MakerOrder memory makerOrder, bytes4 typeNft) = abi.decode(marketData, (LibLooksRare.TakerOrder, LibLooksRare.MakerOrder, bytes4));\n            if (allowFail) {\n                try ILooksRare(looksRare).matchAskWithTakerBidUsingETHAndWETH{value : paymentAmount}(takerOrder, makerOrder) {\n                }   catch {\n                    return (false, 0, 0);\n                }\n            } else {\n                ILooksRare(looksRare).matchAskWithTakerBidUsingETHAndWETH{value : paymentAmount}(takerOrder, makerOrder);\n            }\n            if (typeNft == LibAsset.ERC721_ASSET_CLASS) {\n                IERC721Upgradeable(makerOrder.collection).safeTransferFrom(address(this), _msgSender(), makerOrder.tokenId);\n            } else if (typeNft == LibAsset.ERC1155_ASSET_CLASS) {\n                IERC1155Upgradeable(makerOrder.collection).safeTransferFrom(address(this), _msgSender(), makerOrder.tokenId, makerOrder.amount, \"\");\n            } else {\n                revert(\"Unknown token type\");\n            }\n        } else if (purchaseDetails.marketId == Markets.SudoSwap) {\n            (bool success,) = address(sudoswap).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase sudoswap failed\");\n            }\n        } else if (purchaseDetails.marketId == Markets.SeaPort_1_4){\n            (bool success,) = address(seaPort_1_4).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_4 failed\");\n            }\n        } else if (purchaseDetails.marketId == Markets.LooksRareV2){\n            (bool success,) = address(looksRareV2).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase LooksRareV2 failed\");\n            }\n        } else if (purchaseDetails.marketId == Markets.Blur){\n            (IBlur.Input memory sell, IBlur.Input memory buy, bytes4 typeNft) = abi.decode(marketData, (IBlur.Input, IBlur.Input, bytes4));\n            if (allowFail) {\n                try IBlur(blur).execute{value : paymentAmount}(sell, buy) {\n                }   catch {\n                    return (false, 0, 0);\n                }\n            } else {\n                IBlur(blur).execute{value : paymentAmount}(sell, buy);\n            }\n            if (typeNft == LibAsset.ERC721_ASSET_CLASS) {\n                IERC721Upgradeable(sell.order.collection).safeTransferFrom(address(this), _msgSender(), sell.order.tokenId);\n            } else if (typeNft == LibAsset.ERC1155_ASSET_CLASS) {\n                IERC1155Upgradeable(sell.order.collection).safeTransferFrom(address(this), _msgSender(), sell.order.tokenId, sell.order.amount, \"\");\n            } else {\n                revert(\"Unknown token type\");\n            }\n        } else if (purchaseDetails.marketId == Markets.SeaPort_1_5){\n            (bool success,) = address(seaPort_1_5).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_5 failed\");\n            }\n        } else if (purchaseDetails.marketId == Markets.SeaPort_1_6){\n            (bool success,) = address(seaPort_1_6).call{value : paymentAmount}(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_6 failed\");\n            }\n        } else {\n            revert(\"Unknown marketId ETH\");\n        }\n\n        //transferring royalties\n        transferAdditionalRoyaltiesETH(additionalRoyalties, purchaseDetails.amount);\n        \n        (uint firstFeeAmount, uint secondFeeAmount) = getFees(purchaseDetails.fees, purchaseDetails.amount);\n        return (true, firstFeeAmount, secondFeeAmount);\n    }\n\n    /**\n        @notice executes one purchase in WETH\n        @param purchaseDetails - details about the purchase\n        @param allowFail - true if errors are handled, false if revert on errors\n        @return result false if execution failed, true if succeded\n        @return firstFeeAmount amount of the first fee of the purchase, 0 if failed\n        @return secondFeeAmount amount of the second fee of the purchase, 0 if failed\n     */\n    function purchaseWETH(PurchaseDetails memory purchaseDetails, bool allowFail) internal returns(bool, uint, uint) {\n        (bytes memory marketData, uint[] memory additionalRoyalties) = getDataAndAdditionalData (purchaseDetails.data, purchaseDetails.fees, purchaseDetails.marketId);\n\n        //buying\n        if (purchaseDetails.marketId == Markets.SeaPort_1_1){\n            (bool success,) = address(seaPort_1_1).call(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_1 failed WETH\");\n            }\n        } else if (purchaseDetails.marketId == Markets.ExchangeV2) {\n            (bool success,) = address(exchangeV2).call(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase rarible failed WETH\");\n            }\n        } else if (purchaseDetails.marketId == Markets.SeaPort_1_4){\n            (bool success,) = address(seaPort_1_4).call(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_4 failed WETH\");\n            }\n        } else if (purchaseDetails.marketId == Markets.SeaPort_1_5){\n            (bool success,) = address(seaPort_1_5).call(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_5 failed WETH\");\n            }\n        } else if (purchaseDetails.marketId == Markets.SeaPort_1_6){\n            (bool success,) = address(seaPort_1_6).call(marketData);\n            if (allowFail) {\n                if (!success) {\n                    return (false, 0, 0);\n                }\n            } else {\n                require(success, \"Purchase SeaPort_1_6 failed WETH\");\n            }\n        } else {\n            revert(\"Unknown marketId WETH\");\n        }\n        \n        //transfer royalties\n        transferAdditionalRoyaltiesWETH(additionalRoyalties, purchaseDetails.amount);\n\n        //get fees\n        (uint firstFeeAmount, uint secondFeeAmount) = getFees(purchaseDetails.fees, purchaseDetails.amount);\n        return (true, firstFeeAmount, secondFeeAmount);\n    }\n\n    /**\n        @notice transfers ETH fee to feeRecipient\n        @param feeAmount - amount to be transfered\n        @param feeRecipient - address of the recipient\n     */\n    function transferFeeETH(uint feeAmount, address feeRecipient) internal {\n        if (feeAmount > 0 && feeRecipient != address(0)) {\n            LibTransfer.transferEth(feeRecipient, feeAmount);\n        }\n    }\n\n    /**\n        @notice transfers WETH fee to feeRecipient\n        @param feeAmount - amount to be transfered\n        @param feeRecipient - address of the recipient\n     */\n    function transferFeeWETH(uint feeAmount, address feeRecipient) internal {\n        if (feeAmount > 0 && feeRecipient != address(0)) {\n            IERC20Upgradeable(weth).transfer(feeRecipient, feeAmount);\n        }\n    }\n\n    /**\n        @notice transfers change back to sender\n     */\n    function transferChange() internal {\n        uint ethAmount = address(this).balance;\n        if (ethAmount > 0) {\n            address(msg.sender).transferEth(ethAmount);\n        }\n    }\n\n    /**\n        @notice transfers weth change back to sender\n     */\n    function transferChangeWETH() internal {\n        uint wethAmount = IERC20Upgradeable(weth).balanceOf(address(this));\n        if (wethAmount > 0) {\n            IERC20Upgradeable(weth).transfer(_msgSender(), wethAmount);\n        }\n    }\n\n    /**\n        @notice parses fees in base points from one uint and calculates real amount of fees\n        @param fees two fees encoded in one uint, 29 and 30 bytes are used for the first fee, 31 and 32 bytes for second fee\n        @param amount price of the order\n        @return firstFeeAmount real amount for the first fee\n        @return secondFeeAmount real amount for the second fee\n     */\n    function getFees(uint fees, uint amount) internal pure returns(uint, uint) {\n        uint firstFee = uint(uint16(fees >> 16));\n        uint secondFee = uint(uint16(fees));\n        return (amount.bp(firstFee), amount.bp(secondFee));\n    }\n\n    /**\n        @notice parses \"fees\" field to find the currency for the purchase\n        @param fees field with encoded data\n        @return 0 if ETH, 1 if WETH ERC-20\n     */\n    function getCurrency(uint fees) internal pure returns(Currencies) {\n        return Currencies(uint16(fees >> 48));\n    }\n\n\n    /**\n        @notice parses _data to data for market call and additionalData\n        @param feesAndDataType 27 and 28 bytes for dataType\n        @return marketData data for market call\n        @return additionalRoyalties array uint256, (base point + address)\n     */\n    function getDataAndAdditionalData (bytes memory _data, uint feesAndDataType, Markets marketId) internal pure returns (bytes memory, uint[] memory) {\n        AdditionalDataTypes dataType = AdditionalDataTypes(uint16(feesAndDataType >> 32));\n        uint[] memory additionalRoyalties;\n\n        //return no royalties if wrong data type\n        if (dataType == AdditionalDataTypes.NoAdditionalData) {\n            return (_data, additionalRoyalties);\n        }\n\n        if (dataType == AdditionalDataTypes.RoyaltiesAdditionalData) {\n            AdditionalData memory additionalData = abi.decode(_data, (AdditionalData));\n\n            //return no royalties if market doesn't support royalties\n            if (supportsRoyalties(marketId)) {\n                return (additionalData.data, additionalData.additionalRoyalties);\n            } else {\n                return (additionalData.data, additionalRoyalties);\n            } \n        }\n        \n        revert(\"unknown additionalDataType\");\n    }\n\n    /**\n        @notice transfer additional royalties in ETH\n        @param _additionalRoyalties array uint256 (base point + royalty recipient address)\n     */\n    function transferAdditionalRoyaltiesETH (uint[] memory _additionalRoyalties, uint amount) internal {\n        for (uint i = 0; i < _additionalRoyalties.length; ++i) {\n            if (_additionalRoyalties[i] > 0) {\n                address payable account = payable(address(_additionalRoyalties[i]));\n                uint basePoint = uint(_additionalRoyalties[i] >> 160);\n                uint value = amount.bp(basePoint);\n                transferFeeETH(value, account);\n            }\n        }\n    }\n\n    /**\n        @notice transfer additional royalties in WETH\n        @param _additionalRoyalties array uint256 (base point + royalty recipient address)\n     */\n    function transferAdditionalRoyaltiesWETH (uint[] memory _additionalRoyalties, uint amount) internal {\n        for (uint i = 0; i < _additionalRoyalties.length; ++i) {\n            if (_additionalRoyalties[i] > 0) {\n                address payable account = payable(address(_additionalRoyalties[i]));\n                uint basePoint = uint(_additionalRoyalties[i] >> 160);\n                uint value = amount.bp(basePoint);\n                transferFeeWETH(value, account);\n            }\n        }\n    }\n\n    // modifies `src`\n    function _arrayReplace(\n        bytes memory src,\n        bytes memory replacement,\n        bytes memory mask\n    ) internal view virtual {\n        require(src.length == replacement.length);\n        require(src.length == mask.length);\n\n        for (uint256 i = 0; i < src.length; ++i) {\n            if (mask[i] != 0) {\n                src[i] = replacement[i];\n            }\n        }\n    }\n\n    /**\n        @notice returns true if this contract supports additional royalties for the marketplace;\n        now royalties are supported for:\n          1. SudoSwap\n          2. LooksRare old\n          3. LooksRare V2\n    */\n    function supportsRoyalties(Markets marketId) internal pure returns (bool){\n        if (\n            marketId == Markets.SudoSwap ||\n            marketId == Markets.LooksRareOrders ||\n            marketId == Markets.LooksRareV2\n        ) {\n            return true;\n        }\n\n        return false;\n    }\n\n    function getAmountOfWethForPurchase(PurchaseDetails memory detail) internal pure returns (uint) {\n        uint result = 0;\n\n        Currencies currency = getCurrency(detail.fees);\n\n        //for every purchase with WETH we sum amount, fees and royalties needed\n            if (currency == Currencies.WETH) {\n\n                //add amount\n                result = result + detail.amount;\n\n                //add fees\n                (uint firstFeeAmount, uint secondFeeAmount) = getFees(detail.fees, detail.amount);\n                result = result + firstFeeAmount + secondFeeAmount;\n\n                //add royalties\n                (, uint[] memory royalties) = getDataAndAdditionalData (detail.data, detail.fees, detail.marketId);\n                for (uint j = 0; j < royalties.length; ++j) {\n                    uint royaltyBasePoint = uint(royalties[j] >> 160);\n                    uint royaltyValue = detail.amount.bp(royaltyBasePoint);\n                    result = result + royaltyValue;\n                }\n            }\n\n        return result;\n    }\n\n    /**\n        @notice approves weth for a list of the addresses\n        @param transferProxies - array of addresses to approve WETH for\n    */\n    function approveWETH(address[] calldata transferProxies) external onlyOwner {\n        for (uint i = 0; i < transferProxies.length; ++i) {\n            IERC20Upgradeable(weth).approve(transferProxies[i], UINT256_MAX);\n        }\n    }\n\n    receive() external payable {}\n}"
      },
      "@rarible/exchange-wrapper/contracts/interfaces/IBlur.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\n\ninterface IBlur {\n    enum Side { Buy, Sell }\n    enum SignatureVersion { Single, Bulk }\n    enum AssetType { ERC721, ERC1155 }\n\n    struct Fee {\n        uint16 rate;\n        address payable recipient;\n    }\n        \n    struct Order {\n        address trader;\n        Side side;\n        address matchingPolicy;\n        address collection;\n        uint256 tokenId;\n        uint256 amount;\n        address paymentToken;\n        uint256 price;\n        uint256 listingTime;\n        /* Order expiration timestamp - 0 for oracle cancellations. */\n        uint256 expirationTime;\n        Fee[] fees;\n        uint256 salt;\n        bytes extraParams;\n    }\n\n    struct Input {\n        Order order;\n        uint8 v;\n        bytes32 r;\n        bytes32 s;\n        bytes extraSignature;\n        SignatureVersion signatureVersion;\n        uint256 blockNumber;\n    }\n\n    function execute(Input calldata sell, Input calldata buy)\n        external\n        payable;\n}\n"
      },
      "@rarible/exchange-wrapper/contracts/interfaces/IExchangeV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\npragma abicoder v2;\n\nimport \"@rarible/exchange-v2/contracts/ExchangeV2.sol\";\n\nimport {RoyaltiesRegistry} from \"@rarible/royalties-registry/contracts/RoyaltiesRegistry.sol\";\nimport {TransferProxy} from \"@rarible/transfer-proxy/contracts/proxy/TransferProxy.sol\";\nimport {ERC20TransferProxy} from \"@rarible/transfer-proxy/contracts/proxy/ERC20TransferProxy.sol\";\n\ninterface IExchangeV2 {\n    function matchOrders(\n        LibOrder.Order memory orderLeft,\n        bytes memory signatureLeft,\n        LibOrder.Order memory orderRight,\n        bytes memory signatureRight\n    ) external payable;\n\n    function directPurchase(\n        LibDirectTransfer.Purchase calldata direct\n    ) external payable;\n}"
      },
      "@rarible/exchange-wrapper/contracts/interfaces/ILooksRare.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"../libraries/LibLooksRare.sol\";\n\ninterface ILooksRare {\n    function matchAskWithTakerBidUsingETHAndWETH(LibLooksRare.TakerOrder calldata takerBid, LibLooksRare.MakerOrder calldata makerAsk) external payable;\n\n    /**\n     * @notice This function allows a user to execute a taker bid (against a maker ask).\n     * @param takerBid Taker bid struct\n     * @param makerAsk Maker ask struct\n     * @param makerSignature Maker signature\n     * @param merkleTree Merkle tree struct (if the signature contains multiple maker orders)\n     * @param affiliate Affiliate address\n     */\n    function executeTakerBid(LibLooksRare.Taker calldata takerBid, LibLooksRare.Maker calldata makerAsk, bytes calldata makerSignature, LibLooksRare.MerkleTree calldata merkleTree, address affiliate) external payable;\n}\n"
      },
      "@rarible/exchange-wrapper/contracts/interfaces/ISeaPort.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\npragma abicoder v2;\n\nimport \"../libraries/LibSeaPort.sol\";\n\ninterface ISeaPort {\n    function fulfillAdvancedOrder(\n        LibSeaPort.AdvancedOrder calldata advancedOrder,\n        LibSeaPort.CriteriaResolver[] calldata criteriaResolvers,\n        bytes32 fulfillerConduitKey,\n        address recipient\n    ) external payable returns (bool fulfilled);\n\n    function fulfillAvailableAdvancedOrders(\n        LibSeaPort.AdvancedOrder[] memory advancedOrders,\n        LibSeaPort.CriteriaResolver[] calldata criteriaResolvers,\n        LibSeaPort.FulfillmentComponent[][] calldata offerFulfillments,\n        LibSeaPort.FulfillmentComponent[][] calldata considerationFulfillments,\n        bytes32 fulfillerConduitKey,\n        address recipient,\n        uint256 maximumFulfilled\n    ) external payable returns (bool[] memory availableOrders, LibSeaPort.Execution[] memory executions);\n\n    function fulfillBasicOrder(LibSeaPort.BasicOrderParameters calldata parameters)\n        external\n        payable\n        returns (bool fulfilled);\n}"
      },
      "@rarible/exchange-wrapper/contracts/interfaces/IWyvernExchange.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\npragma abicoder v2;\n\ninterface IWyvernExchange {\n    function atomicMatch_(\n        address[14] memory addrs,\n        uint[18] memory uints,\n        uint8[8] memory feeMethodsSidesKindsHowToCalls,\n        bytes memory calldataBuy,\n        bytes memory calldataSell,\n        bytes memory replacementPatternBuy,\n        bytes memory replacementPatternSell,\n        bytes memory staticExtradataBuy,\n        bytes memory staticExtradataSell,\n        uint8[2] memory vs,\n        bytes32[5] memory rssMetadata)\n    external\n    payable;\n\n    enum Side {\n        Buy,\n        Sell\n    }\n\n    enum SaleKind {\n        FixedPrice,\n        DutchAuction\n    }\n\n    function calculateFinalPrice(\n        Side side,\n        SaleKind saleKind,\n        uint256 basePrice,\n        uint256 extra,\n        uint256 listingTime,\n        uint256 expirationTime\n    ) external view returns (uint256);\n}"
      },
      "@rarible/exchange-wrapper/contracts/interfaces/Ix2y2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\npragma abicoder v2;\n\ninterface Ix2y2 {\n\n    struct OrderItem {\n        uint256 price;\n        bytes data;\n    }\n\n    struct Pair721 {\n        address token;\n        uint256 tokenId;\n    }\n\n    struct Pair1155 {\n        address token;\n        uint256 tokenId;\n        uint256 amount;\n    }\n\n    struct Order {\n        uint256 salt;\n        address user;\n        uint256 network;\n        uint256 intent;\n        uint256 delegateType;\n        uint256 deadline;\n        address currency;\n        bytes dataMask;\n        OrderItem[] items;\n        // signature\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n        uint8 signVersion;\n    }\n\n    struct Fee {\n        uint256 percentage;\n        address to;\n    }\n\n    struct SettleDetail {\n        Op op;\n        uint256 orderIdx;\n        uint256 itemIdx;\n        uint256 price;\n        bytes32 itemHash;\n        address executionDelegate;\n        bytes dataReplacement;\n        uint256 bidIncentivePct;\n        uint256 aucMinIncrementPct;\n        uint256 aucIncDurationSecs;\n        Fee[] fees;\n    }\n\n    struct SettleShared {\n        uint256 salt;\n        uint256 deadline;\n        uint256 amountToEth;\n        uint256 amountToWeth;\n        address user;\n        bool canFail;\n    }\n\n    struct RunInput {\n        Order[] orders;\n        SettleDetail[] details;\n        SettleShared shared;\n        // signature\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n    }\n\n    enum Op {\n        INVALID,\n        // off-chain\n        COMPLETE_SELL_OFFER,\n        COMPLETE_BUY_OFFER,\n        CANCEL_OFFER,\n        // auction\n        BID,\n        COMPLETE_AUCTION,\n        REFUND_AUCTION,\n        REFUND_AUCTION_STUCK_ITEM\n    }\n\n    function run(RunInput memory input) external payable;\n}"
      },
      "@rarible/exchange-wrapper/contracts/libraries/IsPausable.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\n\nabstract contract IsPausable is Ownable {\n    bool public paused;\n\n    event Paused(bool paused);\n\n    function pause(bool _paused) external onlyOwner {\n        paused = _paused;\n        emit Paused(_paused);\n    }\n\n    function requireNotPaused() internal view {\n        require (!paused, \"the contract is paused\");\n    }\n\n}\n"
      },
      "@rarible/exchange-wrapper/contracts/libraries/LibLooksRare.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nlibrary LibLooksRare {\n    struct MakerOrder {\n        bool isOrderAsk; // true --> ask / false --> bid\n        address signer; // signer of the maker order\n        address collection; // collection address\n        uint256 price; // price (used as )\n        uint256 tokenId; // id of the token\n        uint256 amount; // amount of tokens to sell/purchase (must be 1 for ERC721, 1+ for ERC1155)\n        address strategy; // strategy for trade execution (e.g., DutchAuction, StandardSaleForFixedPrice)\n        address currency; // currency (e.g., WETH)\n        uint256 nonce; // order nonce (must be unique unless new maker order is meant to override existing one e.g., lower ask price)\n        uint256 startTime; // startTime in timestamp\n        uint256 endTime; // endTime in timestamp\n        uint256 minPercentageToAsk; // slippage protection (9000 --> 90% of the final price must return to ask)\n        bytes params; // additional parameters\n        uint8 v; // v: parameter (27 or 28)\n        bytes32 r; // r: parameter\n        bytes32 s; // s: parameter\n    }\n\n    struct TakerOrder {\n        bool isOrderAsk; // true --> ask / false --> bid\n        address taker; // msg.sender\n        uint256 price; // final price for the purchase\n        uint256 tokenId;\n        uint256 minPercentageToAsk; // // slippage protection (9000 --> 90% of the final price must return to ask)\n        bytes params; // other params (e.g., tokenId)\n    }\n\n    /**\n     * @notice CollectionType is used in OrderStructs.Maker's collectionType to determine the collection type being traded.\n     */\n    enum CollectionType {\n        ERC721,\n        ERC1155\n    }\n\n    /**\n     * @notice QuoteType is used in OrderStructs.Maker's quoteType to determine whether the maker order is a bid or an ask.\n     */\n    enum QuoteType {\n        Bid,\n        Ask\n    }\n    /**\n     * 1. Maker struct\n     */\n\n    /**\n     * @notice Maker is the struct for a maker order.\n     * @param quoteType Quote type (i.e. 0 = BID, 1 = ASK)\n     * @param globalNonce Global user order nonce for maker orders\n     * @param subsetNonce Subset nonce (shared across bid/ask maker orders)\n     * @param orderNonce Order nonce (it can be shared across bid/ask maker orders)\n     * @param strategyId Strategy id\n     * @param collectionType Collection type (i.e. 0 = ERC721, 1 = ERC1155)\n     * @param collection Collection address\n     * @param currency Currency address (@dev address(0) = ETH)\n     * @param signer Signer address\n     * @param startTime Start timestamp\n     * @param endTime End timestamp\n     * @param price Minimum price for maker ask, maximum price for maker bid\n     * @param itemIds Array of itemIds\n     * @param amounts Array of amounts\n     * @param additionalParameters Extra data specific for the order\n     */\n    struct Maker {\n        QuoteType quoteType;\n        uint256 globalNonce;\n        uint256 subsetNonce;\n        uint256 orderNonce;\n        uint256 strategyId;\n        CollectionType collectionType;\n        address collection;\n        address currency;\n        address signer;\n        uint256 startTime;\n        uint256 endTime;\n        uint256 price;\n        uint256[] itemIds;\n        uint256[] amounts;\n        bytes additionalParameters;\n    }\n\n    /**\n     * 2. Taker struct\n     */\n\n    /**\n     * @notice Taker is the struct for a taker ask/bid order. It contains the parameters required for a direct purchase.\n     * @dev Taker struct is matched against MakerAsk/MakerBid structs at the protocol level.\n     * @param recipient Recipient address (to receive NFTs or non-fungible tokens)\n     * @param additionalParameters Extra data specific for the order\n     */\n    struct Taker {\n        address recipient;\n        bytes additionalParameters;\n    }\n\n    /**\n     * 3. Merkle tree struct\n     */\n\n    enum MerkleTreeNodePosition {\n        Left,\n        Right\n    }\n\n    /**\n     * @notice MerkleTreeNode is a MerkleTree's node.\n     * @param value It can be an order hash or a proof\n     * @param position The node's position in its branch.\n     *                 It can be left or right or none\n     *                 (before the tree is sorted).\n     */\n    struct MerkleTreeNode {\n        bytes32 value;\n        MerkleTreeNodePosition position;\n    }\n\n    /**\n     * @notice MerkleTree is the struct for a merkle tree of order hashes.\n     * @dev A Merkle tree can be computed with order hashes.\n     *      It can contain order hashes from both maker bid and maker ask structs.\n     * @param root Merkle root\n     * @param proof Array containing the merkle proof\n     */\n    struct MerkleTree {\n        bytes32 root;\n        MerkleTreeNode[] proof;\n    }\n}\n"
      },
      "@rarible/exchange-wrapper/contracts/libraries/LibSeaPort.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nlibrary LibSeaPort {\n    /**\n      * @dev For basic orders involving ETH / native / ERC20 <=> ERC721 / ERC1155\n      *      matching, a group of six functions may be called that only requires a\n      *      subset of the usual order arguments. Note the use of a \"basicOrderType\"\n      *      enum; this represents both the usual order type as well as the \"route\"\n      *      of the basic order (a simple derivation function for the basic order\n      *      type is `basicOrderType = orderType + (4 * basicOrderRoute)`.)\n      */\n    struct BasicOrderParameters {\n        address considerationToken; // 0x24\n        uint256 considerationIdentifier; // 0x44\n        uint256 considerationAmount; // 0x64\n        address payable offerer; // 0x84\n        address zone; // 0xa4\n        address offerToken; // 0xc4\n        uint256 offerIdentifier; // 0xe4\n        uint256 offerAmount; // 0x104\n        BasicOrderType basicOrderType; // 0x124\n        uint256 startTime; // 0x144\n        uint256 endTime; // 0x164\n        bytes32 zoneHash; // 0x184\n        uint256 salt; // 0x1a4\n        bytes32 offererConduitKey; // 0x1c4\n        bytes32 fulfillerConduitKey; // 0x1e4\n        uint256 totalOriginalAdditionalRecipients; // 0x204\n        AdditionalRecipient[] additionalRecipients; // 0x224\n        bytes signature; // 0x244\n    }\n    /**\n     * @dev Basic orders can supply any number of additional recipients, with the\n     *      implied assumption that they are supplied from the offered ETH (or other\n     *      native token) or ERC20 token for the order.\n     */\n    struct AdditionalRecipient {\n        uint256 amount;\n        address payable recipient;\n    }\n\n    // prettier-ignore\n    enum BasicOrderType {\n        // 0: no partial fills, anyone can execute\n        ETH_TO_ERC721_FULL_OPEN,\n\n        // 1: partial fills supported, anyone can execute\n        ETH_TO_ERC721_PARTIAL_OPEN,\n\n        // 2: no partial fills, only offerer or zone can execute\n        ETH_TO_ERC721_FULL_RESTRICTED,\n\n        // 3: partial fills supported, only offerer or zone can execute\n        ETH_TO_ERC721_PARTIAL_RESTRICTED,\n\n        // 4: no partial fills, anyone can execute\n        ETH_TO_ERC1155_FULL_OPEN,\n\n        // 5: partial fills supported, anyone can execute\n        ETH_TO_ERC1155_PARTIAL_OPEN,\n\n        // 6: no partial fills, only offerer or zone can execute\n        ETH_TO_ERC1155_FULL_RESTRICTED,\n\n        // 7: partial fills supported, only offerer or zone can execute\n        ETH_TO_ERC1155_PARTIAL_RESTRICTED,\n\n        // 8: no partial fills, anyone can execute\n        ERC20_TO_ERC721_FULL_OPEN,\n\n        // 9: partial fills supported, anyone can execute\n        ERC20_TO_ERC721_PARTIAL_OPEN,\n\n        // 10: no partial fills, only offerer or zone can execute\n        ERC20_TO_ERC721_FULL_RESTRICTED,\n\n        // 11: partial fills supported, only offerer or zone can execute\n        ERC20_TO_ERC721_PARTIAL_RESTRICTED,\n\n        // 12: no partial fills, anyone can execute\n        ERC20_TO_ERC1155_FULL_OPEN,\n\n        // 13: partial fills supported, anyone can execute\n        ERC20_TO_ERC1155_PARTIAL_OPEN,\n\n        // 14: no partial fills, only offerer or zone can execute\n        ERC20_TO_ERC1155_FULL_RESTRICTED,\n\n        // 15: partial fills supported, only offerer or zone can execute\n        ERC20_TO_ERC1155_PARTIAL_RESTRICTED,\n\n        // 16: no partial fills, anyone can execute\n        ERC721_TO_ERC20_FULL_OPEN,\n\n        // 17: partial fills supported, anyone can execute\n        ERC721_TO_ERC20_PARTIAL_OPEN,\n\n        // 18: no partial fills, only offerer or zone can execute\n        ERC721_TO_ERC20_FULL_RESTRICTED,\n\n        // 19: partial fills supported, only offerer or zone can execute\n        ERC721_TO_ERC20_PARTIAL_RESTRICTED,\n\n        // 20: no partial fills, anyone can execute\n        ERC1155_TO_ERC20_FULL_OPEN,\n\n        // 21: partial fills supported, anyone can execute\n        ERC1155_TO_ERC20_PARTIAL_OPEN,\n\n        // 22: no partial fills, only offerer or zone can execute\n        ERC1155_TO_ERC20_FULL_RESTRICTED,\n\n        // 23: partial fills supported, only offerer or zone can execute\n        ERC1155_TO_ERC20_PARTIAL_RESTRICTED\n    }\n\n     /**\n     * @dev The full set of order components, with the exception of the counter,\n     *      must be supplied when fulfilling more sophisticated orders or groups of\n     *      orders. The total number of original consideration items must also be\n     *      supplied, as the caller may specify additional consideration items.\n     */\n    struct OrderParameters {\n        address offerer; // 0x00\n        address zone; // 0x20\n        OfferItem[] offer; // 0x40\n        ConsiderationItem[] consideration; // 0x60\n        OrderType orderType; // 0x80\n        uint256 startTime; // 0xa0\n        uint256 endTime; // 0xc0\n        bytes32 zoneHash; // 0xe0\n        uint256 salt; // 0x100\n        bytes32 conduitKey; // 0x120\n        uint256 totalOriginalConsiderationItems; // 0x140\n        // offer.length                          // 0x160\n    }\n\n    /**\n     * @dev Orders require a signature in addition to the other order parameters.\n     */\n    struct Order {\n        OrderParameters parameters;\n        bytes signature;\n    }\n\n    struct AdvancedOrder {\n        OrderParameters parameters;\n        uint120 numerator;\n        uint120 denominator;\n        bytes signature;\n        bytes extraData;\n    }\n\n    struct OfferItem {\n        ItemType itemType;\n        address token;\n        uint256 identifierOrCriteria;\n        uint256 startAmount;\n        uint256 endAmount;\n    }\n\n    /**\n     * @dev A consideration item has the same five components as an offer item and\n     *      an additional sixth component designating the required recipient of the\n     *      item.\n     */\n    struct ConsiderationItem {\n        ItemType itemType;\n        address token;\n        uint256 identifierOrCriteria;\n        uint256 startAmount;\n        uint256 endAmount;\n        address payable recipient;\n    }\n\n    // prettier-ignore\n    enum OrderType {\n        // 0: no partial fills, anyone can execute\n        FULL_OPEN,\n\n        // 1: partial fills supported, anyone can execute\n        PARTIAL_OPEN,\n\n        // 2: no partial fills, only offerer or zone can execute\n        FULL_RESTRICTED,\n\n        // 3: partial fills supported, only offerer or zone can execute\n        PARTIAL_RESTRICTED\n    }\n\n    // prettier-ignore\n    enum ItemType {\n        // 0: ETH on mainnet, MATIC on polygon, etc.\n        NATIVE,\n\n        // 1: ERC20 items (ERC777 and ERC20 analogues could also technically work)\n        ERC20,\n\n        // 2: ERC721 items\n        ERC721,\n\n        // 3: ERC1155 items\n        ERC1155,\n\n        // 4: ERC721 items where a number of tokenIds are supported\n        ERC721_WITH_CRITERIA,\n\n        // 5: ERC1155 items where a number of ids are supported\n        ERC1155_WITH_CRITERIA\n    }\n\n    /**\n     * @dev A fulfillment is applied to a group of orders. It decrements a series of\n     *      offer and consideration items, then generates a single execution\n     *      element. A given fulfillment can be applied to as many offer and\n     *      consideration items as desired, but must contain at least one offer and\n     *      at least one consideration that match. The fulfillment must also remain\n     *      consistent on all key parameters across all offer items (same offerer,\n     *      token, type, tokenId, and conduit preference) as well as across all\n     *      consideration items (token, type, tokenId, and recipient).\n     */\n    struct Fulfillment {\n        FulfillmentComponent[] offerComponents;\n        FulfillmentComponent[] considerationComponents;\n    }\n\n    /**\n     * @dev Each fulfillment component contains one index referencing a specific\n     *      order and another referencing a specific offer or consideration item.\n     */\n    struct FulfillmentComponent {\n        uint256 orderIndex;\n        uint256 itemIndex;\n    }\n\n    /**\n     * @dev An execution is triggered once all consideration items have been zeroed\n     *      out. It sends the item in question from the offerer to the item's\n     *      recipient, optionally sourcing approvals from either this contract\n     *      directly or from the offerer's chosen conduit if one is specified. An\n     *      execution is not provided as an argument, but rather is derived via\n     *      orders, criteria resolvers, and fulfillments (where the total number of\n     *      executions will be less than or equal to the total number of indicated\n     *      fulfillments) and returned as part of `matchOrders`.\n     */\n    struct Execution {\n        ReceivedItem item;\n        address offerer;\n        bytes32 conduitKey;\n    }\n\n    /**\n * @dev A received item is translated from a utilized consideration item and has\n *      the same four components as a spent item, as well as an additional fifth\n *      component designating the required recipient of the item.\n */\n    struct ReceivedItem {\n        ItemType itemType;\n        address token;\n        uint256 identifier;\n        uint256 amount;\n        address payable recipient;\n    }\n\n    struct CriteriaResolver {\n        uint256 orderIndex;\n        Side side;\n        uint256 index;\n        uint256 identifier;\n        bytes32[] criteriaProof;\n    }\n\n    // prettier-ignore\n    enum Side {\n        // 0: Items that can be spent\n        OFFER,\n\n        // 1: Items that must be received\n        CONSIDERATION\n    }\n}\n"
      },
      "@rarible/lazy-mint/contracts/erc-1155/LibERC1155LazyMint.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\nlibrary LibERC1155LazyMint {\n    bytes4 constant public ERC1155_LAZY_ASSET_CLASS = bytes4(keccak256(\"ERC1155_LAZY\"));\n    bytes4 constant _INTERFACE_ID_MINT_AND_TRANSFER = 0x6db15a0f;\n\n    struct Mint1155Data {\n        uint tokenId;\n        string tokenURI;\n        uint supply;\n        LibPart.Part[] creators;\n        LibPart.Part[] royalties;\n        bytes[] signatures;\n    }\n\n    bytes32 public constant MINT_AND_TRANSFER_TYPEHASH = keccak256(\"Mint1155(uint256 tokenId,uint256 supply,string tokenURI,Part[] creators,Part[] royalties)Part(address account,uint96 value)\");\n\n    function hash(Mint1155Data memory data) internal pure returns (bytes32) {\n        bytes32[] memory royaltiesBytes = new bytes32[](data.royalties.length);\n        for (uint i = 0; i < data.royalties.length; ++i) {\n            royaltiesBytes[i] = LibPart.hash(data.royalties[i]);\n        }\n        bytes32[] memory creatorsBytes = new bytes32[](data.creators.length);\n        for (uint i = 0; i < data.creators.length; ++i) {\n            creatorsBytes[i] = LibPart.hash(data.creators[i]);\n        }\n        return keccak256(abi.encode(\n                MINT_AND_TRANSFER_TYPEHASH,\n                data.tokenId,\n                data.supply,\n                keccak256(bytes(data.tokenURI)),\n                keccak256(abi.encodePacked(creatorsBytes)),\n                keccak256(abi.encodePacked(royaltiesBytes))\n            ));\n    }\n}\n"
      },
      "@rarible/lazy-mint/contracts/erc-721/LibERC721LazyMint.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\nlibrary LibERC721LazyMint {\n    bytes4 constant public ERC721_LAZY_ASSET_CLASS = bytes4(keccak256(\"ERC721_LAZY\"));\n    bytes4 constant _INTERFACE_ID_MINT_AND_TRANSFER = 0x8486f69f;\n\n    struct Mint721Data {\n        uint tokenId;\n        string tokenURI;\n        LibPart.Part[] creators;\n        LibPart.Part[] royalties;\n        bytes[] signatures;\n    }\n\n    bytes32 public constant MINT_AND_TRANSFER_TYPEHASH = keccak256(\"Mint721(uint256 tokenId,string tokenURI,Part[] creators,Part[] royalties)Part(address account,uint96 value)\");\n\n    function hash(Mint721Data memory data) internal pure returns (bytes32) {\n        bytes32[] memory royaltiesBytes = new bytes32[](data.royalties.length);\n        for (uint i = 0; i < data.royalties.length; ++i) {\n            royaltiesBytes[i] = LibPart.hash(data.royalties[i]);\n        }\n        bytes32[] memory creatorsBytes = new bytes32[](data.creators.length);\n        for (uint i = 0; i < data.creators.length; ++i) {\n            creatorsBytes[i] = LibPart.hash(data.creators[i]);\n        }\n        return keccak256(abi.encode(\n                MINT_AND_TRANSFER_TYPEHASH,\n                data.tokenId,\n                keccak256(bytes(data.tokenURI)),\n                keccak256(abi.encodePacked(creatorsBytes)),\n                keccak256(abi.encodePacked(royaltiesBytes))\n            ));\n    }\n\n}\n"
      },
      "@rarible/lib-asset/contracts/LibAsset.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nlibrary LibAsset {\n    bytes4 constant public ETH_ASSET_CLASS = bytes4(keccak256(\"ETH\"));\n    bytes4 constant public ERC20_ASSET_CLASS = bytes4(keccak256(\"ERC20\"));\n    bytes4 constant public ERC721_ASSET_CLASS = bytes4(keccak256(\"ERC721\"));\n    bytes4 constant public ERC1155_ASSET_CLASS = bytes4(keccak256(\"ERC1155\"));\n    bytes4 constant public COLLECTION = bytes4(keccak256(\"COLLECTION\"));\n    bytes4 constant public CRYPTO_PUNKS = bytes4(keccak256(\"CRYPTO_PUNKS\"));\n\n    bytes32 constant ASSET_TYPE_TYPEHASH = keccak256(\n        \"AssetType(bytes4 assetClass,bytes data)\"\n    );\n\n    bytes32 constant ASSET_TYPEHASH = keccak256(\n        \"Asset(AssetType assetType,uint256 value)AssetType(bytes4 assetClass,bytes data)\"\n    );\n\n    struct AssetType {\n        bytes4 assetClass;\n        bytes data;\n    }\n\n    struct Asset {\n        AssetType assetType;\n        uint value;\n    }\n\n    function hash(AssetType memory assetType) internal pure returns (bytes32) {\n        return keccak256(abi.encode(\n                ASSET_TYPE_TYPEHASH,\n                assetType.assetClass,\n                keccak256(assetType.data)\n            ));\n    }\n\n    function hash(Asset memory asset) internal pure returns (bytes32) {\n        return keccak256(abi.encode(\n                ASSET_TYPEHASH,\n                hash(asset.assetType),\n                asset.value\n            ));\n    }\n\n}\n"
      },
      "@rarible/lib-bp/contracts/BpLibrary.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\";\n\nlibrary BpLibrary {\n    using SafeMathUpgradeable for uint;\n\n    function bp(uint value, uint bpValue) internal pure returns (uint) {\n        return value.mul(bpValue).div(10000);\n    }\n}\n"
      },
      "@rarible/lib-part/contracts/LibPart.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nlibrary LibPart {\n    bytes32 public constant TYPE_HASH = keccak256(\"Part(address account,uint96 value)\");\n\n    struct Part {\n        address payable account;\n        uint96 value;\n    }\n\n    function hash(Part memory part) internal pure returns (bytes32) {\n        return keccak256(abi.encode(TYPE_HASH, part.account, part.value));\n    }\n}\n"
      },
      "@rarible/lib-signature/contracts/IERC1271.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\ninterface IERC1271 {\n\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param _hash Hash of the data signed on the behalf of address(this)\n     * @param _signature Signature byte array associated with _data\n     *\n     * MUST return the bytes4 magic value 0x1626ba7e when function passes.\n     * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n     * MUST allow external calls\n     */\n    function isValidSignature(bytes32 _hash, bytes calldata _signature) virtual external view returns (bytes4 magicValue);\n}"
      },
      "@rarible/lib-signature/contracts/LibSignature.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.7.0;\n\nlibrary LibSignature {\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)\n        internal\n        pure\n        returns (address)\n    {\n        // Check the signature length\n        if (signature.length != 65) {\n            revert(\"ECDSA: invalid signature length\");\n        }\n\n        // Divide the signature in r, s and v variables\n        bytes32 r;\n        bytes32 s;\n        uint8 v;\n\n        // ecrecover takes the signature parameters, and the only way to get them\n        // currently is to use assembly.\n        // solhint-disable-next-line no-inline-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\n        return recover(hash, v, r, s);\n    }\n\n    /**\n     * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`,\n     * `r` and `s` signature fields separately.\n     */\n    function recover(\n        bytes32 hash,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal pure returns (address) {\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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): 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        require(\n            uint256(s) <=\n                0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0,\n            \"ECDSA: invalid signature 's' value\"\n        );\n\n        // If the signature is valid (and not malleable), return the signer address\n        // v > 30 is a special case, we need to adjust hash with \"\\x19Ethereum Signed Message:\\n32\"\n        // and v = v - 4\n        address signer;\n        if (v > 30) {\n            require(\n                v - 4 == 27 || v - 4 == 28,\n                \"ECDSA: invalid signature 'v' value\"\n            );\n            signer = ecrecover(toEthSignedMessageHash(hash), v - 4, r, s);\n        } else {\n            require(v == 27 || v == 28, \"ECDSA: invalid signature 'v' value\");\n            signer = ecrecover(hash, v, r, s);\n        }\n\n        require(signer != address(0), \"ECDSA: invalid signature\");\n\n        return signer;\n    }\n\n    /**\n     * @dev Returns an Ethereum Signed Message, created from a `hash`. This\n     * replicates the behavior of the\n     * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]\n     * JSON-RPC method.\n     *\n     * See {recover}.\n     */\n    function toEthSignedMessageHash(bytes32 hash)\n        internal\n        pure\n        returns (bytes32)\n    {\n        // 32 is the length in bytes of hash,\n        // enforced by the type signature above\n        return\n            keccak256(\n                abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", hash)\n            );\n    }\n}\n"
      },
      "@rarible/role-operator/contracts/OperatorRole.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract OperatorRole is OwnableUpgradeable {\n    mapping (address => bool) operators;\n\n    function __OperatorRole_init() external initializer {\n        __Context_init_unchained();\n        __Ownable_init_unchained();\n    }\n\n    function addOperator(address operator) external onlyOwner {\n        operators[operator] = true;\n    }\n\n    function removeOperator(address operator) external onlyOwner {\n        operators[operator] = false;\n    }\n\n    modifier onlyOperator() {\n        require(operators[_msgSender()], \"OperatorRole: caller is not the operator\");\n        _;\n    }\n}\n"
      },
      "@rarible/royalties-registry/contracts/RoyaltiesRegistry.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\npragma abicoder v2;\n\nimport \"@rarible/exchange-interfaces/contracts/IRoyaltiesProvider.sol\";\nimport \"@rarible/royalties/contracts/LibRoyaltiesV2.sol\";\nimport \"@rarible/royalties/contracts/LibRoyaltiesV1.sol\";\nimport \"@rarible/royalties/contracts/LibRoyalties2981.sol\";\nimport \"@rarible/royalties/contracts/RoyaltiesV1.sol\";\nimport \"@rarible/royalties/contracts/RoyaltiesV2.sol\";\nimport \"@rarible/royalties/contracts/IERC2981.sol\";\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\ncontract RoyaltiesRegistry is IRoyaltiesProvider, OwnableUpgradeable {\n    /// @dev deprecated\n    event RoyaltiesSetForToken(address indexed token, uint indexed tokenId, LibPart.Part[] royalties);\n    /// @dev emitted when royalties set for token in \n    event RoyaltiesSetForContract(address indexed token, LibPart.Part[] royalties);\n\n    /// @dev struct to store royalties in royaltiesByToken\n    struct RoyaltiesSet {\n        bool initialized;\n        LibPart.Part[] royalties;\n    }\n\n    /// @dev deprecated\n    mapping(bytes32 => RoyaltiesSet) public royaltiesByTokenAndTokenId;\n    /// @dev stores royalties for token contract, set in setRoyaltiesByToken() method\n    mapping(address => RoyaltiesSet) public royaltiesByToken;\n    /// @dev stores external provider and royalties type for token contract\n    mapping(address => uint) public royaltiesProviders;\n\n    /// @dev total amount or supported royalties types\n    // 0 - royalties type is unset\n    // 1 - royaltiesByToken, 2 - v2, 3 - v1,\n    // 4 - external provider, 5 - EIP-2981\n    // 6 - unsupported/nonexistent royalties type\n    uint constant royaltiesTypesAmount = 6;\n\n    function __RoyaltiesRegistry_init() external initializer {\n        __Ownable_init_unchained();\n    }\n\n    /// @dev sets external provider for token contract, and royalties type = 4\n    function setProviderByToken(address token, address provider) external {\n        checkOwner(token);\n        setRoyaltiesType(token, 4, provider);\n    }\n\n    /// @dev returns provider address for token contract from royaltiesProviders mapping\n    function getProvider(address token) public view returns(address) {\n        return address(royaltiesProviders[token]);\n    }\n\n    /// @dev returns royalties type for token contract\n    function getRoyaltiesType(address token) external view returns(uint) {\n        return _getRoyaltiesType(royaltiesProviders[token]);\n    }\n\n    /// @dev returns royalties type from uint\n    function _getRoyaltiesType(uint data) internal pure returns(uint) {\n        for (uint i = 1; i <= royaltiesTypesAmount; ++i) {\n            if (data / 2**(256-i) == 1) {\n                return i;\n            }\n        }\n        return 0;\n    }\n\n    /// @dev sets royalties type for token contract\n    function setRoyaltiesType(address token, uint royaltiesType, address royaltiesProvider) internal {\n        require(royaltiesType > 0 && royaltiesType <= royaltiesTypesAmount, \"wrong royaltiesType\");\n        royaltiesProviders[token] = uint(royaltiesProvider) + 2**(256 - royaltiesType);\n    }\n\n    /// @dev clears and sets new royalties type for token contract\n    function forceSetRoyaltiesType(address token, uint royaltiesType) external {\n        checkOwner(token);\n        setRoyaltiesType(token, royaltiesType, getProvider(token));\n    }\n\n    /// @dev clears royalties type for token contract\n    function clearRoyaltiesType(address token) external {\n        checkOwner(token);\n        royaltiesProviders[token] = uint(getProvider(token));\n    }\n\n    /// @dev sets royalties for token contract in royaltiesByToken mapping and royalties type = 1\n    function setRoyaltiesByToken(address token, LibPart.Part[] memory royalties) external {\n        checkOwner(token);\n        //clearing royaltiesProviders value for the token\n        delete royaltiesProviders[token];\n        // setting royaltiesType = 1 for the token\n        setRoyaltiesType(token, 1, address(0));\n        uint sumRoyalties = 0;\n        delete royaltiesByToken[token];\n        for (uint i = 0; i < royalties.length; ++i) {\n            require(royalties[i].account != address(0x0), \"RoyaltiesByToken recipient should be present\");\n            require(royalties[i].value != 0, \"Royalty value for RoyaltiesByToken should be > 0\");\n            royaltiesByToken[token].royalties.push(royalties[i]);\n            sumRoyalties += royalties[i].value;\n        }\n        require(sumRoyalties < 10000, \"Set by token royalties sum more, than 100%\");\n        royaltiesByToken[token].initialized = true;\n        emit RoyaltiesSetForContract(token, royalties);\n    }\n\n    /// @dev checks if msg.sender is owner of this contract or owner of the token contract\n    function checkOwner(address token) internal view {\n        if ((owner() != _msgSender()) && (OwnableUpgradeable(token).owner() != _msgSender())) {\n            revert(\"Token owner not detected\");\n        }\n    }\n\n    /// @dev calculates royalties type for token contract\n    function calculateRoyaltiesType(address token, address royaltiesProvider ) internal view returns(uint) {   \n        try IERC165Upgradeable(token).supportsInterface(LibRoyaltiesV2._INTERFACE_ID_ROYALTIES) returns(bool result) {\n            if (result) {\n                return 2;\n            }\n        } catch { }\n\n        try IERC165Upgradeable(token).supportsInterface(LibRoyaltiesV1._INTERFACE_ID_FEES) returns(bool result) {\n            if (result) {\n                return 3;\n            }\n        } catch { }\n        \n        try IERC165Upgradeable(token).supportsInterface(LibRoyalties2981._INTERFACE_ID_ROYALTIES) returns(bool result) {\n            if (result) {\n                return 5;\n            }\n        } catch { }\n        \n        if (royaltiesProvider != address(0)) {\n            return 4;\n        }\n\n        if (royaltiesByToken[token].initialized) {\n            return 1;\n        }\n\n        return 6;\n    }\n\n    /// @dev returns royalties for token contract and token id\n    function getRoyalties(address token, uint tokenId) override external returns (LibPart.Part[] memory) {\n        uint royaltiesProviderData = royaltiesProviders[token];\n\n        address royaltiesProvider = address(royaltiesProviderData);\n        uint royaltiesType = _getRoyaltiesType(royaltiesProviderData);\n\n        // case when royaltiesType is not set\n        if (royaltiesType == 0) {\n            // calculating royalties type for token\n            royaltiesType = calculateRoyaltiesType(token, royaltiesProvider);\n            \n            //saving royalties type\n            setRoyaltiesType(token, royaltiesType, royaltiesProvider);\n        }\n\n        //case royaltiesType = 1, royalties are set in royaltiesByToken\n        if (royaltiesType == 1) {\n            return royaltiesByToken[token].royalties;\n        }\n\n        //case royaltiesType = 2, royalties rarible v2\n        if (royaltiesType == 2) {\n            return getRoyaltiesRaribleV2(token,tokenId);\n        }\n\n        //case royaltiesType = 3, royalties rarible v1\n        if (royaltiesType == 3) {\n            return getRoyaltiesRaribleV1(token, tokenId);\n        }\n\n        //case royaltiesType = 4, royalties from external provider\n        if (royaltiesType == 4) {\n            return providerExtractor(token, tokenId, royaltiesProvider);\n        }\n\n        //case royaltiesType = 5, royalties EIP-2981\n        if (royaltiesType == 5) {\n            return getRoyaltiesEIP2981(token, tokenId);\n        }\n\n        // case royaltiesType = 6, unknown/empty royalties\n        if (royaltiesType == 6) {\n            return new LibPart.Part[](0);\n        } \n\n        revert(\"something wrong in getRoyalties\");\n    }\n\n    /// @dev tries to get royalties rarible-v2 for token and tokenId\n    function getRoyaltiesRaribleV2(address token, uint tokenId) internal view returns (LibPart.Part[] memory) {\n        try RoyaltiesV2(token).getRaribleV2Royalties(tokenId) returns (LibPart.Part[] memory result) {\n            return result;\n        } catch {\n            return new LibPart.Part[](0);\n        }\n    }\n\n    /// @dev tries to get royalties rarible-v1 for token and tokenId\n    function getRoyaltiesRaribleV1(address token, uint tokenId) internal view returns (LibPart.Part[] memory) {\n        RoyaltiesV1 v1 = RoyaltiesV1(token);\n        address payable[] memory recipients;\n        try v1.getFeeRecipients(tokenId) returns (address payable[] memory resultRecipients) {\n            recipients = resultRecipients;\n        } catch {\n            return new LibPart.Part[](0);\n        }\n        uint[] memory values;\n        try v1.getFeeBps(tokenId) returns (uint[] memory resultValues) {\n            values = resultValues;\n        } catch {\n            return new LibPart.Part[](0);\n        }\n        if (values.length != recipients.length) {\n            return new LibPart.Part[](0);\n        }\n        LibPart.Part[] memory result = new LibPart.Part[](values.length);\n        for (uint256 i = 0; i < values.length; ++i) {\n            result[i].value = uint96(values[i]);\n            result[i].account = recipients[i];\n        }\n        return result;\n    }\n\n    /// @dev tries to get royalties EIP-2981 for token and tokenId\n    function getRoyaltiesEIP2981(address token, uint tokenId) internal view returns (LibPart.Part[] memory) {\n        try IERC2981(token).royaltyInfo(tokenId, LibRoyalties2981._WEIGHT_VALUE) returns (address receiver, uint256 royaltyAmount) {\n            return LibRoyalties2981.calculateRoyalties(receiver, royaltyAmount);\n        } catch {\n            return new LibPart.Part[](0);\n        }\n    }\n\n    /// @dev tries to get royalties for token and tokenId from external provider set in royaltiesProviders\n    function providerExtractor(address token, uint tokenId, address providerAddress) internal returns (LibPart.Part[] memory) {\n        try IRoyaltiesProvider(providerAddress).getRoyalties(token, tokenId) returns (LibPart.Part[] memory result) {\n            return result;\n        } catch {\n            return new LibPart.Part[](0);\n        }\n    }\n\n    uint256[46] private __gap;\n}\n"
      },
      "@rarible/royalties/contracts/IERC2981.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n///\n/// @dev Interface for the NFT Royalty Standard\n///\n//interface IERC2981 is IERC165 {\ninterface IERC2981 {\n    /// ERC165 bytes to add to interface array - set in parent contract\n    /// implementing this standard\n    ///\n    /// bytes4(keccak256(\"royaltyInfo(uint256,uint256)\")) == 0x2a55205a\n    /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;\n    /// _registerInterface(_INTERFACE_ID_ERC2981);\n\n    /// @notice Called with the sale price to determine how much royalty\n    //          is owed and to whom.\n    /// @param _tokenId - the NFT asset queried for royalty information\n    /// @param _salePrice - the sale price of the NFT asset specified by _tokenId\n    /// @return receiver - address of who should be sent the royalty payment\n    /// @return royaltyAmount - the royalty payment amount for _salePrice\n    function royaltyInfo(\n        uint256 _tokenId,\n        uint256 _salePrice\n    ) external view returns (\n        address receiver,\n        uint256 royaltyAmount\n    );\n}"
      },
      "@rarible/royalties/contracts/LibRoyalties2981.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\nlibrary LibRoyalties2981 {\n    /*\n     * https://eips.ethereum.org/EIPS/eip-2981: bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a;\n     */\n    bytes4 constant _INTERFACE_ID_ROYALTIES = 0x2a55205a;\n    uint96 constant _WEIGHT_VALUE = 1000000;\n\n    /*Method for converting amount to percent and forming LibPart*/\n    function calculateRoyalties(address to, uint256 amount) internal view returns (LibPart.Part[] memory) {\n        LibPart.Part[] memory result;\n        if (amount == 0) {\n            return result;\n        }\n        uint256 percent = amount * 10000 / _WEIGHT_VALUE;\n        require(percent < 10000, \"Royalties 2981 exceeds 100%\");\n        result = new LibPart.Part[](1);\n        result[0].account = payable(to);\n        result[0].value = uint96(percent);\n        return result;\n    }\n}\n"
      },
      "@rarible/royalties/contracts/LibRoyaltiesV1.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nlibrary LibRoyaltiesV1 {\n    /*\n     * bytes4(keccak256('getFeeBps(uint256)')) == 0x0ebd4c7f\n     * bytes4(keccak256('getFeeRecipients(uint256)')) == 0xb9c4d9fb\n     *\n     * => 0x0ebd4c7f ^ 0xb9c4d9fb == 0xb7799584\n     */\n    bytes4 constant _INTERFACE_ID_FEES = 0xb7799584;\n}\n"
      },
      "@rarible/royalties/contracts/LibRoyaltiesV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nlibrary LibRoyaltiesV2 {\n    /*\n     * bytes4(keccak256('getRaribleV2Royalties(uint256)')) == 0xcad96cca\n     */\n    bytes4 constant _INTERFACE_ID_ROYALTIES = 0xcad96cca;\n}\n"
      },
      "@rarible/royalties/contracts/RoyaltiesV1.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\ninterface RoyaltiesV1 {\n    event SecondarySaleFees(uint256 tokenId, address[] recipients, uint[] bps);\n\n    function getFeeRecipients(uint256 id) external view returns (address payable[] memory);\n    function getFeeBps(uint256 id) external view returns (uint[] memory);\n}\n"
      },
      "@rarible/royalties/contracts/RoyaltiesV2.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\npragma abicoder v2;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\n\ninterface RoyaltiesV2 {\n    event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties);\n\n    function getRaribleV2Royalties(uint256 id) external view returns (LibPart.Part[] memory);\n}\n"
      },
      "@rarible/transfer-manager/contracts/RaribleTransferManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"@rarible/lazy-mint/contracts/erc-721/LibERC721LazyMint.sol\";\nimport \"@rarible/lazy-mint/contracts/erc-1155/LibERC1155LazyMint.sol\";\n\nimport \"@rarible/exchange-interfaces/contracts/IRoyaltiesProvider.sol\";\n\nimport \"@rarible/lib-bp/contracts/BpLibrary.sol\";\n\nimport \"./interfaces/ITransferManager.sol\";\n\nabstract contract RaribleTransferManager is OwnableUpgradeable, ITransferManager {\n    using BpLibrary for uint;\n    using SafeMathUpgradeable for uint;\n\n    ProtocolFeeData public protocolFee;\n    IRoyaltiesProvider public royaltiesRegistry;\n\n    //deprecated\n    address private defaultFeeReceiver;\n    // deprecated\n    mapping(address => address) private feeReceivers;\n\n    /// @dev event that's emitted when ProtocolFeeData buyerAmount changes\n    event BuyerFeeAmountChanged(uint oldValue, uint newValue);\n\n    /// @dev event that's emitted when ProtocolFeeData sellerAmount changes\n    event SellerFeeAmountChanged(uint oldValue, uint newValue);\n\n    /// @dev event that's emitted when ProtocolFeeData receiver changes\n    event FeeReceiverChanged(address oldValue, address newValue);\n\n    /// @dev struct to store protocol fee - receiver address, buyer fee amount (in bp), seller fee amount (in bp)\n    struct ProtocolFeeData {\n        address receiver;\n        uint48 buyerAmount;\n        uint48 sellerAmount;\n    }\n\n    /**\n        @notice initialises RaribleTransferManager state\n        @param newProtocolFee deprecated\n        @param newDefaultFeeReceiver deprecated\n        @param newRoyaltiesProvider royaltiesRegistry contract address\n     */\n    function __RaribleTransferManager_init_unchained(\n        uint newProtocolFee,\n        address newDefaultFeeReceiver,\n        IRoyaltiesProvider newRoyaltiesProvider\n    ) internal initializer {\n        royaltiesRegistry = newRoyaltiesProvider;\n    }\n\n    function setRoyaltiesRegistry(IRoyaltiesProvider newRoyaltiesRegistry) external onlyOwner {\n        royaltiesRegistry = newRoyaltiesRegistry;\n    }\n\n    function setPrtocolFeeReceiver(address _receiver) public onlyOwner {\n        emit FeeReceiverChanged(protocolFee.receiver, _receiver);\n        protocolFee.receiver = _receiver;\n    }\n\n    function setPrtocolFeeBuyerAmount(uint48 _buyerAmount) public onlyOwner {\n        emit BuyerFeeAmountChanged(protocolFee.buyerAmount, _buyerAmount);\n        protocolFee.buyerAmount = _buyerAmount;\n    }\n\n    function setPrtocolFeeSellerAmount(uint48 _sellerAmount) public onlyOwner {\n        emit SellerFeeAmountChanged(protocolFee.sellerAmount, _sellerAmount);\n        protocolFee.sellerAmount = _sellerAmount;\n    }\n\n    function setAllProtocolFeeData(address _receiver, uint48 _buyerAmount, uint48 _sellerAmount) public onlyOwner {\n        setPrtocolFeeReceiver(_receiver);\n        setPrtocolFeeBuyerAmount(_buyerAmount);\n        setPrtocolFeeSellerAmount(_sellerAmount);\n    }\n\n    /**\n        @notice executes transfers for 2 matched orders\n        @param left DealSide from the left order (see LibDeal.sol)\n        @param right DealSide from the right order (see LibDeal.sol)\n        @param feeSide feeSide of the match\n        @return totalLeftValue - total amount for the left order\n        @return totalRightValue - total amout for the right order\n    */\n    function doTransfers(\n        LibDeal.DealSide memory left,\n        LibDeal.DealSide memory right,\n        LibFeeSide.FeeSide feeSide\n    ) override internal returns (uint totalLeftValue, uint totalRightValue) {\n        totalLeftValue = left.asset.value;\n        totalRightValue = right.asset.value;\n\n        if (feeSide == LibFeeSide.FeeSide.LEFT) {\n            totalLeftValue = doTransfersWithFees(left, right, protocolFee);\n            transferPayouts(right.asset.assetType, right.asset.value, right.from, left.payouts, right.proxy);\n        } else if (feeSide == LibFeeSide.FeeSide.RIGHT) {\n            totalRightValue = doTransfersWithFees(right, left,protocolFee);\n            transferPayouts(left.asset.assetType, left.asset.value, left.from, right.payouts, left.proxy);\n        } else {\n            transferPayouts(left.asset.assetType, left.asset.value, left.from, right.payouts, left.proxy);\n            transferPayouts(right.asset.assetType, right.asset.value, right.from, left.payouts, right.proxy);\n        }\n    }\n\n    /**\n        @notice executes the fee-side transfers (payment + fees)\n        @param paymentSide DealSide of the fee-side order\n        @param nftSide  DealSide of the nft-side order\n        @param _protocolFee protocol fee data\n        @return totalAmount of fee-side asset\n    */\n    function doTransfersWithFees(\n        LibDeal.DealSide memory paymentSide,\n        LibDeal.DealSide memory nftSide,\n        ProtocolFeeData memory _protocolFee\n    ) internal returns (uint totalAmount) {\n        totalAmount = calculateTotalAmount(paymentSide.asset.value, _protocolFee, paymentSide.originFees);\n        uint rest = transferProtocolFee(totalAmount, paymentSide.asset.value, paymentSide.from, _protocolFee, paymentSide.asset.assetType, paymentSide.proxy);\n\n        rest = transferRoyalties(paymentSide.asset.assetType, nftSide.asset.assetType, nftSide.payouts, rest, paymentSide.asset.value, paymentSide.from, paymentSide.proxy);\n        if (\n            paymentSide.originFees.length  == 1 &&\n            nftSide.originFees.length  == 1 &&\n            nftSide.originFees[0].account == paymentSide.originFees[0].account\n        ) { \n            LibPart.Part[] memory origin = new  LibPart.Part[](1);\n            origin[0].account = nftSide.originFees[0].account;\n            origin[0].value = nftSide.originFees[0].value + paymentSide.originFees[0].value;\n            (rest,) = transferFees(paymentSide.asset.assetType, rest, paymentSide.asset.value, origin, paymentSide.from, paymentSide.proxy);\n        } else {\n            (rest,) = transferFees(paymentSide.asset.assetType, rest, paymentSide.asset.value, paymentSide.originFees, paymentSide.from, paymentSide.proxy);\n            (rest,) = transferFees(paymentSide.asset.assetType, rest, paymentSide.asset.value, nftSide.originFees, paymentSide.from, paymentSide.proxy);\n        }\n        transferPayouts(paymentSide.asset.assetType, rest, paymentSide.from, nftSide.payouts, paymentSide.proxy);\n    }\n\n    function transferProtocolFee(\n        uint totalAmount,\n        uint amount,\n        address from,\n        ProtocolFeeData memory _protocolFee,\n        LibAsset.AssetType memory matchCalculate,\n        address proxy\n    ) internal returns (uint) {\n        (uint rest, uint fee) = subFeeInBp(totalAmount, amount, _protocolFee.buyerAmount + _protocolFee.sellerAmount);\n        if (fee > 0) {\n            transfer(LibAsset.Asset(matchCalculate, fee), from, _protocolFee.receiver, proxy);\n        }\n        return rest;\n    }\n\n    /**\n        @notice Transfer royalties. If there is only one royalties receiver and one address in payouts and they match,\n           nothing is transferred in this function\n        @param paymentAssetType Asset Type which represents payment\n        @param nftAssetType Asset Type which represents NFT to pay royalties for\n        @param payouts Payouts to be made\n        @param rest How much of the amount left after previous transfers\n        @param from owner of the Asset to transfer\n        @param proxy Transfer proxy to use\n        @return How much left after transferring royalties\n    */\n    function transferRoyalties(\n        LibAsset.AssetType memory paymentAssetType,\n        LibAsset.AssetType memory nftAssetType,\n        LibPart.Part[] memory payouts,\n        uint rest,\n        uint amount,\n        address from,\n        address proxy\n    ) internal returns (uint) {\n        LibPart.Part[] memory royalties = getRoyaltiesByAssetType(nftAssetType);\n        if (\n            royalties.length == 1 &&\n            payouts.length == 1 &&\n            royalties[0].account == payouts[0].account\n        ) {\n            require(royalties[0].value <= 5000, \"Royalties are too high (>50%)\");\n            return rest;\n        }\n        (uint result, uint totalRoyalties) = transferFees(paymentAssetType, rest, amount, royalties, from, proxy);\n        require(totalRoyalties <= 5000, \"Royalties are too high (>50%)\");\n        return result;\n    }\n\n    /**\n        @notice calculates royalties by asset type. If it's a lazy NFT, then royalties are extracted from asset. otherwise using royaltiesRegistry\n        @param nftAssetType NFT Asset Type to calculate royalties for\n        @return calculated royalties (Array of LibPart.Part)\n    */\n    function getRoyaltiesByAssetType(LibAsset.AssetType memory nftAssetType) internal returns (LibPart.Part[] memory) {\n        if (nftAssetType.assetClass == LibAsset.ERC1155_ASSET_CLASS || nftAssetType.assetClass == LibAsset.ERC721_ASSET_CLASS) {\n            (address token, uint tokenId) = abi.decode(nftAssetType.data, (address, uint));\n            return royaltiesRegistry.getRoyalties(token, tokenId);\n        } else if (nftAssetType.assetClass == LibERC1155LazyMint.ERC1155_LAZY_ASSET_CLASS) {\n            (, LibERC1155LazyMint.Mint1155Data memory data) = abi.decode(nftAssetType.data, (address, LibERC1155LazyMint.Mint1155Data));\n            return data.royalties;\n        } else if (nftAssetType.assetClass == LibERC721LazyMint.ERC721_LAZY_ASSET_CLASS) {\n            (, LibERC721LazyMint.Mint721Data memory data) = abi.decode(nftAssetType.data, (address, LibERC721LazyMint.Mint721Data));\n            return data.royalties;\n        }\n        LibPart.Part[] memory empty;\n        return empty;\n    }\n\n    /**\n        @notice Transfer fees\n        @param assetType Asset Type to transfer\n        @param rest How much of the amount left after previous transfers\n        @param amount Total amount of the Asset. Used as a base to calculate part from (100%)\n        @param fees Array of LibPart.Part which represents fees to pay\n        @param from owner of the Asset to transfer\n        @param proxy Transfer proxy to use\n        @return newRest how much left after transferring fees\n        @return totalFees total number of fees in bp\n    */\n    function transferFees(\n        LibAsset.AssetType memory assetType,\n        uint rest,\n        uint amount,\n        LibPart.Part[] memory fees,\n        address from,\n        address proxy\n    ) internal returns (uint newRest, uint totalFees) {\n        totalFees = 0;\n        newRest = rest;\n        for (uint256 i = 0; i < fees.length; ++i) {\n            totalFees = totalFees.add(fees[i].value);\n            uint feeValue;\n            (newRest, feeValue) = subFeeInBp(newRest, amount, fees[i].value);\n            if (feeValue > 0) {\n                transfer(LibAsset.Asset(assetType, feeValue), from, fees[i].account, proxy);\n            }\n        }\n    }\n\n    /**\n        @notice transfers main part of the asset (payout)\n        @param assetType Asset Type to transfer\n        @param amount Amount of the asset to transfer\n        @param from Current owner of the asset\n        @param payouts List of payouts - receivers of the Asset\n        @param proxy Transfer Proxy to use\n    */\n    function transferPayouts(\n        LibAsset.AssetType memory assetType,\n        uint amount,\n        address from,\n        LibPart.Part[] memory payouts,\n        address proxy\n    ) internal {\n        require(payouts.length > 0, \"transferPayouts: nothing to transfer\");\n        uint sumBps = 0;\n        uint rest = amount;\n        for (uint256 i = 0; i < payouts.length - 1; ++i) {\n            uint currentAmount = amount.bp(payouts[i].value);\n            sumBps = sumBps.add(payouts[i].value);\n            if (currentAmount > 0) {\n                rest = rest.sub(currentAmount);\n                transfer(LibAsset.Asset(assetType, currentAmount), from, payouts[i].account, proxy);\n            }\n        }\n        LibPart.Part memory lastPayout = payouts[payouts.length - 1];\n        sumBps = sumBps.add(lastPayout.value);\n        require(sumBps == 10000, \"Sum payouts Bps not equal 100%\");\n        if (rest > 0) {\n            transfer(LibAsset.Asset(assetType, rest), from, lastPayout.account, proxy);\n        }\n    }\n    \n    /**\n        @notice calculates total amount of fee-side asset that is going to be used in match\n        @param amount fee-side order value\n        @param _protocolFee protocol fee\n        @param orderOriginFees fee-side order's origin fee (it adds on top of the amount)\n        @return total amount of fee-side asset\n    */\n    function calculateTotalAmount(\n        uint amount,\n        ProtocolFeeData memory _protocolFee,\n        LibPart.Part[] memory orderOriginFees\n    ) internal pure returns (uint) {\n        \n        uint fees = _protocolFee.buyerAmount;\n        for (uint256 i = 0; i < orderOriginFees.length; ++i) {\n            require(orderOriginFees[i].value <= 10000, \"origin fee is too big\");\n            fees = fees + orderOriginFees[i].value;\n        }\n\n        return amount.add(amount.bp(fees));\n    }\n\n    function subFeeInBp(uint value, uint total, uint feeInBp) internal pure returns (uint newValue, uint realFee) {\n        return subFee(value, total.bp(feeInBp));\n    }\n\n    function subFee(uint value, uint fee) internal pure returns (uint newValue, uint realFee) {\n        if (value > fee) {\n            newValue = value.sub(fee);\n            realFee = fee;\n        } else {\n            newValue = 0;\n            realFee = value;\n        }\n    }\n\n    uint256[46] private __gap;\n}\n"
      },
      "@rarible/transfer-manager/contracts/TransferExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/exchange-interfaces/contracts/ITransferProxy.sol\";\nimport \"@rarible/exchange-interfaces/contracts/INftTransferProxy.sol\";\nimport \"@rarible/exchange-interfaces/contracts/IERC20TransferProxy.sol\";\nimport \"./interfaces/ITransferExecutor.sol\";\n\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\n\nimport \"./lib/LibTransfer.sol\";\n\nabstract contract TransferExecutor is Initializable, OwnableUpgradeable, ITransferExecutor {\n    using LibTransfer for address;\n\n    mapping (bytes4 => address) internal proxies;\n\n    event ProxyChange(bytes4 indexed assetType, address proxy);\n\n    function __TransferExecutor_init_unchained(address transferProxy, address erc20TransferProxy) internal { \n        proxies[LibAsset.ERC20_ASSET_CLASS] = address(erc20TransferProxy);\n        proxies[LibAsset.ERC721_ASSET_CLASS] = address(transferProxy);\n        proxies[LibAsset.ERC1155_ASSET_CLASS] = address(transferProxy);\n    }\n\n    function setTransferProxy(bytes4 assetType, address proxy) external onlyOwner {\n        proxies[assetType] = proxy;\n        emit ProxyChange(assetType, proxy);\n    }\n\n    function transfer(\n        LibAsset.Asset memory asset,\n        address from,\n        address to,\n        address proxy\n    ) internal override {\n        if (asset.assetType.assetClass == LibAsset.ERC721_ASSET_CLASS) {\n            //not using transfer proxy when transfering from this contract\n            (address token, uint tokenId) = abi.decode(asset.assetType.data, (address, uint256));\n            require(asset.value == 1, \"erc721 value error\");\n            if (from == address(this)){\n                IERC721Upgradeable(token).safeTransferFrom(address(this), to, tokenId);\n            } else {\n                INftTransferProxy(proxy).erc721safeTransferFrom(IERC721Upgradeable(token), from, to, tokenId);\n            }\n        } else if (asset.assetType.assetClass == LibAsset.ERC20_ASSET_CLASS) {\n            //not using transfer proxy when transfering from this contract\n            (address token) = abi.decode(asset.assetType.data, (address));\n            if (from == address(this)){\n                require(IERC20Upgradeable(token).transfer(to, asset.value), \"erc20 transfer failed\");\n            } else {\n                IERC20TransferProxy(proxy).erc20safeTransferFrom(IERC20Upgradeable(token), from, to, asset.value);\n            }\n        } else if (asset.assetType.assetClass == LibAsset.ERC1155_ASSET_CLASS) {\n            //not using transfer proxy when transfering from this contract\n            (address token, uint tokenId) = abi.decode(asset.assetType.data, (address, uint256));\n            if (from == address(this)){\n                IERC1155Upgradeable(token).safeTransferFrom(address(this), to, tokenId, asset.value, \"\");\n            } else {\n                INftTransferProxy(proxy).erc1155safeTransferFrom(IERC1155Upgradeable(token), from, to, tokenId, asset.value, \"\");  \n            }\n        } else if (asset.assetType.assetClass == LibAsset.ETH_ASSET_CLASS) {\n            if (to != address(this)) {\n                to.transferEth(asset.value);\n            }\n        } else {\n            ITransferProxy(proxy).transfer(asset, from, to);\n        }\n    }\n    \n    uint256[49] private __gap;\n}\n"
      },
      "@rarible/transfer-manager/contracts/interfaces/ITransferExecutor.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\n\nabstract contract ITransferExecutor {\n    function transfer(\n        LibAsset.Asset memory asset,\n        address from,\n        address to,\n        address proxy\n    ) internal virtual;\n}\n"
      },
      "@rarible/transfer-manager/contracts/interfaces/ITransferManager.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"../lib/LibDeal.sol\";\nimport \"./ITransferExecutor.sol\";\n\nabstract contract ITransferManager is ITransferExecutor {\n\n    function doTransfers(\n        LibDeal.DealSide memory left,\n        LibDeal.DealSide memory right,\n        LibFeeSide.FeeSide feeSide\n    ) internal virtual returns (uint totalMakeValue, uint totalTakeValue);\n}"
      },
      "@rarible/transfer-manager/contracts/lib/LibDeal.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/lib-part/contracts/LibPart.sol\";\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\nimport \"./LibFeeSide.sol\";\n\nlibrary LibDeal {\n    struct DealSide {\n        LibAsset.Asset asset;\n        LibPart.Part[] payouts;\n        LibPart.Part[] originFees;\n        address proxy;\n        address from;\n    }\n}\n"
      },
      "@rarible/transfer-manager/contracts/lib/LibFeeSide.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\n\nlibrary LibFeeSide {\n\n    enum FeeSide {NONE, LEFT, RIGHT}\n\n    function getFeeSide(bytes4 leftClass, bytes4 rightClass) internal pure returns (FeeSide) {\n        if (leftClass == LibAsset.ETH_ASSET_CLASS) {\n            return FeeSide.LEFT;\n        }\n        if (rightClass == LibAsset.ETH_ASSET_CLASS) {\n            return FeeSide.RIGHT;\n        }\n        if (leftClass == LibAsset.ERC20_ASSET_CLASS) {\n            return FeeSide.LEFT;\n        }\n        if (rightClass == LibAsset.ERC20_ASSET_CLASS) {\n            return FeeSide.RIGHT;\n        }\n        if (leftClass == LibAsset.ERC1155_ASSET_CLASS) {\n            return FeeSide.LEFT;\n        }\n        if (rightClass == LibAsset.ERC1155_ASSET_CLASS) {\n            return FeeSide.RIGHT;\n        }\n        return FeeSide.NONE;\n    }\n}\n"
      },
      "@rarible/transfer-manager/contracts/lib/LibTransfer.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nlibrary LibTransfer {\n    function transferEth(address to, uint value) internal {\n        (bool success,) = to.call{ value: value }(\"\");\n        require(success, \"transfer failed\");\n    }\n}\n"
      },
      "@rarible/transfer-proxy/contracts/proxy/ERC20TransferProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\n\nimport \"@rarible/role-operator/contracts/OperatorRole.sol\";\nimport \"@rarible/exchange-interfaces/contracts/IERC20TransferProxy.sol\";\n\ncontract ERC20TransferProxy is IERC20TransferProxy, Initializable, OperatorRole {\n\n    function __ERC20TransferProxy_init() external initializer {\n        __Ownable_init();\n    }\n\n    function erc20safeTransferFrom(IERC20Upgradeable token, address from, address to, uint256 value) override external onlyOperator {\n        require(token.transferFrom(from, to, value), \"failure while transferring\");\n    }\n}\n"
      },
      "@rarible/transfer-proxy/contracts/proxy/TransferProxy.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.9 <0.8.0;\n\nimport \"@rarible/role-operator/contracts/OperatorRole.sol\";\nimport \"@rarible/exchange-interfaces/contracts/INftTransferProxy.sol\";\n\ncontract TransferProxy is INftTransferProxy, Initializable, OperatorRole {\n\n    function __TransferProxy_init() external initializer {\n        __Ownable_init();\n    }\n\n    function erc721safeTransferFrom(IERC721Upgradeable token, address from, address to, uint256 tokenId) override external onlyOperator {\n        token.safeTransferFrom(from, to, tokenId);\n    }\n\n    function erc1155safeTransferFrom(IERC1155Upgradeable token, address from, address to, uint256 id, uint256 value, bytes calldata data) override external onlyOperator {\n        token.safeTransferFrom(from, to, id, value, data);\n    }\n}\n"
      }
    }
  }}