Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- Marketplace
- Optimization enabled
- true
- Compiler version
- v0.8.9+commit.e5eed63a
- Optimization runs
- 200
- EVM Version
- default
- Verified at
- 2024-04-28T07:47:53.062914Z
Contract source code
// Sources flattened with hardhat v2.10.1 https://hardhat.org // File openzeppelin-contracts-upgradeable/utils/CountersUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } } // File openzeppelin-contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); } // File openzeppelin-contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; } // File openzeppelin-contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); } // File openzeppelin-contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); } // File openzeppelin-contracts-upgradeable/utils/AddressUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } } // File openzeppelin-contracts-upgradeable/proxy/utils/Initializable.sol // OpenZeppelin Contracts v4.4.0 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { require(_initializing || !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } } // File openzeppelin-contracts-upgradeable/utils/ContextUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/Context.sol) pragma solidity ^0.8.0; /** * @dev Provides information about the current execution context, including the * sender of the transaction and its data. While these are generally available * via msg.sender and msg.data, they should not be accessed in such a direct * manner, since when dealing with meta-transactions the account sending and * paying for execution may not be the actual sender (as far as an application * is concerned). * * This contract is only required for intermediate, library-like contracts. */ abstract contract ContextUpgradeable is Initializable { function __Context_init() internal initializer { __Context_init_unchained(); } function __Context_init_unchained() internal initializer { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; } // File openzeppelin-contracts-upgradeable/utils/StringsUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { // Inspired by OraclizeAPI's implementation - MIT licence // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol if (value == 0) { return "0"; } uint256 temp = value; uint256 digits; while (temp != 0) { digits++; temp /= 10; } bytes memory buffer = new bytes(digits); while (value != 0) { digits -= 1; buffer[digits] = bytes1(uint8(48 + uint256(value % 10))); value /= 10; } return string(buffer); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { if (value == 0) { return "0x00"; } uint256 temp = value; uint256 length = 0; while (temp != 0) { length++; temp >>= 8; } return toHexString(value, length); } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length. */ function toHexString(uint256 value, uint256 length) internal pure returns (string memory) { bytes memory buffer = new bytes(2 * length + 2); buffer[0] = "0"; buffer[1] = "x"; for (uint256 i = 2 * length + 1; i > 1; --i) { buffer[i] = _HEX_SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } } // File openzeppelin-contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal initializer { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal initializer { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; } // File openzeppelin-contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol // OpenZeppelin Contracts v4.4.0 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} uint256[44] private __gap; } // File openzeppelin-contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; /** * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations. * * These functions can be used to verify that a message was signed by the holder * of the private keys of a given address. */ library ECDSAUpgradeable { enum RecoverError { NoError, InvalidSignature, InvalidSignatureLength, InvalidSignatureS, InvalidSignatureV } function _throwError(RecoverError error) private pure { if (error == RecoverError.NoError) { return; // no error: do nothing } else if (error == RecoverError.InvalidSignature) { revert("ECDSA: invalid signature"); } else if (error == RecoverError.InvalidSignatureLength) { revert("ECDSA: invalid signature length"); } else if (error == RecoverError.InvalidSignatureS) { revert("ECDSA: invalid signature 's' value"); } else if (error == RecoverError.InvalidSignatureV) { revert("ECDSA: invalid signature 'v' value"); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature` or error string. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. * * Documentation for signature generation: * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js] * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers] * * _Available since v4.3._ */ function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) { // Check the signature length // - case 65: r,s,v signature (standard) // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._ if (signature.length == 65) { bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return tryRecover(hash, v, r, s); } else if (signature.length == 64) { bytes32 r; bytes32 vs; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. assembly { r := mload(add(signature, 0x20)) vs := mload(add(signature, 0x40)) } return tryRecover(hash, r, vs); } else { return (address(0), RecoverError.InvalidSignatureLength); } } /** * @dev Returns the address that signed a hashed message (`hash`) with * `signature`. This address can then be used for verification purposes. * * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures: * this function rejects them by requiring the `s` value to be in the lower * half order, and the `v` value to be either 27 or 28. * * IMPORTANT: `hash` _must_ be the result of a hash operation for the * verification to be secure: it is possible to craft signatures that * recover to arbitrary addresses for non-hashed data. A safe way to ensure * this is by receiving a hash of the original message (which may otherwise * be too long), and then calling {toEthSignedMessageHash} on it. */ function recover(bytes32 hash, bytes memory signature) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, signature); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately. * * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures] * * _Available since v4.3._ */ function tryRecover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address, RecoverError) { bytes32 s; uint8 v; assembly { s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff) v := add(shr(255, vs), 27) } return tryRecover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately. * * _Available since v4.2._ */ function recover( bytes32 hash, bytes32 r, bytes32 vs ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, r, vs); _throwError(error); return recovered; } /** * @dev Overload of {ECDSA-tryRecover} that receives the `v`, * `r` and `s` signature fields separately. * * _Available since v4.3._ */ function tryRecover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address, RecoverError) { // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most // signatures from current libraries generate a unique signature with an s-value in the lower half order. // // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept // these malleable signatures as well. if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) { return (address(0), RecoverError.InvalidSignatureS); } if (v != 27 && v != 28) { return (address(0), RecoverError.InvalidSignatureV); } // If the signature is valid (and not malleable), return the signer address address signer = ecrecover(hash, v, r, s); if (signer == address(0)) { return (address(0), RecoverError.InvalidSignature); } return (signer, RecoverError.NoError); } /** * @dev Overload of {ECDSA-recover} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { (address recovered, RecoverError error) = tryRecover(hash, v, r, s); _throwError(error); return recovered; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) { // 32 is the length in bytes of hash, // enforced by the type signature above return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash)); } /** * @dev Returns an Ethereum Signed Message, created from `s`. This * produces hash corresponding to the one signed with the * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`] * JSON-RPC method as part of EIP-191. * * See {recover}. */ function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s)); } /** * @dev Returns an Ethereum Signed Typed Data, created from a * `domainSeparator` and a `structHash`. This produces hash corresponding * to the one signed with the * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`] * JSON-RPC method as part of EIP-712. * * See {recover}. */ function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) { return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash)); } } // File openzeppelin-contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol // OpenZeppelin Contracts v4.4.0 (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; /** * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data. * * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible, * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding * they need in their contracts using a combination of `abi.encode` and `keccak256`. * * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA * ({_hashTypedDataV4}). * * The implementation of the domain separator was designed to be as efficient as possible while still properly updating * the chain id to protect against replay attacks on an eventual fork of the chain. * * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask]. * * _Available since v3.4._ */ abstract contract EIP712Upgradeable is Initializable { /* solhint-disable var-name-mixedcase */ bytes32 private _HASHED_NAME; bytes32 private _HASHED_VERSION; bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"); /* solhint-enable var-name-mixedcase */ /** * @dev Initializes the domain separator and parameter caches. * * The meaning of `name` and `version` is specified in * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]: * * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol. * - `version`: the current major version of the signing domain. * * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart * contract upgrade]. */ function __EIP712_init(string memory name, string memory version) internal initializer { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal initializer { bytes32 hashedName = keccak256(bytes(name)); bytes32 hashedVersion = keccak256(bytes(version)); _HASHED_NAME = hashedName; _HASHED_VERSION = hashedVersion; } /** * @dev Returns the domain separator for the current chain. */ function _domainSeparatorV4() internal view returns (bytes32) { return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash()); } function _buildDomainSeparator( bytes32 typeHash, bytes32 nameHash, bytes32 versionHash ) private view returns (bytes32) { return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this))); } /** * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this * function returns the hash of the fully encoded EIP712 message for this domain. * * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example: * * ```solidity * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode( * keccak256("Mail(address to,string contents)"), * mailTo, * keccak256(bytes(mailContents)) * ))); * address signer = ECDSA.recover(digest, signature); * ``` */ function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) { return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash); } /** * @dev The hash of the name parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712NameHash() internal virtual view returns (bytes32) { return _HASHED_NAME; } /** * @dev The hash of the version parameter for the EIP712 domain. * * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs * are a concern. */ function _EIP712VersionHash() internal virtual view returns (bytes32) { return _HASHED_VERSION; } uint256[50] private __gap; } // File contracts/utils/EIP712Custom.sol // contracts/Market.sol pragma solidity ^0.8.0; /// @title Contract for game Item sale /// @notice User can use this contract for selling and buying game Items /// @dev this's an upgradeable contract with creating item for sale, selling and unlisting gameItem from sale /// @dev Marketplace is inheriting from IMarketplace and EIP712Upgradeable contract EIP712Custom is EIP712Upgradeable { error IncorrectSigner(address signer); error DeadlineExpired(uint256 deadline, uint256 currentTimestamp); } // File contracts/interfaces/IGameItem.sol pragma solidity ^0.8.0; /// @notice Interface for GameItemContract interface IGameItem { /// @notice this event is emitted when NFT GameItem is minted /// @param to new owner of GameItem /// @param tokenID id ow new GameItem /// @param quality quality(0-4) of new GameItem /// @param seasonID BattlePass season of new GameItem /// @param hacker the hacker who minted this item event Minted( address indexed to, uint256 indexed tokenID, uint8 quality, uint256 seasonID, address hacker); event MintedForUser( address indexed to, uint256 indexed tokenID, uint8 quality, uint256 financialWalletPayment, uint256 seasonID, address hacker); function version() external view returns (uint32); /// @notice gets creator's address of specific GameItem /// @param _tokenID token id of specific GameItem /// @return minter's address function getItemCreator(uint256 _tokenID) external view returns(address); /// @notice gets (hacker) address of specific GameItem /// @param _tokenID token id of specific GameItem /// @return hacker's address function getItemHacker(uint256 _tokenID) external view returns(address); /// @notice gets validator's(hacker) address of specific GameItem /// @param _tokenID token id of specific GameItem /// @return validator's address function getItemValidator(uint256 _tokenID) external view returns(uint256); /// @notice gets quality of specific GameItem /// @param _tokenID token id of specific GameItem /// @return uint8 parameter. quality of GameItem function getItemQuality(uint256 _tokenID) external view returns(uint8); /// @notice gets season of specific GameItem /// @param _tokenID token id of specific GameItem /// @return uint256 parameter. season id function getItemSeason(uint256 _tokenID) external view returns(uint256); /// @notice gets market state of specific GameItem /// @param _tokenID token id of specific GameItem /// @return uint8 parameter. Market state of GameItem function getItemState(uint256 _tokenID) external view returns(uint8); /// @notice changes market state of specific GameItem /// @param _tokenID token id of specific GameItem /// @param _state (0-2) new item state function changeItemState(uint256 _tokenID, uint8 _state) external; /// @notice mints new GameItem /// @dev can be called only via DataCubeContract or ValidatorLicenseContract /// @dev emits "Minted" event /// @param _receiver receiver's address of new GameItem /// @param _VLTokenID token id of specific ValidatorLicense /// @param _seasonID token id of season /// @param _DCQuality quality of new GameItem /// @param _metadataURL URL to metadata storage function mintFromCube( address _receiver, uint256 _VLTokenID, uint256 _seasonID, uint8 _DCQuality, string memory _metadataURL) external; /// @notice mints new GameItem /// @dev can be called by user, with signature /// @dev sends GUNs to this contract address /// @param _VLTokenID token id of specific ValidatorLicense /// @param _seasonID token id of season /// @param _quality quality of new GameItem /// @param _price price(in GUNs) od DataCube decoding /// @param _metadataURL URL to metadata storage function mintForUser( uint256 _VLTokenID, uint256 _seasonID, uint8 _quality, uint256 _price, string memory _metadataURL, address receiver) payable external; function burn(uint256 _tokenID) external; function bridgeBurn(uint256 _tokenID) external; function bridgeMint(address to, uint256 _tokenID) external; } // File contracts/interfaces/IMarketplace.sol pragma solidity ^0.8.0; /// @notice Interface for Marketplace interface IMarketplace { function version() external view returns (uint32); /// @notice the user creates MarketItem and set gameItem for sale /// @dev Emits "MarketItemCreated" event. Requirements: price must be more or equal to floorPrice; msg.value must be equal to itemCreateFee; the signer must have BACKEND_ROLE /// @dev if _battlePassFlag is false then floorPrice must be more or equal to battlePassFee /// @dev calls transferFrom function from ERC721Upgradeable contract /// @param _tokenId Id of NFT in the gameItemContract /// @param _price The price of item /// @param _floorPrice Floor price calculation includes all costs related to the item placed on the marketplace. /// @param _payer The lever which controls if the price includes fee or it must be paid above /// @param _battlePassFlag Value that shows if the item was created with battlePass or not /// @param _saleDuration duration of the sale of the item(in unix time) /// @param _deadline date of expiring signature(in unix time) /// @param _signature The signature that verifies all the data above by BACKEND signer function createMarketItem( uint256 _tokenId, uint256 _price, uint256 _floorPrice, bool _payer, bool _battlePassFlag, uint256 _saleDuration, uint256 _deadline, bytes memory _signature) external payable; /// @notice the user unlist Item from sale /// @dev Requirements: the caller of this function must be the seller or the admin; the signer must have BACKEND_ROLE /// @dev calls transferFrom function from ERC721Upgradeable contract /// @param _itemId Id of MarketItem. /// @param _deadline date of expiring signature(in unix time) /// @param _signature The signature that verifies all the data above by BACKEND signer function unlistMarketItem( uint256 _itemId, uint256 _deadline, bytes memory _signature ) external; /// @notice the user buy the Item /// @dev Emits "MarketItemSale" event. Requirements: the signer must have BACKEND_ROLE /// @dev calls _makeFeePayment function from Marketplace contract; calls _createMarketTransfer function from Marketplace contract /// @param _itemId Id of MarketItem. /// @param _deadline date of expiring signature(in unix time) /// @param _signature The signature that verifies all the data above by BACKEND signer function createMarketSale( uint256 _itemId, uint256 _deadline, bytes memory _signature ) external payable; } // File openzeppelin-contracts-upgradeable/access/IAccessControlUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (access/IAccessControl.sol) pragma solidity ^0.8.0; /** * @dev External interface of AccessControl declared to support ERC165 detection. */ interface IAccessControlUpgradeable { /** * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole` * * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite * {RoleAdminChanged} not being emitted signaling this. * * _Available since v3.1._ */ event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole); /** * @dev Emitted when `account` is granted `role`. * * `sender` is the account that originated the contract call, an admin role * bearer except when using {AccessControl-_setupRole}. */ event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Emitted when `account` is revoked `role`. * * `sender` is the account that originated the contract call: * - if using `revokeRole`, it is the admin role bearer * - if using `renounceRole`, it is the role bearer (i.e. `account`) */ event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender); /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) external view returns (bool); /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {AccessControl-_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) external view returns (bytes32); /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) external; /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) external; /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been granted `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) external; } // File openzeppelin-contracts-upgradeable/access/AccessControlUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (access/AccessControl.sol) pragma solidity ^0.8.0; /** * @dev Contract module that allows children to implement role-based access * control mechanisms. This is a lightweight version that doesn't allow enumerating role * members except through off-chain means by accessing the contract event logs. Some * applications may benefit from on-chain enumerability, for those cases see * {AccessControlEnumerable}. * * Roles are referred to by their `bytes32` identifier. These should be exposed * in the external API and be unique. The best way to achieve this is by * using `public constant` hash digests: * * ``` * bytes32 public constant MY_ROLE = keccak256("MY_ROLE"); * ``` * * Roles can be used to represent a set of permissions. To restrict access to a * function call, use {hasRole}: * * ``` * function foo() public { * require(hasRole(MY_ROLE, msg.sender)); * ... * } * ``` * * Roles can be granted and revoked dynamically via the {grantRole} and * {revokeRole} functions. Each role has an associated admin role, and only * accounts that have a role's admin role can call {grantRole} and {revokeRole}. * * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means * that only accounts with this role will be able to grant or revoke other * roles. More complex role relationships can be created by using * {_setRoleAdmin}. * * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to * grant and revoke this role. Extra precautions should be taken to secure * accounts that have been granted it. */ abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable { function __AccessControl_init() internal initializer { __Context_init_unchained(); __ERC165_init_unchained(); __AccessControl_init_unchained(); } function __AccessControl_init_unchained() internal initializer { } struct RoleData { mapping(address => bool) members; bytes32 adminRole; } mapping(bytes32 => RoleData) private _roles; bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00; /** * @dev Modifier that checks that an account has a specific role. Reverts * with a standardized message including the required role. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ * * _Available since v4.1._ */ modifier onlyRole(bytes32 role) { _checkRole(role, _msgSender()); _; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev Returns `true` if `account` has been granted `role`. */ function hasRole(bytes32 role, address account) public view override returns (bool) { return _roles[role].members[account]; } /** * @dev Revert with a standard message if `account` is missing `role`. * * The format of the revert reason is given by the following regular expression: * * /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/ */ function _checkRole(bytes32 role, address account) internal view { if (!hasRole(role, account)) { revert( string( abi.encodePacked( "AccessControl: account ", StringsUpgradeable.toHexString(uint160(account), 20), " is missing role ", StringsUpgradeable.toHexString(uint256(role), 32) ) ) ); } } /** * @dev Returns the admin role that controls `role`. See {grantRole} and * {revokeRole}. * * To change a role's admin, use {_setRoleAdmin}. */ function getRoleAdmin(bytes32 role) public view override returns (bytes32) { return _roles[role].adminRole; } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _grantRole(role, account); } /** * @dev Revokes `role` from `account`. * * If `account` had been granted `role`, emits a {RoleRevoked} event. * * Requirements: * * - the caller must have ``role``'s admin role. */ function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) { _revokeRole(role, account); } /** * @dev Revokes `role` from the calling account. * * Roles are often managed via {grantRole} and {revokeRole}: this function's * purpose is to provide a mechanism for accounts to lose their privileges * if they are compromised (such as when a trusted device is misplaced). * * If the calling account had been revoked `role`, emits a {RoleRevoked} * event. * * Requirements: * * - the caller must be `account`. */ function renounceRole(bytes32 role, address account) public virtual override { require(account == _msgSender(), "AccessControl: can only renounce roles for self"); _revokeRole(role, account); } /** * @dev Grants `role` to `account`. * * If `account` had not been already granted `role`, emits a {RoleGranted} * event. Note that unlike {grantRole}, this function doesn't perform any * checks on the calling account. * * [WARNING] * ==== * This function should only be called from the constructor when setting * up the initial roles for the system. * * Using this function in any other way is effectively circumventing the admin * system imposed by {AccessControl}. * ==== * * NOTE: This function is deprecated in favor of {_grantRole}. */ function _setupRole(bytes32 role, address account) internal virtual { _grantRole(role, account); } /** * @dev Sets `adminRole` as ``role``'s admin role. * * Emits a {RoleAdminChanged} event. */ function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual { bytes32 previousAdminRole = getRoleAdmin(role); _roles[role].adminRole = adminRole; emit RoleAdminChanged(role, previousAdminRole, adminRole); } /** * @dev Grants `role` to `account`. * * Internal function without access restriction. */ function _grantRole(bytes32 role, address account) internal virtual { if (!hasRole(role, account)) { _roles[role].members[account] = true; emit RoleGranted(role, account, _msgSender()); } } /** * @dev Revokes `role` from `account`. * * Internal function without access restriction. */ function _revokeRole(bytes32 role, address account) internal virtual { if (hasRole(role, account)) { _roles[role].members[account] = false; emit RoleRevoked(role, account, _msgSender()); } } uint256[49] private __gap; } // File openzeppelin-contracts-upgradeable/security/PausableUpgradeable.sol // OpenZeppelin Contracts v4.4.0 (security/Pausable.sol) pragma solidity ^0.8.0; /** * @dev Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * * This module is used through inheritance. It will make available the * modifiers `whenNotPaused` and `whenPaused`, which can be applied to * the functions of your contract. Note that they will not be pausable by * simply including this module, only once the modifiers are put in place. */ abstract contract PausableUpgradeable is Initializable, ContextUpgradeable { /** * @dev Emitted when the pause is triggered by `account`. */ event Paused(address account); /** * @dev Emitted when the pause is lifted by `account`. */ event Unpaused(address account); bool private _paused; /** * @dev Initializes the contract in unpaused state. */ function __Pausable_init() internal initializer { __Context_init_unchained(); __Pausable_init_unchained(); } function __Pausable_init_unchained() internal initializer { _paused = false; } /** * @dev Returns true if the contract is paused, and false otherwise. */ function paused() public view virtual returns (bool) { return _paused; } /** * @dev Modifier to make a function callable only when the contract is not paused. * * Requirements: * * - The contract must not be paused. */ modifier whenNotPaused() { require(!paused(), "Pausable: paused"); _; } /** * @dev Modifier to make a function callable only when the contract is paused. * * Requirements: * * - The contract must be paused. */ modifier whenPaused() { require(paused(), "Pausable: not paused"); _; } /** * @dev Triggers stopped state. * * Requirements: * * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { _paused = true; emit Paused(_msgSender()); } /** * @dev Returns to normal state. * * Requirements: * * - The contract must be paused. */ function _unpause() internal virtual whenPaused { _paused = false; emit Unpaused(_msgSender()); } uint256[49] private __gap; } // File contracts/PlatformSettings.sol //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; /// @title A platform settings for OTG contracts /// @notice Admin can use this contract for granting and revoking roles, pause and unpause platform, set new wallets for fee receiving /// @dev This contract inherits 'Initializable', 'AccessControlUpgradeable', 'PausableUpgradeable' contracts form openzeppelin library contract PlatformSettings is Initializable, AccessControlUpgradeable, PausableUpgradeable{ bytes32 public constant SECONDARY_ADMIN_ROLE = keccak256("SECONDARY_ADMIN_ROLE"); bytes32 public constant BACKEND_ROLE = keccak256("BACKEND_ROLE"); uint256 public constant gunDecimals = 10**18; uint256 public constant PERCENT_DENOMINATOR = 100; // address of main admin address public initialAdmin; // address of financial wallet (withdraws GUNs from contract) address payable public financialWallet; // percentage that represents validator fee during decoding process uint256 public validatorFeePercentageForDecoding; // percentage that represents platform fee during decoding process uint256 public platformFeePercentageForDecoding; bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE"); /// @notice this event is emitted when new financial wallet is set /// @param newWallet address of new financial wallet event newFinancialWallet( address indexed newWallet ); error InvalidRole(address caller, bytes32 role); error IncorrectFeeDistribution(); error AlreadyHasRole(address account, bytes32 role); error AlreadyHasNotRole(address account, bytes32 role); /// @notice A disposable function for initializing contract /// @param _admin address of initial admin of contract /// @dev Grants caller with admin role /// @dev Also calls initializers of AccessControl and Pausable contracts. /// @dev Sets caller as an initialAdmin and financeWallet(wallet for receiving fees and royalties) /// @dev Sets initial fee percentage for decoding process function initialize( address _admin )public initializer{ __AccessControl_init(); __Pausable_init_unchained(); _setupRole(DEFAULT_ADMIN_ROLE, _admin); initialAdmin = _admin; financialWallet = payable(msg.sender); validatorFeePercentageForDecoding = 50; platformFeePercentageForDecoding = 50; } // *********************** MODIFIERS ********************************************* /// @notice verifies if message sender is an admin or secondary admin modifier onlyAdmin{ if(!(hasRole(DEFAULT_ADMIN_ROLE, msg.sender) || hasRole(SECONDARY_ADMIN_ROLE,msg.sender))){ revert InvalidRole(msg.sender, SECONDARY_ADMIN_ROLE); } _; } // *********************** VIEW FUNCTIONS ********************************************* /// TODO restrict function visibility from view to pure function version() public pure returns (uint32){ //version in format aaa.bbb.ccc => aaa*1E6+bbb*1E3+ccc; return uint32(1000001); } // *********************** FUNCTIONS ********************************************* /// @notice checks account for admin roles function isAdmin(address account) public view returns(bool){ return (hasRole(DEFAULT_ADMIN_ROLE, account)||hasRole(SECONDARY_ADMIN_ROLE, account)); } /// @notice checks account for backend role function isBackendRole(address account) public view returns(bool){ return hasRole(BACKEND_ROLE, account); } function isBridgeRole(address account) public view returns(bool){ return hasRole(BRIDGE_ROLE, account); } /// @notice checks account for admin roles or if platform is not paused function isAdminOrNotPaused(address caller) public view returns(bool){ return(!paused()||hasRole(DEFAULT_ADMIN_ROLE,caller)||hasRole(SECONDARY_ADMIN_ROLE,caller)); } /// TODO check if this function must exist /// @notice returns a number, that represents amount of fee, which validator will receive after decoding process function getValidatorFeeForDecoding(uint256 _price)public view returns(uint256){ if((platformFeePercentageForDecoding + validatorFeePercentageForDecoding)!=100){ revert IncorrectFeeDistribution(); } return (_price* gunDecimals * validatorFeePercentageForDecoding)/PERCENT_DENOMINATOR; } /// TODO check if this function must exist /// @notice returns a number, that represents amount of fee, which financialWallet will receive after decoding process function getPlatformFeeForDecoding(uint256 _price)public view returns(uint256){ if((platformFeePercentageForDecoding + validatorFeePercentageForDecoding)!=100){ revert IncorrectFeeDistribution(); } return (_price* gunDecimals * platformFeePercentageForDecoding)/PERCENT_DENOMINATOR; } /// @notice suspends most functions in contracts /// @dev Caller must be admin function pause() public onlyAdmin{ _pause(); } /// @notice restores most functions in contracts /// @dev Caller must be admin function unpause() public onlyAdmin{ _unpause(); } /// @notice sets new address as a payable financialWallet /// @dev caller must be admin, emits 'newFinancialWallet' function setNewFinancialWallet(address _newWalletAddress) public onlyAdmin{ financialWallet = payable(_newWalletAddress); emit newFinancialWallet(_newWalletAddress); } /// @notice granting secondary admin role to a specific address /// @param account address of a specific account function grantSecondaryAdminRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(SECONDARY_ADMIN_ROLE, account)){ revert AlreadyHasRole(account, SECONDARY_ADMIN_ROLE); } grantRole(SECONDARY_ADMIN_ROLE, account); } /// @notice revoking secondary admin role from a specific address /// @param account address of a specific account function revokeSecondaryAdminRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(SECONDARY_ADMIN_ROLE, account)){ revert AlreadyHasNotRole(account, SECONDARY_ADMIN_ROLE); } revokeRole(SECONDARY_ADMIN_ROLE, account); } /// @notice granting backend admin role from a specific address /// @param account address of a specific account function grantBackendRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(BACKEND_ROLE, account)){ revert AlreadyHasRole(account, BACKEND_ROLE); } grantRole(BACKEND_ROLE, account); } /// @notice revoking backend admin role from a specific address /// @param account address of a specific account function revokeBackendRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(BACKEND_ROLE, account)){ revert AlreadyHasNotRole(account, BACKEND_ROLE); } revokeRole(BACKEND_ROLE, account); } function grantBridgeRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(hasRole(BRIDGE_ROLE, account)){ revert AlreadyHasRole(account, BRIDGE_ROLE); } grantRole(BRIDGE_ROLE, account); } function revokeBridgeRole(address account) public onlyRole(DEFAULT_ADMIN_ROLE){ if(!hasRole(BRIDGE_ROLE, account)){ revert AlreadyHasNotRole(account, BRIDGE_ROLE); } revokeRole(BRIDGE_ROLE, account); } /// TODO maybe it will be better, to set validatorFeePercentageForDecoding and platformFeePercentageForDecoding with one function /// @notice Sets a number, that represents amount of fee, which validator will receive after /// @dev caller must be admin function setValidatorFeePercentageForDecoding(uint256 _percentage) public onlyAdmin{ validatorFeePercentageForDecoding = _percentage; } /// @notice Sets a number, that represents amount of fee, which financialWallet will receive after /// @dev caller must be admin function setPlatformFeePercentageForDecoding(uint256 _percentage) public onlyAdmin{ platformFeePercentageForDecoding = _percentage; } // TODO DEPRECATED, will be deleted sooner function getValidatorFeePercentageForDecoding() external view returns(uint256){ return(validatorFeePercentageForDecoding); } // TODO DEPRECATED, will be deleted sooner function getPlatformFeePercentageForDecoding() external view returns(uint256){ return(platformFeePercentageForDecoding); } } // File contracts/Marketplace.sol // contracts/Market.sol pragma solidity ^0.8.0; /// @title Contract for game Item sale /// @notice User can use this contract for selling and buying game Items /// @dev this's an upgradeable contract with creating item for sale, selling and unlisting gameItem from sale /// @dev Marketplace is inheriting from IMarketplace and EIP712Upgradeable contract Marketplace is IMarketplace, EIP712Custom { using CountersUpgradeable for CountersUpgradeable.Counter; // address for GameItem contract address public gameItem; // address for validatorLicenseContract address public validatorLicenseContract; // address for platformSettingsContractAddress address public platformSettingsContractAddress; // % fee for sale Item and it sends to financialWallet uint256 public marketFee; // % fee for sale Item and it sends to the validator uint256 public validatorFee; // % fee for sale Item and it sends to user who created item uint256 public firstMinterFee; // fee for create Item for sale and it sends to financialWallet uint256 public itemCreateFee; // fee for sale Item which was created without battlePass and it sends to the validator uint256 public battlePassFee; // variable that controls fee percentages uint256 public percentage; // variable that lists the items that were created for sale CountersUpgradeable.Counter private _itemIds; // structure of MarketItem // itemId - id of MarketItem, nftContract - address of NFT item, tokenId - id of NFT, seller - the seller's address, owner - the address of item owner, price - the price of item, sold - value that shows if the sale was made or not, payer - the lever which controls if the price includes fee or it must be paid above, battlePassFlag - value that shows if the item was created with battlePass or not struct MarketItem { uint256 itemId; address nftContract; uint256 tokenId; address payable seller; address owner; uint256 price; bool sold; bool payer; bool battlePassFlag; uint256 deadline; } // uint to MarketItem mapping(uint256 => MarketItem) private idToMarketItem; /// @notice This event is emitted when a marketItem are created. /// @param itemId Id of MarketItem. /// @param nftContract The address of NFT item. /// @param tokenId Id of NFT. /// @param seller The seller's address. /// @param owner The address of item owner. /// @param price The price of item. /// @param sold Value that shows if the sale was made or not. /// @param payer The lever which controls if the price includes fee or it must be paid above. /// @param battlePassFlag Value that shows if the item was created with battlePass or not. /// @param saleDeadline The deadline of the item sale(in unix time) /// @param itemCreateFee fee that payed for item creation to the financialWallet event MarketItemCreated ( uint256 indexed itemId, address indexed nftContract, uint256 indexed tokenId, address seller, address owner, uint256 price, bool sold, bool payer, bool battlePassFlag, uint256 saleDeadline, uint256 itemCreateFee ); /// DEPRECATED WILL BE DELETED event MarketItemChangePrice ( address indexed nftContract, uint256 indexed itemId, uint256 newPrice ); /// @notice This event is emitted when a gameItem was sold. /// @param nftContract The address of NFT item. /// @param itemId Id of MarketItem. /// @param buyer The buyer's address. /// @param price The price of item. event MarketItemSale ( address indexed nftContract, uint256 indexed itemId, address buyer, uint256 price ); event FeePaymentForSale ( address financialWallet, uint256 marketPayment, address validator, uint256 validatorPayment, address itemCreator, uint256 itemCreatorPayment, address seller, uint256 sellerPayment ); error InvalidRole(address caller, bytes32 role); error IncorrectFloorPrice(uint256 floorPrice, uint256 minValue); error IncorrectPrice(uint256 price, uint256 floorPrice); error IncorrectValue(uint256 value, uint256 price); error UnsuccessfulPayment(address from, address to, uint256 amount); error IncorrectCaller(address caller); error ItemDeadlineExpired(uint256 deadline, uint256 currentTimestamp); error ItemSold(); error IncorrectFeeDistribution(); /// @notice A disposable function for initializing contract /// @param _gameItem address of GameItemContract /// @param _platformSettingsContractAddress address of PlatformSettings contract /// @param _validatorLicenseContract address of ValidatorLicenseContract contract /// @param _marketFee % fee for sale Item and it sends to financialWallet(it must be given relative to the percentage) /// @param _validatorFee % fee for sale Item and it sends to the validator(it must be given relative to the percentage) /// @param _firstMinterFee % fee for sale Item and it sends to user who created item(it must be given relative to the percentage) /// @param _itemCreateFee fee for create Item for sale and it sends to financialWallet /// @param _battlePassFee fee for sale Item which was created without battlePass and it sends to the validator function initialize( address _gameItem, address _platformSettingsContractAddress, address _validatorLicenseContract, uint256 _marketFee, uint256 _validatorFee, uint256 _firstMinterFee, uint256 _itemCreateFee, uint256 _battlePassFee ) public initializer { __EIP712_init_unchained('Marketplace','1'); gameItem = _gameItem; platformSettingsContractAddress = _platformSettingsContractAddress; validatorLicenseContract = _validatorLicenseContract; marketFee = _marketFee; validatorFee = _validatorFee; firstMinterFee = _firstMinterFee; itemCreateFee = _itemCreateFee; battlePassFee = _battlePassFee; percentage = 1000; } // *********************** MODIFIERS ********************************************* /// @notice verifies if message sender is an admin or secondary admin modifier onlyAdmin{ if(!(PlatformSettings(platformSettingsContractAddress).hasRole(PlatformSettings(platformSettingsContractAddress).DEFAULT_ADMIN_ROLE(),msg.sender)||PlatformSettings(platformSettingsContractAddress).hasRole(PlatformSettings(platformSettingsContractAddress).SECONDARY_ADMIN_ROLE(),msg.sender))){ revert InvalidRole(msg.sender, PlatformSettings(platformSettingsContractAddress).SECONDARY_ADMIN_ROLE()); } _; } // *********************** VIEW FUNCTIONS ********************************************* function version() public override pure returns (uint32){ //version in format aaa.bbb.ccc => aaa*1E6+bbb*1E3+ccc; return uint32(1000000); } /// @notice gets NFT id of GameItem /// @param _itemId Id of MarketItem. function getTokenId(uint256 _itemId) public view returns(uint256){ return idToMarketItem[_itemId].tokenId; } /// @notice gets price of GameItem /// @param _itemId Id of MarketItem. function getItemPrice(uint256 _itemId) public view returns(uint256){ return idToMarketItem[_itemId].price; } /// @notice gets address of item seller /// @param _itemId Id of MarketItem. function getItemSeller(uint256 _itemId) public view returns(address){ return idToMarketItem[_itemId].seller; } /// @notice gets address of item owner /// @param _itemId Id of MarketItem. function getItemOwner(uint256 _itemId) public view returns(address){ return idToMarketItem[_itemId].owner; } /// @notice gets address of GameItem contract /// @param _itemId Id of MarketItem. function getItemNFTContract(uint256 _itemId) public view returns(address){ return idToMarketItem[_itemId].nftContract; } /// @notice gets deadline of item for sale /// @param _itemId Id of MarketItem. function getItemDeadline(uint256 _itemId) public view returns(uint256){ return idToMarketItem[_itemId].deadline; } /// @notice gets the full price of the item it depends by payer /// @param _itemId Id of MarketItem. function getItemFullPrice(uint256 _itemId) public view returns(uint256){ if (idToMarketItem[_itemId].payer){ return idToMarketItem[_itemId].price; } else { uint256 price = idToMarketItem[_itemId].price; uint256 marketPayment = (price * marketFee)/percentage; uint256 validatorPayment = (price * validatorFee)/percentage; uint256 itemCreatorPayment = (price * firstMinterFee)/percentage; return price + (marketPayment + validatorPayment + itemCreatorPayment); } } // *********************** FUNCTIONS ********************************************* /// @notice Admin sets new marketFee function setMarketFee(uint256 _marketFee) public onlyAdmin{ marketFee = _marketFee; } /// @notice Admin sets new validatorFee function setValidatorFee(uint256 _validatorFee) public onlyAdmin{ validatorFee = _validatorFee; } /// @notice Admin sets new firstMinterFee function setFirstMinterFee(uint256 _firstMinterFee) public onlyAdmin{ firstMinterFee = _firstMinterFee; } /// @notice Admin sets new itemCreateFee function setItemCreateFee(uint256 _itemCreateFee) public onlyAdmin{ itemCreateFee = _itemCreateFee; } /// @notice Admin sets new percentage function setPercentage(uint256 _percentage) public onlyAdmin{ percentage = _percentage; } /// @notice Admin sets new battlePassFee function setBattlePassFee(uint256 _battlePassFee) public onlyAdmin{ battlePassFee = _battlePassFee; } /// @notice the user creates MarketItem and set gameItem for sale /// @dev Emits "MarketItemCreated" event. Requirements: price must be more or equal to floorPrice; msg.value must be equal to itemCreateFee; the signer must have BACKEND_ROLE /// @dev if _battlePassFlag is false then floorPrice must be more or equal to battlePassFee /// @dev calls transferFrom function from ERC721Upgradeable contract /// @param _tokenId Id of NFT in the gameItemContract /// @param _price The price of item /// @param _floorPrice Floor price calculation includes all costs related to the item placed on the marketplace. /// @param _payer The lever which controls if the price includes fee or it must be paid above /// @param _battlePassFlag Value that shows if the item was created with battlePass or not /// @param _saleDuration duration of the sale of the item(in unix time) /// @param _deadline date of expiring signature(in unix time) /// @param _signature The signature that verifies all the data above by BACKEND signer function createMarketItem( uint256 _tokenId, uint256 _price, uint256 _floorPrice, bool _payer, bool _battlePassFlag, uint256 _saleDuration, uint256 _deadline, bytes memory _signature ) public override payable { bytes32 __digest = _hashTypedDataV4( keccak256( abi.encode( keccak256("CreateMarketItem(uint256 _tokenId,uint256 _price,uint256 _floorPrice,bool _payer,bool _battlePassFlag,uint256 _saleDuration,uint256 _deadline)"), _tokenId, _price, _floorPrice, _payer, _battlePassFlag, _saleDuration, _deadline ) ) ); address __signer = ECDSAUpgradeable.recover(__digest,_signature); if(!PlatformSettings(platformSettingsContractAddress).isBackendRole(__signer)){ revert IncorrectSigner(__signer); } if(block.timestamp > _deadline){ revert DeadlineExpired(_deadline, block.timestamp); } if(!_battlePassFlag && _floorPrice < battlePassFee){ revert IncorrectFloorPrice(_floorPrice, battlePassFee); } if(_price < _floorPrice){ revert IncorrectPrice(_price, _floorPrice); } _itemIds.increment(); uint256 itemId = _itemIds.current(); uint256 saleDeadline = block.timestamp + _saleDuration; { if(msg.value != itemCreateFee){ revert IncorrectValue(msg.value, itemCreateFee); } address payable financialWallet = PlatformSettings(platformSettingsContractAddress).financialWallet(); (bool success,) = financialWallet.call{value: msg.value}(""); if(!success){ revert UnsuccessfulPayment(address(this), financialWallet, msg.value); } } IERC721Upgradeable(gameItem).transferFrom(msg.sender, address(this), _tokenId); _createMarketItem(itemId, _tokenId, _price, _payer, _battlePassFlag, saleDeadline); } /// @notice the user unlist Item from sale /// @dev Requirements: the caller of this function must be the seller or the admin; the signer must have BACKEND_ROLE /// @dev calls transferFrom function from ERC721Upgradeable contract /// @param _itemId Id of MarketItem. /// @param _deadline date of expiring signature(in unix time) /// @param _signature The signature that verifies all the data above by BACKEND signer function unlistMarketItem( uint256 _itemId, uint256 _deadline, bytes memory _signature ) public override { bytes32 __digest = _hashTypedDataV4( keccak256( abi.encode( keccak256("UnlistMarketItem(uint256 _itemId,uint256 _deadline)"), _itemId, _deadline ) ) ); address __signer = ECDSAUpgradeable.recover(__digest,_signature); if(!PlatformSettings(platformSettingsContractAddress).isBackendRole(__signer)){ revert IncorrectSigner(__signer); } if(block.timestamp > _deadline){ revert DeadlineExpired(_deadline, block.timestamp); } if( msg.sender != idToMarketItem[_itemId].seller && !PlatformSettings(platformSettingsContractAddress).hasRole(PlatformSettings(platformSettingsContractAddress).DEFAULT_ADMIN_ROLE(),msg.sender) && !PlatformSettings(platformSettingsContractAddress).hasRole(PlatformSettings(platformSettingsContractAddress).SECONDARY_ADMIN_ROLE(), msg.sender) ){ revert IncorrectCaller(msg.sender); } if(idToMarketItem[_itemId].sold == true){ revert ItemSold(); } uint256 tokenId = idToMarketItem[_itemId].tokenId; idToMarketItem[_itemId].owner = idToMarketItem[_itemId].seller; IERC721Upgradeable(gameItem).transferFrom(address(this), idToMarketItem[_itemId].seller , tokenId); } /// @notice the user buy the Item /// @dev Emits "MarketItemSale" event. Requirements: the signer must have BACKEND_ROLE /// @dev calls _makeFeePayment function from Marketplace contract; calls _createMarketTransfer function from Marketplace contract /// @param _itemId Id of MarketItem. /// @param _deadline date of expiring signature(in unix time) /// @param _signature The signature that verifies all the data above by BACKEND signer function createMarketSale( uint256 _itemId, uint256 _deadline, bytes memory _signature ) public override payable { bytes32 __digest = _hashTypedDataV4( keccak256( abi.encode( keccak256("createMarketSale(uint256 _itemId,uint256 _deadline)"), _itemId, _deadline ) ) ); address __signer = ECDSAUpgradeable.recover(__digest,_signature); if(!PlatformSettings(platformSettingsContractAddress).isBackendRole(__signer)){ revert IncorrectSigner(__signer); } if(block.timestamp > _deadline){ revert DeadlineExpired(_deadline, block.timestamp); } MarketItem memory item = idToMarketItem[_itemId]; uint256 tokenId = item.tokenId; uint256 price = item.price; bool battlePassFlag = item.battlePassFlag; if(block.timestamp > item.deadline){ revert ItemDeadlineExpired(item.deadline, block.timestamp); } if(item.owner != address(this)){ revert ItemSold(); } address buyer = msg.sender; _makeFeePayment(item, tokenId, price, battlePassFlag); _createMarketTransfer(_itemId, buyer); emit MarketItemSale( gameItem, _itemId, buyer, price ); } /// @dev transfer gameItem from seller to buyer /// @dev calls transferFrom function from Marketplace contract; calls _createMarketTransfer function from Marketplace contract /// @param _itemId Id of MarketItem. /// @param _buyer The buyer's address. function _createMarketTransfer( uint256 _itemId, address _buyer ) internal virtual { MarketItem memory item = idToMarketItem[_itemId]; uint256 tokenId = item.tokenId; IERC721Upgradeable(gameItem).transferFrom(address(this), msg.sender, tokenId); idToMarketItem[_itemId].owner = _buyer; idToMarketItem[_itemId].sold = true; } /// @dev buyer pays fee and price for the item /// @dev Requirements: msg.value must be equal to price if payer is true if else then msg.value must be equal to price + marketPayment + validatorPayment + itemCreatorPayment /// @dev calls transferFrom function from Marketplace contract; calls _createMarketTransfer function from Marketplace contract /// @dev _battlePassFlag is false then seller pays from price battlePassFee to the validator /// @param _item MarketItem. /// @param _tokenId Id of NFT in the gameItemContract /// @param _price The price of item /// @param _battlePassFlag Value that shows if the item was created with battlePass or not function _makeFeePayment( MarketItem memory _item, uint256 _tokenId, uint256 _price, bool _battlePassFlag ) internal virtual { address payable seller = _item.seller; address payable itemCreator = payable (IGameItem(gameItem).getItemCreator(_tokenId)); address payable validator = payable (IGameItem(gameItem).getItemHacker(_tokenId)); address payable financialWallet = PlatformSettings(platformSettingsContractAddress).financialWallet(); { uint256 marketPayment = (_price * marketFee)/percentage; uint256 validatorPayment = (_price * validatorFee)/percentage; uint256 itemCreatorPayment = (_price * firstMinterFee)/percentage; if(_price < (marketPayment + validatorPayment + itemCreatorPayment)){ revert IncorrectFeeDistribution(); } uint256 sellerPayment = _price; if(_item.payer){ sellerPayment = sellerPayment - (marketPayment + validatorPayment + itemCreatorPayment); } if(msg.value != sellerPayment + marketPayment + validatorPayment + itemCreatorPayment){ revert IncorrectValue(msg.value, sellerPayment + marketPayment + validatorPayment + itemCreatorPayment); } bool success; if(!_battlePassFlag){ sellerPayment = sellerPayment - battlePassFee; (success,) = financialWallet.call{value: battlePassFee}(""); if(!success){ revert UnsuccessfulPayment(address(this), financialWallet, battlePassFee); } } (success,) = seller.call{value: sellerPayment}(""); if(!success){ revert UnsuccessfulPayment(address(this), seller, sellerPayment); } (success,) = validator.call{value: validatorPayment}(""); if(!success){ revert UnsuccessfulPayment(address(this), validator, validatorPayment); } (success,) = financialWallet.call{value: marketPayment}(""); if(!success){ revert UnsuccessfulPayment(address(this), financialWallet, marketPayment); } (success,) = itemCreator.call{value: itemCreatorPayment}(""); if(!success){ revert UnsuccessfulPayment(address(this), itemCreator, itemCreatorPayment); } if(!_battlePassFlag){ marketPayment += battlePassFee; } emit FeePaymentForSale( financialWallet, marketPayment, validator, validatorPayment, itemCreator, itemCreatorPayment, seller, sellerPayment ); } } function _createMarketItem( uint256 _itemId, uint256 _tokenId, uint256 _price, bool _payer, bool _battlePassFlag, uint256 _saleDeadline ) internal virtual { idToMarketItem[_itemId] = MarketItem( _itemId, gameItem, _tokenId, payable (msg.sender), address(this), _price, false, _payer, _battlePassFlag, _saleDeadline ); emit MarketItemCreated( _itemId, gameItem, _tokenId, msg.sender, address(this), _price, false, _payer, _battlePassFlag, _saleDeadline, itemCreateFee ); } }
Contract ABI
[{"type":"error","name":"DeadlineExpired","inputs":[{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"uint256","name":"currentTimestamp","internalType":"uint256"}]},{"type":"error","name":"IncorrectCaller","inputs":[{"type":"address","name":"caller","internalType":"address"}]},{"type":"error","name":"IncorrectFeeDistribution","inputs":[]},{"type":"error","name":"IncorrectFloorPrice","inputs":[{"type":"uint256","name":"floorPrice","internalType":"uint256"},{"type":"uint256","name":"minValue","internalType":"uint256"}]},{"type":"error","name":"IncorrectPrice","inputs":[{"type":"uint256","name":"price","internalType":"uint256"},{"type":"uint256","name":"floorPrice","internalType":"uint256"}]},{"type":"error","name":"IncorrectSigner","inputs":[{"type":"address","name":"signer","internalType":"address"}]},{"type":"error","name":"IncorrectValue","inputs":[{"type":"uint256","name":"value","internalType":"uint256"},{"type":"uint256","name":"price","internalType":"uint256"}]},{"type":"error","name":"InvalidRole","inputs":[{"type":"address","name":"caller","internalType":"address"},{"type":"bytes32","name":"role","internalType":"bytes32"}]},{"type":"error","name":"ItemDeadlineExpired","inputs":[{"type":"uint256","name":"deadline","internalType":"uint256"},{"type":"uint256","name":"currentTimestamp","internalType":"uint256"}]},{"type":"error","name":"ItemSold","inputs":[]},{"type":"error","name":"UnsuccessfulPayment","inputs":[{"type":"address","name":"from","internalType":"address"},{"type":"address","name":"to","internalType":"address"},{"type":"uint256","name":"amount","internalType":"uint256"}]},{"type":"event","name":"FeePaymentForSale","inputs":[{"type":"address","name":"financialWallet","internalType":"address","indexed":false},{"type":"uint256","name":"marketPayment","internalType":"uint256","indexed":false},{"type":"address","name":"validator","internalType":"address","indexed":false},{"type":"uint256","name":"validatorPayment","internalType":"uint256","indexed":false},{"type":"address","name":"itemCreator","internalType":"address","indexed":false},{"type":"uint256","name":"itemCreatorPayment","internalType":"uint256","indexed":false},{"type":"address","name":"seller","internalType":"address","indexed":false},{"type":"uint256","name":"sellerPayment","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MarketItemChangePrice","inputs":[{"type":"address","name":"nftContract","internalType":"address","indexed":true},{"type":"uint256","name":"itemId","internalType":"uint256","indexed":true},{"type":"uint256","name":"newPrice","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MarketItemCreated","inputs":[{"type":"uint256","name":"itemId","internalType":"uint256","indexed":true},{"type":"address","name":"nftContract","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"address","name":"seller","internalType":"address","indexed":false},{"type":"address","name":"owner","internalType":"address","indexed":false},{"type":"uint256","name":"price","internalType":"uint256","indexed":false},{"type":"bool","name":"sold","internalType":"bool","indexed":false},{"type":"bool","name":"payer","internalType":"bool","indexed":false},{"type":"bool","name":"battlePassFlag","internalType":"bool","indexed":false},{"type":"uint256","name":"saleDeadline","internalType":"uint256","indexed":false},{"type":"uint256","name":"itemCreateFee","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"event","name":"MarketItemSale","inputs":[{"type":"address","name":"nftContract","internalType":"address","indexed":true},{"type":"uint256","name":"itemId","internalType":"uint256","indexed":true},{"type":"address","name":"buyer","internalType":"address","indexed":false},{"type":"uint256","name":"price","internalType":"uint256","indexed":false}],"anonymous":false},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"battlePassFee","inputs":[]},{"type":"function","stateMutability":"payable","outputs":[],"name":"createMarketItem","inputs":[{"type":"uint256","name":"_tokenId","internalType":"uint256"},{"type":"uint256","name":"_price","internalType":"uint256"},{"type":"uint256","name":"_floorPrice","internalType":"uint256"},{"type":"bool","name":"_payer","internalType":"bool"},{"type":"bool","name":"_battlePassFlag","internalType":"bool"},{"type":"uint256","name":"_saleDuration","internalType":"uint256"},{"type":"uint256","name":"_deadline","internalType":"uint256"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"payable","outputs":[],"name":"createMarketSale","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"},{"type":"uint256","name":"_deadline","internalType":"uint256"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"firstMinterFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"gameItem","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getItemDeadline","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getItemFullPrice","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getItemNFTContract","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getItemOwner","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getItemPrice","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"getItemSeller","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"getTokenId","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"initialize","inputs":[{"type":"address","name":"_gameItem","internalType":"address"},{"type":"address","name":"_platformSettingsContractAddress","internalType":"address"},{"type":"address","name":"_validatorLicenseContract","internalType":"address"},{"type":"uint256","name":"_marketFee","internalType":"uint256"},{"type":"uint256","name":"_validatorFee","internalType":"uint256"},{"type":"uint256","name":"_firstMinterFee","internalType":"uint256"},{"type":"uint256","name":"_itemCreateFee","internalType":"uint256"},{"type":"uint256","name":"_battlePassFee","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"itemCreateFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"marketFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"percentage","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"platformSettingsContractAddress","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setBattlePassFee","inputs":[{"type":"uint256","name":"_battlePassFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setFirstMinterFee","inputs":[{"type":"uint256","name":"_firstMinterFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setItemCreateFee","inputs":[{"type":"uint256","name":"_itemCreateFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMarketFee","inputs":[{"type":"uint256","name":"_marketFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setPercentage","inputs":[{"type":"uint256","name":"_percentage","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setValidatorFee","inputs":[{"type":"uint256","name":"_validatorFee","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"unlistMarketItem","inputs":[{"type":"uint256","name":"_itemId","internalType":"uint256"},{"type":"uint256","name":"_deadline","internalType":"uint256"},{"type":"bytes","name":"_signature","internalType":"bytes"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"uint256","name":"","internalType":"uint256"}],"name":"validatorFee","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"validatorLicenseContract","inputs":[]},{"type":"function","stateMutability":"pure","outputs":[{"type":"uint32","name":"","internalType":"uint32"}],"name":"version","inputs":[]}]
Contract Creation Code
0x608060405234801561001057600080fd5b506131c8806100206000396000f3fe60806040526004361061019c5760003560e01c80635da4a1d3116100ec578063b8a0a8861161008a578063c6a319fa11610064578063c6a319fa146104db578063c78ad77f146104fb578063df8fa43014610511578063ff39e9c91461053157600080fd5b8063b8a0a88614610488578063be7b66a3146104a8578063bed4a4b9146104bb57600080fd5b806399540b51116100c657806399540b5114610406578063a917f66f14610419578063abba5a4c14610452578063abdb2f631461047257600080fd5b80635da4a1d3146103965780635e8e9cd6146103b657806391df3d3e146103d657600080fd5b806326b825d2116101595780634c4df870116101335780634c4df870146103125780634fc4a1ae1461034257806354fd4d501461035857806355460f811461037657600080fd5b806326b825d2146102a35780632785b911146102c35780633f6d8256146102fc57600080fd5b80630b3f55d2146101a15780630ccf2156146101c357806314ff5ea3146101ec578063163d36ba1461021c5780631d1440fd146102325780632374d2ae14610283575b600080fd5b3480156101ad57600080fd5b506101c16101bc366004612e94565b610551565b005b3480156101cf57600080fd5b506101d960385481565b6040519081526020015b60405180910390f35b3480156101f857600080fd5b506101d9610207366004612ee4565b6000908152603f602052604090206002015490565b34801561022857600080fd5b506101d9603a5481565b34801561023e57600080fd5b5061026b61024d366004612ee4565b6000908152603f60205260409020600401546001600160a01b031690565b6040516001600160a01b0390911681526020016101e3565b34801561028f57600080fd5b506101c161029e366004612ee4565b6109af565b3480156102af57600080fd5b506101c16102be366004612ee4565b610c58565b3480156102cf57600080fd5b5061026b6102de366004612ee4565b6000908152603f60205260409020600101546001600160a01b031690565b34801561030857600080fd5b506101d960395481565b34801561031e57600080fd5b506101d961032d366004612ee4565b6000908152603f602052604090206005015490565b34801561034e57600080fd5b506101d9603b5481565b34801561036457600080fd5b50604051620f424081526020016101e3565b34801561038257600080fd5b506101c1610391366004612ee4565b610e9f565b3480156103a257600080fd5b506101c16103b1366004612ee4565b6110e6565b3480156103c257600080fd5b5060355461026b906001600160a01b031681565b3480156103e257600080fd5b506101d96103f1366004612ee4565b6000908152603f602052604090206007015490565b6101c1610414366004612e94565b61132d565b34801561042557600080fd5b5061026b610434366004612ee4565b6000908152603f60205260409020600301546001600160a01b031690565b34801561045e57600080fd5b506101c161046d366004612ee4565b6115c6565b34801561047e57600080fd5b506101d9603c5481565b34801561049457600080fd5b506101c16104a3366004612ee4565b61180d565b6101c16104b6366004612f0b565b611a54565b3480156104c757600080fd5b506101d96104d6366004612ee4565b611dec565b3480156104e757600080fd5b5060375461026b906001600160a01b031681565b34801561050757600080fd5b506101d9603d5481565b34801561051d57600080fd5b506101c161052c366004612fb3565b611eb9565b34801561053d57600080fd5b5060365461026b906001600160a01b031681565b604080517fe733ae9f3cbed0032e619b793c461cc7a8094ef97c0d59e7ef699fe26e6584126020820152908101849052606081018390526000906105ae906080015b60405160208183030381529060405280519060200120611fcf565b905060006105bc8284612023565b6037546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b15801561060357600080fd5b505afa158015610617573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063b919061302a565b610668576040516333ffff9b60e01b81526001600160a01b03821660048201526024015b60405180910390fd5b83421115610692576040516302a07ebf60e31b81526004810185905242602482015260440161065f565b6000858152603f60205260409020600301546001600160a01b031633148015906107b357506037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561070457600080fd5b505afa158015610718573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073c919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561077957600080fd5b505afa15801561078d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b1919061302a565b155b80156108b657506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561080757600080fd5b505afa15801561081b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083f919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561087c57600080fd5b505afa158015610890573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b4919061302a565b155b156108d6576040516302c2c4c760e11b815233600482015260240161065f565b6000858152603f602052604090206006015460ff1615156001141561090e57604051630be82b4560e21b815260040160405180910390fd5b6000858152603f60205260409081902060028101546003820154600492830180546001600160a01b0319166001600160a01b0392831690811790915560355494516323b872dd60e01b81529294909116926323b872dd926109759230929091879101613067565b600060405180830381600087803b15801561098f57600080fd5b505af11580156109a3573d6000803e3d6000fd5b50505050505050505050565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b1580156109fc57600080fd5b505afa158015610a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a34919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610a7157600080fd5b505afa158015610a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa9919061302a565b80610ba957506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b158015610afc57600080fd5b505afa158015610b10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b34919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610b7157600080fd5b505afa158015610b85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba9919061302a565b610c53576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b505afa158015610c05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c29919061304e565b6040516316b4d34b60e31b81526001600160a01b039092166004830152602482015260440161065f565b603b55565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b158015610ca557600080fd5b505afa158015610cb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cdd919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d52919061302a565b80610e5257506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b158015610da557600080fd5b505afa158015610db9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ddd919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610e1a57600080fd5b505afa158015610e2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e52919061302a565b610e9a576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603855565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b158015610eec57600080fd5b505afa158015610f00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f24919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610f6157600080fd5b505afa158015610f75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f99919061302a565b8061109957506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b158015610fec57600080fd5b505afa158015611000573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611024919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561106157600080fd5b505afa158015611075573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611099919061302a565b6110e1576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603955565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561113357600080fd5b505afa158015611147573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156111a857600080fd5b505afa1580156111bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e0919061302a565b806112e057506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561123357600080fd5b505afa158015611247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156112a857600080fd5b505afa1580156112bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e0919061302a565b611328576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603d55565b604080517fb3eb797330dcba0b1770e63c28973d7dd4729e01cf8a0ac76b631057037b3bc060208201529081018490526060810183905260009061137390608001610593565b905060006113818284612023565b6037546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b1580156113c857600080fd5b505afa1580156113dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611400919061302a565b611428576040516333ffff9b60e01b81526001600160a01b038216600482015260240161065f565b83421115611452576040516302a07ebf60e31b81526004810185905242602482015260440161065f565b6000858152603f60209081526040918290208251610140810184528154815260018201546001600160a01b0390811693820193909352600282015493810184905260038201548316606082015260048201549092166080830152600581015460a08301819052600682015460ff808216151560c08601526101008083048216151560e087015262010000909204161515908401819052600790920154610120840181905292939290919042111561152c576101208401516040516399d30d2760e01b8152600481019190915242602482015260440161065f565b60808401516001600160a01b0316301461155957604051630be82b4560e21b815260040160405180910390fd5b3361156685858585612047565b6115708a82612606565b603554604080516001600160a01b038481168252602082018790528d9316917f38d3b35f9d1a01bdaf62d50358599208ee79c951b1dc12e1032b30a03411d919910160405180910390a350505050505050505050565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561161357600080fd5b505afa158015611627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561168857600080fd5b505afa15801561169c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c0919061302a565b806117c057506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561171357600080fd5b505afa158015611727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561178857600080fd5b505afa15801561179c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c0919061302a565b611808576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603c55565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561185a57600080fd5b505afa15801561186e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611892919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156118cf57600080fd5b505afa1580156118e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611907919061302a565b80611a0757506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561195a57600080fd5b505afa15801561196e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611992919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156119cf57600080fd5b505afa1580156119e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a07919061302a565b611a4f576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603a55565b604080517f5692fac64371a8b1a07bff8cdd3d83af7c5cca18d2f10e2de046b25d6235fcf46020820152908101899052606081018890526080810187905285151560a082015284151560c082015260e081018490526101008101839052600090611ac19061012001610593565b90506000611acf8284612023565b6037546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b158015611b1657600080fd5b505afa158015611b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4e919061302a565b611b76576040516333ffff9b60e01b81526001600160a01b038216600482015260240161065f565b83421115611ba0576040516302a07ebf60e31b81526004810185905242602482015260440161065f565b85158015611baf5750603c5488105b15611bdb57603c5460405163a9b53d8360e01b815261065f918a91600401918252602082015260400190565b87891015611c0657604051630145611560e21b8152600481018a90526024810189905260440161065f565b611c14603e80546001019055565b6000611c1f603e5490565b90506000611c2d87426130a1565b9050603b543414611c5e57603b54604051635928816d60e11b8152346004820152602481019190915260440161065f565b6037546040805163220ce7e760e21b815290516000926001600160a01b0316916388339f9c916004808301926020929190829003018186803b158015611ca357600080fd5b505afa158015611cb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cdb91906130b9565b90506000816001600160a01b03163460405160006040518083038185875af1925050503d8060008114611d2a576040519150601f19603f3d011682016040523d82523d6000602084013e611d2f565b606091505b5050905080611d5757308234604051634eb3d3e160e11b815260040161065f93929190613067565b5050603560009054906101000a90046001600160a01b03166001600160a01b03166323b872dd33308f6040518463ffffffff1660e01b8152600401611d9e93929190613067565b600060405180830381600087803b158015611db857600080fd5b505af1158015611dcc573d6000803e3d6000fd5b50505050611dde828d8d8c8c86612744565b505050505050505050505050565b6000818152603f6020526040812060060154610100900460ff1615611e2157506000908152603f602052604090206005015490565b6000828152603f6020526040812060050154603d54603854919291611e4690846130d6565b611e5091906130f5565b90506000603d5460395484611e6591906130d6565b611e6f91906130f5565b90506000603d54603a5485611e8491906130d6565b611e8e91906130f5565b905080611e9b83856130a1565b611ea591906130a1565b611eaf90856130a1565b9695505050505050565b600054610100900460ff1680611ed2575060005460ff16155b611eee5760405162461bcd60e51b815260040161065f90613117565b600054610100900460ff16158015611f10576000805461ffff19166101011790555b611f566040518060400160405280600b81526020016a4d61726b6574706c61636560a81b815250604051806040016040528060018152602001603160f81b81525061299c565b603580546001600160a01b03808c166001600160a01b031992831617909255603780548b841690831617905560368054928a169290911691909117905560388690556039859055603a849055603b839055603c8290556103e8603d558015611fc4576000805461ff00191690555b505050505050505050565b600061201d611fdc612a27565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b60008060006120328585612aa7565b9150915061203f81612b17565b509392505050565b60608401516035546040516362848c0f60e01b8152600481018690526000916001600160a01b0316906362848c0f9060240160206040518083038186803b15801561209157600080fd5b505afa1580156120a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120c991906130b9565b60355460405163f52d779f60e01b8152600481018890529192506000916001600160a01b039091169063f52d779f9060240160206040518083038186803b15801561211357600080fd5b505afa158015612127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214b91906130b9565b90506000603760009054906101000a90046001600160a01b03166001600160a01b03166388339f9c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561219d57600080fd5b505afa1580156121b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121d591906130b9565b90506000603d54603854886121ea91906130d6565b6121f491906130f5565b90506000603d546039548961220991906130d6565b61221391906130f5565b90506000603d54603a548a61222891906130d6565b61223291906130f5565b90508061223f83856130a1565b61224991906130a1565b89101561226957604051635d616c1360e01b815260040160405180910390fd5b60e08b0151899015612297578161228084866130a1565b61228a91906130a1565b6122949082613165565b90505b81836122a386846130a1565b6122ad91906130a1565b6122b791906130a1565b3414612300573482846122ca87856130a1565b6122d491906130a1565b6122de91906130a1565b604051635928816d60e11b81526004810192909252602482015260440161065f565b60008961239257603c546123149083613165565b603c546040519193506001600160a01b03881691600081818185875af1925050503d8060008114612361576040519150601f19603f3d011682016040523d82523d6000602084013e612366565b606091505b50508091505080612392573086603c54604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038a16908390600081818185875af1925050503d80600081146123db576040519150601f19603f3d011682016040523d82523d6000602084013e6123e0565b606091505b5050809150508061240a57308983604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038816908590600081818185875af1925050503d8060008114612453576040519150601f19603f3d011682016040523d82523d6000602084013e612458565b606091505b5050809150508061248257308785604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038716908690600081818185875af1925050503d80600081146124cb576040519150601f19603f3d011682016040523d82523d6000602084013e6124d0565b606091505b505080915050806124fa57308686604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038916908490600081818185875af1925050503d8060008114612543576040519150601f19603f3d011682016040523d82523d6000602084013e612548565b606091505b5050809150508061257257308884604051634eb3d3e160e11b815260040161065f93929190613067565b8961258757603c5461258490866130a1565b94505b604080516001600160a01b0388811682526020820188905289811682840152606082018790528a8116608083015260a082018690528b1660c082015260e0810184905290517f2a8ef2e78928f7009766e5f98d25725e2786c77f03522b580da350cfb2ad91cd918190036101000190a150505050505050505050505050565b6000828152603f60209081526040918290208251610140810184528154815260018201546001600160a01b0390811693820193909352600282015481850181905260038301548416606083015260048084015485166080840152600584015460a0840152600684015460ff808216151560c08601526101008083048216151560e0870152620100009092041615159084015260079093015461012083015260355494516323b872dd60e01b81529194909316916323b872dd916126cf9130913391879101613067565b600060405180830381600087803b1580156126e957600080fd5b505af11580156126fd573d6000803e3d6000fd5b50505060009485525050603f6020525060409091206004810180546001600160a01b0319166001600160a01b0390931692909217909155600601805460ff19166001179055565b604051806101400160405280878152602001603560009054906101000a90046001600160a01b03166001600160a01b03168152602001868152602001336001600160a01b03168152602001306001600160a01b031681526020018581526020016000151581526020018415158152602001831515815260200182815250603f60008881526020019081526020016000206000820151816000015560208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c08201518160060160006101000a81548160ff02191690831515021790555060e08201518160060160016101000a81548160ff0219169083151502179055506101008201518160060160026101000a81548160ff021916908315150217905550610120820151816007015590505084603560009054906101000a90046001600160a01b03166001600160a01b0316877f9d59d31d5753a7d709b23f2e99253ddfb2eba27384a2f54790290cc93d25c82f33308960008a8a8a603b5460405161298c9897969594939291906001600160a01b0398891681529690971660208701526040860194909452911515606085015215156080840152151560a083015260c082015260e08101919091526101000190565b60405180910390a4505050505050565b600054610100900460ff16806129b5575060005460ff16155b6129d15760405162461bcd60e51b815260040161065f90613117565b600054610100900460ff161580156129f3576000805461ffff19166101011790555b82516020808501919091208351918401919091206001919091556002558015612a22576000805461ff00191690555b505050565b6000612aa27f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f612a5660015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b600080825160411415612ade5760208301516040840151606085015160001a612ad287828585612cd5565b94509450505050612b10565b825160401415612b085760208301516040840151612afd868383612dc2565b935093505050612b10565b506000905060025b9250929050565b6000816004811115612b2b57612b2b61317c565b1415612b345750565b6001816004811115612b4857612b4861317c565b1415612b965760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161065f565b6002816004811115612baa57612baa61317c565b1415612bf85760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161065f565b6003816004811115612c0c57612c0c61317c565b1415612c655760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161065f565b6004816004811115612c7957612c7961317c565b1415612cd25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161065f565b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612d0c5750600090506003612db9565b8460ff16601b14158015612d2457508460ff16601c14155b15612d355750600090506004612db9565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612d89573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612db257600060019250925050612db9565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01612de387828885612cd5565b935093505050935093915050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612e1857600080fd5b813567ffffffffffffffff80821115612e3357612e33612df1565b604051601f8301601f19908116603f01168101908282118183101715612e5b57612e5b612df1565b81604052838152866020858801011115612e7457600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600060608486031215612ea957600080fd5b8335925060208401359150604084013567ffffffffffffffff811115612ece57600080fd5b612eda86828701612e07565b9150509250925092565b600060208284031215612ef657600080fd5b5035919050565b8015158114612cd257600080fd5b600080600080600080600080610100898b031215612f2857600080fd5b8835975060208901359650604089013595506060890135612f4881612efd565b94506080890135612f5881612efd565b935060a0890135925060c0890135915060e089013567ffffffffffffffff811115612f8257600080fd5b612f8e8b828c01612e07565b9150509295985092959890939650565b6001600160a01b0381168114612cd257600080fd5b600080600080600080600080610100898b031215612fd057600080fd5b8835612fdb81612f9e565b97506020890135612feb81612f9e565b96506040890135612ffb81612f9e565b979a96995096976060810135975060808101359660a0820135965060c0820135955060e0909101359350915050565b60006020828403121561303c57600080fd5b815161304781612efd565b9392505050565b60006020828403121561306057600080fd5b5051919050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601160045260246000fd5b600082198211156130b4576130b461308b565b500190565b6000602082840312156130cb57600080fd5b815161304781612f9e565b60008160001904831182151516156130f0576130f061308b565b500290565b60008261311257634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000828210156131775761317761308b565b500390565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220c2b2534154a575ddf6d6b3b8d36403fbc328837ac78500fa5c6e749ae654c36f64736f6c63430008090033
Deployed ByteCode
0x60806040526004361061019c5760003560e01c80635da4a1d3116100ec578063b8a0a8861161008a578063c6a319fa11610064578063c6a319fa146104db578063c78ad77f146104fb578063df8fa43014610511578063ff39e9c91461053157600080fd5b8063b8a0a88614610488578063be7b66a3146104a8578063bed4a4b9146104bb57600080fd5b806399540b51116100c657806399540b5114610406578063a917f66f14610419578063abba5a4c14610452578063abdb2f631461047257600080fd5b80635da4a1d3146103965780635e8e9cd6146103b657806391df3d3e146103d657600080fd5b806326b825d2116101595780634c4df870116101335780634c4df870146103125780634fc4a1ae1461034257806354fd4d501461035857806355460f811461037657600080fd5b806326b825d2146102a35780632785b911146102c35780633f6d8256146102fc57600080fd5b80630b3f55d2146101a15780630ccf2156146101c357806314ff5ea3146101ec578063163d36ba1461021c5780631d1440fd146102325780632374d2ae14610283575b600080fd5b3480156101ad57600080fd5b506101c16101bc366004612e94565b610551565b005b3480156101cf57600080fd5b506101d960385481565b6040519081526020015b60405180910390f35b3480156101f857600080fd5b506101d9610207366004612ee4565b6000908152603f602052604090206002015490565b34801561022857600080fd5b506101d9603a5481565b34801561023e57600080fd5b5061026b61024d366004612ee4565b6000908152603f60205260409020600401546001600160a01b031690565b6040516001600160a01b0390911681526020016101e3565b34801561028f57600080fd5b506101c161029e366004612ee4565b6109af565b3480156102af57600080fd5b506101c16102be366004612ee4565b610c58565b3480156102cf57600080fd5b5061026b6102de366004612ee4565b6000908152603f60205260409020600101546001600160a01b031690565b34801561030857600080fd5b506101d960395481565b34801561031e57600080fd5b506101d961032d366004612ee4565b6000908152603f602052604090206005015490565b34801561034e57600080fd5b506101d9603b5481565b34801561036457600080fd5b50604051620f424081526020016101e3565b34801561038257600080fd5b506101c1610391366004612ee4565b610e9f565b3480156103a257600080fd5b506101c16103b1366004612ee4565b6110e6565b3480156103c257600080fd5b5060355461026b906001600160a01b031681565b3480156103e257600080fd5b506101d96103f1366004612ee4565b6000908152603f602052604090206007015490565b6101c1610414366004612e94565b61132d565b34801561042557600080fd5b5061026b610434366004612ee4565b6000908152603f60205260409020600301546001600160a01b031690565b34801561045e57600080fd5b506101c161046d366004612ee4565b6115c6565b34801561047e57600080fd5b506101d9603c5481565b34801561049457600080fd5b506101c16104a3366004612ee4565b61180d565b6101c16104b6366004612f0b565b611a54565b3480156104c757600080fd5b506101d96104d6366004612ee4565b611dec565b3480156104e757600080fd5b5060375461026b906001600160a01b031681565b34801561050757600080fd5b506101d9603d5481565b34801561051d57600080fd5b506101c161052c366004612fb3565b611eb9565b34801561053d57600080fd5b5060365461026b906001600160a01b031681565b604080517fe733ae9f3cbed0032e619b793c461cc7a8094ef97c0d59e7ef699fe26e6584126020820152908101849052606081018390526000906105ae906080015b60405160208183030381529060405280519060200120611fcf565b905060006105bc8284612023565b6037546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b15801561060357600080fd5b505afa158015610617573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061063b919061302a565b610668576040516333ffff9b60e01b81526001600160a01b03821660048201526024015b60405180910390fd5b83421115610692576040516302a07ebf60e31b81526004810185905242602482015260440161065f565b6000858152603f60205260409020600301546001600160a01b031633148015906107b357506037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561070457600080fd5b505afa158015610718573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061073c919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561077957600080fd5b505afa15801561078d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107b1919061302a565b155b80156108b657506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561080757600080fd5b505afa15801561081b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061083f919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561087c57600080fd5b505afa158015610890573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108b4919061302a565b155b156108d6576040516302c2c4c760e11b815233600482015260240161065f565b6000858152603f602052604090206006015460ff1615156001141561090e57604051630be82b4560e21b815260040160405180910390fd5b6000858152603f60205260409081902060028101546003820154600492830180546001600160a01b0319166001600160a01b0392831690811790915560355494516323b872dd60e01b81529294909116926323b872dd926109759230929091879101613067565b600060405180830381600087803b15801561098f57600080fd5b505af11580156109a3573d6000803e3d6000fd5b50505050505050505050565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b1580156109fc57600080fd5b505afa158015610a10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a34919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610a7157600080fd5b505afa158015610a85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610aa9919061302a565b80610ba957506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b158015610afc57600080fd5b505afa158015610b10573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610b34919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610b7157600080fd5b505afa158015610b85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba9919061302a565b610c53576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b505afa158015610c05573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c29919061304e565b6040516316b4d34b60e31b81526001600160a01b039092166004830152602482015260440161065f565b603b55565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b158015610ca557600080fd5b505afa158015610cb9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cdd919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610d1a57600080fd5b505afa158015610d2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d52919061302a565b80610e5257506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b158015610da557600080fd5b505afa158015610db9573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ddd919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610e1a57600080fd5b505afa158015610e2e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e52919061302a565b610e9a576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603855565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b158015610eec57600080fd5b505afa158015610f00573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f24919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b158015610f6157600080fd5b505afa158015610f75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f99919061302a565b8061109957506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b158015610fec57600080fd5b505afa158015611000573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611024919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561106157600080fd5b505afa158015611075573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611099919061302a565b6110e1576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603955565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561113357600080fd5b505afa158015611147573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061116b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156111a857600080fd5b505afa1580156111bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111e0919061302a565b806112e057506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561123357600080fd5b505afa158015611247573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061126b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156112a857600080fd5b505afa1580156112bc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112e0919061302a565b611328576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603d55565b604080517fb3eb797330dcba0b1770e63c28973d7dd4729e01cf8a0ac76b631057037b3bc060208201529081018490526060810183905260009061137390608001610593565b905060006113818284612023565b6037546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b1580156113c857600080fd5b505afa1580156113dc573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611400919061302a565b611428576040516333ffff9b60e01b81526001600160a01b038216600482015260240161065f565b83421115611452576040516302a07ebf60e31b81526004810185905242602482015260440161065f565b6000858152603f60209081526040918290208251610140810184528154815260018201546001600160a01b0390811693820193909352600282015493810184905260038201548316606082015260048201549092166080830152600581015460a08301819052600682015460ff808216151560c08601526101008083048216151560e087015262010000909204161515908401819052600790920154610120840181905292939290919042111561152c576101208401516040516399d30d2760e01b8152600481019190915242602482015260440161065f565b60808401516001600160a01b0316301461155957604051630be82b4560e21b815260040160405180910390fd5b3361156685858585612047565b6115708a82612606565b603554604080516001600160a01b038481168252602082018790528d9316917f38d3b35f9d1a01bdaf62d50358599208ee79c951b1dc12e1032b30a03411d919910160405180910390a350505050505050505050565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561161357600080fd5b505afa158015611627573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061164b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561168857600080fd5b505afa15801561169c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116c0919061302a565b806117c057506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561171357600080fd5b505afa158015611727573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061174b919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b15801561178857600080fd5b505afa15801561179c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117c0919061302a565b611808576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603c55565b6037546040805163a217fddf60e01b815290516001600160a01b03909216916391d1485491839163a217fddf91600480820192602092909190829003018186803b15801561185a57600080fd5b505afa15801561186e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611892919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156118cf57600080fd5b505afa1580156118e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611907919061302a565b80611a0757506037546040805163a6b4321160e01b815290516001600160a01b03909216916391d1485491839163a6b4321191600480820192602092909190829003018186803b15801561195a57600080fd5b505afa15801561196e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611992919061304e565b6040516001600160e01b031960e084901b168152600481019190915233602482015260440160206040518083038186803b1580156119cf57600080fd5b505afa1580156119e3573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611a07919061302a565b611a4f576037546040805163a6b4321160e01b8152905133926001600160a01b03169163a6b43211916004808301926020929190829003018186803b158015610bf157600080fd5b603a55565b604080517f5692fac64371a8b1a07bff8cdd3d83af7c5cca18d2f10e2de046b25d6235fcf46020820152908101899052606081018890526080810187905285151560a082015284151560c082015260e081018490526101008101839052600090611ac19061012001610593565b90506000611acf8284612023565b6037546040516310736f8560e01b81526001600160a01b0380841660048301529293509116906310736f859060240160206040518083038186803b158015611b1657600080fd5b505afa158015611b2a573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611b4e919061302a565b611b76576040516333ffff9b60e01b81526001600160a01b038216600482015260240161065f565b83421115611ba0576040516302a07ebf60e31b81526004810185905242602482015260440161065f565b85158015611baf5750603c5488105b15611bdb57603c5460405163a9b53d8360e01b815261065f918a91600401918252602082015260400190565b87891015611c0657604051630145611560e21b8152600481018a90526024810189905260440161065f565b611c14603e80546001019055565b6000611c1f603e5490565b90506000611c2d87426130a1565b9050603b543414611c5e57603b54604051635928816d60e11b8152346004820152602481019190915260440161065f565b6037546040805163220ce7e760e21b815290516000926001600160a01b0316916388339f9c916004808301926020929190829003018186803b158015611ca357600080fd5b505afa158015611cb7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611cdb91906130b9565b90506000816001600160a01b03163460405160006040518083038185875af1925050503d8060008114611d2a576040519150601f19603f3d011682016040523d82523d6000602084013e611d2f565b606091505b5050905080611d5757308234604051634eb3d3e160e11b815260040161065f93929190613067565b5050603560009054906101000a90046001600160a01b03166001600160a01b03166323b872dd33308f6040518463ffffffff1660e01b8152600401611d9e93929190613067565b600060405180830381600087803b158015611db857600080fd5b505af1158015611dcc573d6000803e3d6000fd5b50505050611dde828d8d8c8c86612744565b505050505050505050505050565b6000818152603f6020526040812060060154610100900460ff1615611e2157506000908152603f602052604090206005015490565b6000828152603f6020526040812060050154603d54603854919291611e4690846130d6565b611e5091906130f5565b90506000603d5460395484611e6591906130d6565b611e6f91906130f5565b90506000603d54603a5485611e8491906130d6565b611e8e91906130f5565b905080611e9b83856130a1565b611ea591906130a1565b611eaf90856130a1565b9695505050505050565b600054610100900460ff1680611ed2575060005460ff16155b611eee5760405162461bcd60e51b815260040161065f90613117565b600054610100900460ff16158015611f10576000805461ffff19166101011790555b611f566040518060400160405280600b81526020016a4d61726b6574706c61636560a81b815250604051806040016040528060018152602001603160f81b81525061299c565b603580546001600160a01b03808c166001600160a01b031992831617909255603780548b841690831617905560368054928a169290911691909117905560388690556039859055603a849055603b839055603c8290556103e8603d558015611fc4576000805461ff00191690555b505050505050505050565b600061201d611fdc612a27565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b92915050565b60008060006120328585612aa7565b9150915061203f81612b17565b509392505050565b60608401516035546040516362848c0f60e01b8152600481018690526000916001600160a01b0316906362848c0f9060240160206040518083038186803b15801561209157600080fd5b505afa1580156120a5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906120c991906130b9565b60355460405163f52d779f60e01b8152600481018890529192506000916001600160a01b039091169063f52d779f9060240160206040518083038186803b15801561211357600080fd5b505afa158015612127573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061214b91906130b9565b90506000603760009054906101000a90046001600160a01b03166001600160a01b03166388339f9c6040518163ffffffff1660e01b815260040160206040518083038186803b15801561219d57600080fd5b505afa1580156121b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121d591906130b9565b90506000603d54603854886121ea91906130d6565b6121f491906130f5565b90506000603d546039548961220991906130d6565b61221391906130f5565b90506000603d54603a548a61222891906130d6565b61223291906130f5565b90508061223f83856130a1565b61224991906130a1565b89101561226957604051635d616c1360e01b815260040160405180910390fd5b60e08b0151899015612297578161228084866130a1565b61228a91906130a1565b6122949082613165565b90505b81836122a386846130a1565b6122ad91906130a1565b6122b791906130a1565b3414612300573482846122ca87856130a1565b6122d491906130a1565b6122de91906130a1565b604051635928816d60e11b81526004810192909252602482015260440161065f565b60008961239257603c546123149083613165565b603c546040519193506001600160a01b03881691600081818185875af1925050503d8060008114612361576040519150601f19603f3d011682016040523d82523d6000602084013e612366565b606091505b50508091505080612392573086603c54604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038a16908390600081818185875af1925050503d80600081146123db576040519150601f19603f3d011682016040523d82523d6000602084013e6123e0565b606091505b5050809150508061240a57308983604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038816908590600081818185875af1925050503d8060008114612453576040519150601f19603f3d011682016040523d82523d6000602084013e612458565b606091505b5050809150508061248257308785604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038716908690600081818185875af1925050503d80600081146124cb576040519150601f19603f3d011682016040523d82523d6000602084013e6124d0565b606091505b505080915050806124fa57308686604051634eb3d3e160e11b815260040161065f93929190613067565b6040516001600160a01b038916908490600081818185875af1925050503d8060008114612543576040519150601f19603f3d011682016040523d82523d6000602084013e612548565b606091505b5050809150508061257257308884604051634eb3d3e160e11b815260040161065f93929190613067565b8961258757603c5461258490866130a1565b94505b604080516001600160a01b0388811682526020820188905289811682840152606082018790528a8116608083015260a082018690528b1660c082015260e0810184905290517f2a8ef2e78928f7009766e5f98d25725e2786c77f03522b580da350cfb2ad91cd918190036101000190a150505050505050505050505050565b6000828152603f60209081526040918290208251610140810184528154815260018201546001600160a01b0390811693820193909352600282015481850181905260038301548416606083015260048084015485166080840152600584015460a0840152600684015460ff808216151560c08601526101008083048216151560e0870152620100009092041615159084015260079093015461012083015260355494516323b872dd60e01b81529194909316916323b872dd916126cf9130913391879101613067565b600060405180830381600087803b1580156126e957600080fd5b505af11580156126fd573d6000803e3d6000fd5b50505060009485525050603f6020525060409091206004810180546001600160a01b0319166001600160a01b0390931692909217909155600601805460ff19166001179055565b604051806101400160405280878152602001603560009054906101000a90046001600160a01b03166001600160a01b03168152602001868152602001336001600160a01b03168152602001306001600160a01b031681526020018581526020016000151581526020018415158152602001831515815260200182815250603f60008881526020019081526020016000206000820151816000015560208201518160010160006101000a8154816001600160a01b0302191690836001600160a01b031602179055506040820151816002015560608201518160030160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060808201518160040160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555060a0820151816005015560c08201518160060160006101000a81548160ff02191690831515021790555060e08201518160060160016101000a81548160ff0219169083151502179055506101008201518160060160026101000a81548160ff021916908315150217905550610120820151816007015590505084603560009054906101000a90046001600160a01b03166001600160a01b0316877f9d59d31d5753a7d709b23f2e99253ddfb2eba27384a2f54790290cc93d25c82f33308960008a8a8a603b5460405161298c9897969594939291906001600160a01b0398891681529690971660208701526040860194909452911515606085015215156080840152151560a083015260c082015260e08101919091526101000190565b60405180910390a4505050505050565b600054610100900460ff16806129b5575060005460ff16155b6129d15760405162461bcd60e51b815260040161065f90613117565b600054610100900460ff161580156129f3576000805461ffff19166101011790555b82516020808501919091208351918401919091206001919091556002558015612a22576000805461ff00191690555b505050565b6000612aa27f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f612a5660015490565b6002546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b600080825160411415612ade5760208301516040840151606085015160001a612ad287828585612cd5565b94509450505050612b10565b825160401415612b085760208301516040840151612afd868383612dc2565b935093505050612b10565b506000905060025b9250929050565b6000816004811115612b2b57612b2b61317c565b1415612b345750565b6001816004811115612b4857612b4861317c565b1415612b965760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e61747572650000000000000000604482015260640161065f565b6002816004811115612baa57612baa61317c565b1415612bf85760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e67746800604482015260640161065f565b6003816004811115612c0c57612c0c61317c565b1415612c655760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b606482015260840161065f565b6004816004811115612c7957612c7961317c565b1415612cd25760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b606482015260840161065f565b50565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a0831115612d0c5750600090506003612db9565b8460ff16601b14158015612d2457508460ff16601c14155b15612d355750600090506004612db9565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612d89573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b038116612db257600060019250925050612db9565b9150600090505b94509492505050565b6000806001600160ff1b03831660ff84901c601b01612de387828885612cd5565b935093505050935093915050565b634e487b7160e01b600052604160045260246000fd5b600082601f830112612e1857600080fd5b813567ffffffffffffffff80821115612e3357612e33612df1565b604051601f8301601f19908116603f01168101908282118183101715612e5b57612e5b612df1565b81604052838152866020858801011115612e7457600080fd5b836020870160208301376000602085830101528094505050505092915050565b600080600060608486031215612ea957600080fd5b8335925060208401359150604084013567ffffffffffffffff811115612ece57600080fd5b612eda86828701612e07565b9150509250925092565b600060208284031215612ef657600080fd5b5035919050565b8015158114612cd257600080fd5b600080600080600080600080610100898b031215612f2857600080fd5b8835975060208901359650604089013595506060890135612f4881612efd565b94506080890135612f5881612efd565b935060a0890135925060c0890135915060e089013567ffffffffffffffff811115612f8257600080fd5b612f8e8b828c01612e07565b9150509295985092959890939650565b6001600160a01b0381168114612cd257600080fd5b600080600080600080600080610100898b031215612fd057600080fd5b8835612fdb81612f9e565b97506020890135612feb81612f9e565b96506040890135612ffb81612f9e565b979a96995096976060810135975060808101359660a0820135965060c0820135955060e0909101359350915050565b60006020828403121561303c57600080fd5b815161304781612efd565b9392505050565b60006020828403121561306057600080fd5b5051919050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b634e487b7160e01b600052601160045260246000fd5b600082198211156130b4576130b461308b565b500190565b6000602082840312156130cb57600080fd5b815161304781612f9e565b60008160001904831182151516156130f0576130f061308b565b500290565b60008261311257634e487b7160e01b600052601260045260246000fd5b500490565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6000828210156131775761317761308b565b500390565b634e487b7160e01b600052602160045260246000fdfea2646970667358221220c2b2534154a575ddf6d6b3b8d36403fbc328837ac78500fa5c6e749ae654c36f64736f6c63430008090033