File size: 96,601 Bytes
f998fcd |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 |
{
"language": "Solidity",
"sources": {
"@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 \"./RaribleTransferManager.sol\";\nimport \"@rarible/royalties/contracts/IRoyaltiesProvider.sol\";\n\ncontract ExchangeV2 is ExchangeV2Core, RaribleTransferManager {\n function __ExchangeV2_init(\n INftTransferProxy _transferProxy,\n IERC20TransferProxy _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}"
},
"@rarible/royalties/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/royalties/contracts/IRoyaltiesProvider.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\npragma abicoder v2;\n\nimport \"./LibPart.sol\";\n\ninterface IRoyaltiesProvider {\n function getRoyalties(address token, uint tokenId) external returns (LibPart.Part[] memory);\n}\n"
},
"@rarible/libraries/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/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/lazy-mint/contracts/erc-721/LibERC721LazyMint.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"@rarible/royalties/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/lazy-mint/contracts/erc-1155/LibERC1155LazyMint.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.2 <0.8.0;\n\nimport \"@rarible/royalties/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/exchange-v2/contracts/lib/PerTrillionLibrary.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport '@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol';\n\nlibrary PerTrillionLibrary {\n using SafeMathUpgradeable for uint256;\n\n uint96 public constant TRILLION = 1000000000000;\n\n function perTrillion(uint256 value, uint96 ptValue)\n internal\n pure\n returns (uint256)\n {\n return value.mul(ptValue).div(TRILLION);\n }\n}\n"
},
"@rarible/exchange-v2/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/exchange-v2/contracts/lib/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/lib/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/exchange-v2/contracts/interfaces/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/exchange-v2/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 \"./ITransferExecutor.sol\";\nimport \"@openzeppelin/contracts-upgradeable/proxy/Initializable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol\";\nimport \"./lib/LibTransfer.sol\";\n\nabstract contract TransferExecutor is Initializable, OwnableUpgradeable, ITransferExecutor {\n using LibTransfer for address;\n\n mapping (bytes4 => address) proxies;\n\n event ProxyChange(bytes4 indexed assetType, address proxy);\n\n function __TransferExecutor_init_unchained(INftTransferProxy transferProxy, IERC20TransferProxy 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 bytes4 transferDirection,\n bytes4 transferType\n ) internal override {\n if (asset.assetType.assetClass == LibAsset.ETH_ASSET_CLASS) {\n to.transferEth(asset.value);\n } else if (asset.assetType.assetClass == LibAsset.ERC20_ASSET_CLASS) {\n (address token) = abi.decode(asset.assetType.data, (address));\n IERC20TransferProxy(proxies[LibAsset.ERC20_ASSET_CLASS]).erc20safeTransferFrom(IERC20Upgradeable(token), from, to, asset.value);\n } else if (asset.assetType.assetClass == LibAsset.ERC721_ASSET_CLASS) {\n (address token, uint tokenId) = abi.decode(asset.assetType.data, (address, uint256));\n require(asset.value == 1, \"erc721 value error\");\n INftTransferProxy(proxies[LibAsset.ERC721_ASSET_CLASS]).erc721safeTransferFrom(IERC721Upgradeable(token), from, to, tokenId);\n } else if (asset.assetType.assetClass == LibAsset.ERC1155_ASSET_CLASS) {\n (address token, uint tokenId) = abi.decode(asset.assetType.data, (address, uint256));\n INftTransferProxy(proxies[LibAsset.ERC1155_ASSET_CLASS]).erc1155safeTransferFrom(IERC1155Upgradeable(token), from, to, tokenId, asset.value, \"\");\n } else {\n ITransferProxy(proxies[asset.assetType.assetClass]).transfer(asset, from, to);\n }\n emit Transfer(asset, from, to, transferDirection, transferType);\n }\n\n uint256[49] private __gap;\n}\n"
},
"@rarible/exchange-v2/contracts/RaribleTransferManager.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\";\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\nimport \"@rarible/royalties/contracts/IRoyaltiesProvider.sol\";\nimport \"@rarible/lazy-mint/contracts/erc-721/LibERC721LazyMint.sol\";\nimport \"@rarible/lazy-mint/contracts/erc-1155/LibERC1155LazyMint.sol\";\nimport \"./LibFill.sol\";\nimport \"./LibFeeSide.sol\";\nimport \"./ITransferManager.sol\";\nimport \"./TransferExecutor.sol\";\nimport \"./lib/BpLibrary.sol\";\nimport \"./lib/PerTrillionLibrary.sol\";\n\nabstract contract RaribleTransferManager is OwnableUpgradeable, ITransferManager {\n using BpLibrary for uint;\n using SafeMathUpgradeable for uint;\n using PerTrillionLibrary for uint;\n\n uint public protocolFee;\n IRoyaltiesProvider public royaltiesRegistry;\n\n address public defaultFeeReceiver;\n mapping(address => address) public feeReceivers;\n\n function __RaribleTransferManager_init_unchained(\n uint newProtocolFee,\n address newDefaultFeeReceiver,\n IRoyaltiesProvider newRoyaltiesProvider\n ) internal initializer {\n protocolFee = newProtocolFee;\n defaultFeeReceiver = newDefaultFeeReceiver;\n royaltiesRegistry = newRoyaltiesProvider;\n }\n\n function setRoyaltiesRegistry(IRoyaltiesProvider newRoyaltiesRegistry) external onlyOwner {\n royaltiesRegistry = newRoyaltiesRegistry;\n }\n\n function setProtocolFee(uint newProtocolFee) external onlyOwner {\n protocolFee = newProtocolFee;\n }\n\n function setDefaultFeeReceiver(address payable newDefaultFeeReceiver) external onlyOwner {\n defaultFeeReceiver = newDefaultFeeReceiver;\n }\n\n function setFeeReceiver(address token, address wallet) external onlyOwner {\n feeReceivers[token] = wallet;\n }\n\n function getFeeReceiver(address token) internal view returns (address) {\n address wallet = feeReceivers[token];\n if (wallet != address(0)) {\n return wallet;\n }\n return defaultFeeReceiver;\n }\n\n function doTransfers(\n LibAsset.AssetType memory makeMatch,\n LibAsset.AssetType memory takeMatch,\n LibFill.FillResult memory fill,\n LibOrder.Order memory leftOrder,\n LibOrder.Order memory rightOrder,\n LibOrderDataV2.DataV2 memory leftOrderData,\n LibOrderDataV2.DataV2 memory rightOrderData\n ) override internal returns (uint totalMakeValue, uint totalTakeValue) {\n LibFeeSide.FeeSide feeSide = LibFeeSide.getFeeSide(makeMatch.assetClass, takeMatch.assetClass);\n totalMakeValue = fill.leftValue;\n totalTakeValue = fill.rightValue;\n if (feeSide == LibFeeSide.FeeSide.MAKE) {\n totalMakeValue = doTransfersWithFees(fill.leftValue, leftOrder.maker, leftOrderData, rightOrderData, makeMatch, takeMatch, TO_TAKER);\n transferPayouts(takeMatch, fill.rightValue, rightOrder.maker, leftOrderData.payouts, TO_MAKER);\n } else if (feeSide == LibFeeSide.FeeSide.TAKE) {\n totalTakeValue = doTransfersWithFees(fill.rightValue, rightOrder.maker, rightOrderData, leftOrderData, takeMatch, makeMatch, TO_MAKER);\n transferPayouts(makeMatch, fill.leftValue, leftOrder.maker, rightOrderData.payouts, TO_TAKER);\n } else {\n transferPayouts(makeMatch, fill.leftValue, leftOrder.maker, rightOrderData.payouts, TO_TAKER);\n transferPayouts(takeMatch, fill.rightValue, rightOrder.maker, leftOrderData.payouts, TO_MAKER);\n }\n }\n\n function doTransfersWithFees(\n uint amount,\n address from,\n LibOrderDataV2.DataV2 memory dataCalculate,\n LibOrderDataV2.DataV2 memory dataNft,\n LibAsset.AssetType memory matchCalculate,\n LibAsset.AssetType memory matchNft,\n bytes4 transferDirection\n ) internal returns (uint totalAmount) {\n totalAmount = calculateTotalAmount(amount, protocolFee, dataCalculate.originFees);\n uint rest = transferProtocolFee(totalAmount, amount, from, matchCalculate, transferDirection);\n rest = transferRoyalties(matchCalculate, matchNft, rest, amount, from, transferDirection);\n rest = transferOriginFees(matchCalculate, rest, amount, dataCalculate.originFees, from, transferDirection, ORIGIN);\n rest = transferOriginFees(matchCalculate, rest, amount, dataNft.originFees, from, transferDirection, ORIGIN);\n transferPayouts(matchCalculate, rest, from, dataNft.payouts, transferDirection);\n }\n\n function transferProtocolFee(\n uint totalAmount,\n uint amount,\n address from,\n LibAsset.AssetType memory matchCalculate,\n bytes4 transferDirection\n ) internal returns (uint) {\n (uint rest, uint fee) = subFeeInBp(totalAmount, amount, protocolFee.mul(2));\n if (fee > 0) {\n address tokenAddress = address(0);\n if (matchCalculate.assetClass == LibAsset.ERC20_ASSET_CLASS) {\n tokenAddress = abi.decode(matchCalculate.data, (address));\n } else if (matchCalculate.assetClass == LibAsset.ERC1155_ASSET_CLASS) {\n uint tokenId;\n (tokenAddress, tokenId) = abi.decode(matchCalculate.data, (address, uint));\n }\n transfer(LibAsset.Asset(matchCalculate, fee), from, getFeeReceiver(tokenAddress), transferDirection, PROTOCOL);\n }\n return rest;\n }\n\n function transferRoyalties(\n LibAsset.AssetType memory matchCalculate,\n LibAsset.AssetType memory matchNft,\n uint rest,\n uint amount,\n address from,\n bytes4 transferDirection\n ) internal returns (uint) {\n LibPart.Part[] memory fees = getRoyaltiesByAssetType(matchNft);\n\n (uint result, uint totalRoyalties) = transferFees(matchCalculate, rest, amount, fees, from, transferDirection, ROYALTY);\n require(totalRoyalties <= 5000, \"Royalties are too high (>50%)\");\n return result;\n }\n\n function getRoyaltiesByAssetType(LibAsset.AssetType memory matchNft) internal returns (LibPart.Part[] memory) {\n if (matchNft.assetClass == LibAsset.ERC1155_ASSET_CLASS || matchNft.assetClass == LibAsset.ERC721_ASSET_CLASS) {\n (address token, uint tokenId) = abi.decode(matchNft.data, (address, uint));\n return royaltiesRegistry.getRoyalties(token, tokenId);\n } else if (matchNft.assetClass == LibERC1155LazyMint.ERC1155_LAZY_ASSET_CLASS) {\n (address token, LibERC1155LazyMint.Mint1155Data memory data) = abi.decode(matchNft.data, (address, LibERC1155LazyMint.Mint1155Data));\n return data.royalties;\n } else if (matchNft.assetClass == LibERC721LazyMint.ERC721_LAZY_ASSET_CLASS) {\n (address token, LibERC721LazyMint.Mint721Data memory data) = abi.decode(matchNft.data, (address, LibERC721LazyMint.Mint721Data));\n return data.royalties;\n }\n LibPart.Part[] memory empty;\n return empty;\n }\n\n function transferFees(\n LibAsset.AssetType memory matchCalculate,\n uint rest,\n uint amount,\n LibPart.Part[] memory fees,\n address from,\n bytes4 transferDirection,\n bytes4 transferType\n ) internal returns (uint restValue, uint totalFees) {\n totalFees = 0;\n restValue = rest;\n for (uint256 i = 0; i < fees.length; i++) {\n totalFees = totalFees.add(fees[i].value);\n (uint newRestValue, uint feeValue) = subFeeInBp(restValue, amount, fees[i].value);\n restValue = newRestValue;\n if (feeValue > 0) {\n transfer(LibAsset.Asset(matchCalculate, feeValue), from, fees[i].account, transferDirection, transferType);\n }\n }\n }\n\n function transferPayouts(\n LibAsset.AssetType memory matchCalculate,\n uint amount,\n address from,\n LibPart.Part[] memory payouts,\n bytes4 transferDirection\n ) internal {\n uint sumBps = 0;\n uint restValue = 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 restValue = restValue.sub(currentAmount);\n transfer(LibAsset.Asset(matchCalculate, currentAmount), from, payouts[i].account, transferDirection, PAYOUT);\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 (restValue > 0) {\n transfer(LibAsset.Asset(matchCalculate, restValue), from, lastPayout.account, transferDirection, PAYOUT);\n }\n }\n\n function calculateTotalAmount(\n uint amount,\n uint feeOnTopBp,\n LibPart.Part[] memory orderOriginFees\n ) internal pure returns (uint total){\n total = amount.add(amount.bp(feeOnTopBp));\n for (uint256 i = 0; i < orderOriginFees.length; i++) {\n total = total.add(amount.perTrillion(orderOriginFees[i].value));\n }\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 function transferOriginFees(\n LibAsset.AssetType memory matchCalculate,\n uint rest,\n uint amount,\n LibPart.Part[] memory fees,\n address from,\n bytes4 transferDirection,\n bytes4 transferType\n ) internal returns (uint restValue) {\n restValue = rest;\n for (uint256 i = 0; i < fees.length; i++) {\n (uint newRestValue, uint feeValue) = subFee(restValue, amount.perTrillion(fees[i].value));\n restValue = newRestValue;\n if (feeValue > 0) {\n transfer(LibAsset.Asset(matchCalculate, feeValue), from, fees[i].account, transferDirection, transferType);\n }\n }\n }\n\n\n uint256[46] private __gap;\n}\n"
},
"@rarible/exchange-v2/contracts/OrderValidator.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"./interfaces/IERC1271.sol\";\nimport \"./LibOrder.sol\";\nimport \"@rarible/libraries/contracts/LibSignature.sol\";\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 } else {\n order.maker = _msgSender();\n }\n } else {\n if (_msgSender() != order.maker) {\n bytes32 hash = LibOrder.hash(order);\n address signer;\n if (signature.length == 65) {\n signer = _hashTypedDataV4(hash).recover(signature);\n }\n if (signer != order.maker) {\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 revert(\"order signature verification error\");\n }\n } \n }\n }\n }\n\n uint256[50] private __gap;\n}\n"
},
"@rarible/exchange-v2/contracts/LibOrderDataV2.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/royalties/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 function decodeOrderDataV2(bytes memory data) internal pure returns (DataV2 memory orderData) {\n orderData = abi.decode(data, (DataV2));\n }\n\n}\n"
},
"@rarible/exchange-v2/contracts/LibOrderDataV1.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/royalties/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 function decodeOrderDataV1(bytes memory data) internal pure returns (DataV1 memory orderData) {\n orderData = abi.decode(data, (DataV1));\n }\n}\n"
},
"@rarible/exchange-v2/contracts/LibOrderData.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"./LibOrder.sol\";\n\nlibrary LibOrderData {\n function parse(LibOrder.Order memory order) pure internal returns (LibOrderDataV2.DataV2 memory dataOrder) {\n if (order.dataType == LibOrderDataV1.V1) {\n LibOrderDataV1.DataV1 memory dataV1 = LibOrderDataV1.decodeOrderDataV1(order.data);\n dataOrder.payouts = dataV1.payouts;\n dataOrder.originFees = dataV1.originFees;\n dataOrder.isMakeFill = false;\n } else if (order.dataType == LibOrderDataV2.V2) {\n dataOrder = LibOrderDataV2.decodeOrderDataV2(order.data);\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"
},
"@rarible/exchange-v2/contracts/LibOrder.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"./lib/LibMath.sol\";\nimport \"@rarible/lib-asset/contracts/LibAsset.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 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 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 //order.data is in hash for V2 orders\n if (order.dataType == LibOrderDataV2.V2){\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 } else {\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 }\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 validate(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/LibFill.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\n\nimport \"./LibOrder.sol\";\nimport \"@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol\";\nimport \"@openzeppelin/contracts-upgradeable/math/MathUpgradeable.sol\";\n\nlibrary LibFill {\n using SafeMathUpgradeable for uint;\n\n struct FillResult {\n uint leftValue;\n uint rightValue;\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 */\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) { //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/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, MAKE, TAKE}\n\n function getFeeSide(bytes4 make, bytes4 take) internal pure returns (FeeSide) {\n if (make == LibAsset.ETH_ASSET_CLASS) {\n return FeeSide.MAKE;\n }\n if (take == LibAsset.ETH_ASSET_CLASS) {\n return FeeSide.TAKE;\n }\n if (make == LibAsset.ERC20_ASSET_CLASS) {\n return FeeSide.MAKE;\n }\n if (take == LibAsset.ERC20_ASSET_CLASS) {\n return FeeSide.TAKE;\n }\n if (make == LibAsset.ERC1155_ASSET_CLASS) {\n return FeeSide.MAKE;\n }\n if (take == LibAsset.ERC1155_ASSET_CLASS) {\n return FeeSide.TAKE;\n }\n return FeeSide.NONE;\n }\n}\n"
},
"@rarible/exchange-v2/contracts/ITransferManager.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity 0.7.6;\npragma abicoder v2;\n\nimport \"@rarible/lib-asset/contracts/LibAsset.sol\";\nimport \"./LibFill.sol\";\nimport \"./TransferExecutor.sol\";\nimport \"./LibOrderData.sol\";\n\nabstract contract ITransferManager is ITransferExecutor {\n bytes4 constant TO_MAKER = bytes4(keccak256(\"TO_MAKER\"));\n bytes4 constant TO_TAKER = bytes4(keccak256(\"TO_TAKER\"));\n bytes4 constant PROTOCOL = bytes4(keccak256(\"PROTOCOL\"));\n bytes4 constant ROYALTY = bytes4(keccak256(\"ROYALTY\"));\n bytes4 constant ORIGIN = bytes4(keccak256(\"ORIGIN\"));\n bytes4 constant PAYOUT = bytes4(keccak256(\"PAYOUT\"));\n\n function doTransfers(\n LibAsset.AssetType memory makeMatch,\n LibAsset.AssetType memory takeMatch,\n LibFill.FillResult memory fill,\n LibOrder.Order memory leftOrder,\n LibOrder.Order memory rightOrder,\n LibOrderDataV2.DataV2 memory leftOrderData,\n LibOrderDataV2.DataV2 memory rightOrderData\n ) internal virtual returns (uint totalMakeValue, uint totalTakeValue);\n}\n"
},
"@rarible/exchange-v2/contracts/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\n //events\n event Transfer(LibAsset.Asset asset, address from, address to, bytes4 transferDirection, bytes4 transferType);\n\n function transfer(\n LibAsset.Asset memory asset,\n address from,\n address to,\n bytes4 transferDirection,\n bytes4 transferType\n ) internal virtual;\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 \"./LibFill.sol\";\nimport \"./LibOrder.sol\";\nimport \"./OrderValidator.sol\";\nimport \"./AssetMatcher.sol\";\nimport \"./TransferExecutor.sol\";\nimport \"./ITransferManager.sol\";\nimport \"./lib/LibTransfer.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 = 2 ** 256 - 1;\n\n //state of the orders\n mapping(bytes32 => uint) public fills;\n\n //events\n event Cancel(bytes32 hash, address maker, LibAsset.AssetType makeAssetType, LibAsset.AssetType takeAssetType);\n event Match(bytes32 leftHash, bytes32 rightHash, address leftMaker, address rightMaker, uint newLeftFill, uint newRightFill, LibAsset.AssetType leftAsset, LibAsset.AssetType rightAsset);\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, order.maker, order.makeAsset.assetType, order.takeAsset.assetType);\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 validateFull(orderLeft, signatureLeft);\n validateFull(orderRight, signatureRight);\n if (orderLeft.taker != address(0)) {\n require(orderRight.maker == orderLeft.taker, \"leftOrder.taker verification failed\");\n }\n if (orderRight.taker != address(0)) {\n require(orderRight.taker == orderLeft.maker, \"rightOrder.taker verification failed\");\n }\n matchAndTransfer(orderLeft, orderRight);\n }\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 bytes32 leftOrderKeyHash = LibOrder.hashKey(orderLeft);\n bytes32 rightOrderKeyHash = LibOrder.hashKey(orderRight);\n\n LibOrderDataV2.DataV2 memory leftOrderData = LibOrderData.parse(orderLeft);\n LibOrderDataV2.DataV2 memory rightOrderData = LibOrderData.parse(orderRight);\n\n LibFill.FillResult memory newFill = getFillSetNew(orderLeft, orderRight, leftOrderKeyHash, rightOrderKeyHash, leftOrderData, rightOrderData);\n\n (uint totalMakeValue, uint totalTakeValue) = doTransfers(makeMatch, takeMatch, newFill, orderLeft, orderRight, leftOrderData, rightOrderData);\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 emit Match(leftOrderKeyHash, rightOrderKeyHash, orderLeft.maker, orderRight.maker, newFill.rightValue, newFill.leftValue, makeMatch, takeMatch);\n }\n\n function getFillSetNew(\n LibOrder.Order memory orderLeft,\n LibOrder.Order memory orderRight,\n bytes32 leftOrderKeyHash,\n bytes32 rightOrderKeyHash,\n LibOrderDataV2.DataV2 memory leftOrderData,\n LibOrderDataV2.DataV2 memory rightOrderData\n ) internal returns (LibFill.FillResult memory) {\n uint leftOrderFill = getOrderFill(orderLeft, leftOrderKeyHash);\n uint rightOrderFill = getOrderFill(orderRight, rightOrderKeyHash);\n LibFill.FillResult memory newFill = LibFill.fillOrder(orderLeft, orderRight, leftOrderFill, rightOrderFill, leftOrderData.isMakeFill, rightOrderData.isMakeFill);\n\n require(newFill.rightValue > 0 && newFill.leftValue > 0, \"nothing to fill\");\n\n if (orderLeft.salt != 0) {\n if (leftOrderData.isMakeFill) {\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 (rightOrderData.isMakeFill) {\n fills[rightOrderKeyHash] = rightOrderFill.add(newFill.rightValue);\n } else {\n fills[rightOrderKeyHash] = rightOrderFill.add(newFill.leftValue);\n }\n }\n return newFill;\n }\n\n function getOrderFill(LibOrder.Order memory order, bytes32 hash) internal view returns (uint fill) {\n if (order.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.validate(order);\n validate(order, signature);\n }\n\n uint256[49] private __gap;\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) 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 view 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-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-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/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/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"
},
"@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-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/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/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/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/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/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/math/MathUpgradeable.sol": {
"content": "// SPDX-License-Identifier: MIT\n\npragma solidity >=0.6.0 <0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary MathUpgradeable {\n /**\n * @dev Returns the largest of two numbers.\n */\n function max(uint256 a, uint256 b) internal pure returns (uint256) {\n return a >= b ? a : b;\n }\n\n /**\n * @dev Returns the smallest of two numbers.\n */\n function min(uint256 a, uint256 b) internal pure returns (uint256) {\n return a < b ? a : b;\n }\n\n /**\n * @dev Returns the average of two numbers. The result is rounded towards\n * zero.\n */\n function average(uint256 a, uint256 b) internal pure returns (uint256) {\n // (a + b) / 2 can overflow, so we distribute\n return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);\n }\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/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/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"
}
},
"settings": {
"remappings": [],
"optimizer": {
"enabled": true,
"runs": 200
},
"evmVersion": "istanbul",
"libraries": {},
"outputSelection": {
"*": {
"*": [
"evm.bytecode",
"evm.deployedBytecode",
"devdoc",
"userdoc",
"metadata",
"abi"
]
}
}
}
} |