Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
- Contract name:
- RoyaltiesRegistry
- Optimization enabled
- true
- Compiler version
- v0.8.4+commit.c7e474f2
- Optimization runs
- 200
- Verified at
- 2023-10-19T19:45:36.318247Z
contracts/Royalties-registry/RoyaltiesRegistry.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./IRoyaltiesProvider.sol"; import "../RoyaltiesV1Luxy.sol"; import "../RoyaltiesV2Rarible.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "../tokens/ERC2981/IERC2981.sol"; contract RoyaltiesRegistry is IRoyaltiesProvider, OwnableUpgradeable { event RoyaltiesSetForToken( address indexed token, uint256 indexed tokenId, LibPart.Part[] royalties ); event RoyaltiesSetForContract( address indexed token, LibPart.Part[] royalties ); struct RoyaltiesSet { bool initialized; LibPart.Part[] royalties; } mapping(bytes32 => RoyaltiesSet) public royaltiesByTokenAndTokenId; mapping(address => RoyaltiesSet) public royaltiesByToken; mapping(address => address) public royaltiesProviders; function __RoyaltiesRegistry_init() external initializer { __Ownable_init_unchained(); } function setProviderByToken(address token, address provider) external { checkOwner(token); royaltiesProviders[token] = provider; } function setRoyaltiesByToken( address token, LibPart.Part[] memory royalties ) external { checkOwner(token); uint256 sumRoyalties = 0; delete royaltiesByToken[token]; for (uint256 i = 0; i < royalties.length; i++) { require( royalties[i].account != address(0x0), "RoyaltiesByToken recipient should be present" ); require( royalties[i].value != 0, "Royalty value for RoyaltiesByToken should be > 0" ); // Check if the new royalty is already present in the array for ( uint256 j = 0; j < royaltiesByToken[token].royalties.length; j++ ) { require( royalties[i].account != royaltiesByToken[token].royalties[j].account, "Duplicate account detected in royalties" ); } royaltiesByToken[token].royalties.push(royalties[i]); sumRoyalties += royalties[i].value; } require( sumRoyalties <= 3000, "Set by token royalties sum more than 30%" ); royaltiesByToken[token].initialized = true; emit RoyaltiesSetForContract(token, royalties); } function getRoyaltiesByToken( address token ) external view returns (LibPart.Part[] memory) { return royaltiesByToken[token].royalties; } function getRoyaltiesByTokenAndTokenId( address token, uint256 tokenId ) external view returns (LibPart.Part[] memory) { return royaltiesByTokenAndTokenId[keccak256(abi.encode(token, tokenId))] .royalties; } function checkOwner(address token) internal view { if ((owner() != _msgSender())) { try OwnableUpgradeable(token).owner() returns (address result) { if (result != _msgSender()) { revert("Sender is not owner of the token"); } } catch { revert("Token owner not detected"); } } } function getRoyalties( address token, uint256 tokenId ) external override returns (LibPart.Part[] memory) { RoyaltiesSet memory royaltiesSetNFT = royaltiesByTokenAndTokenId[ keccak256(abi.encode(token, tokenId)) ]; RoyaltiesSet memory royaltiesSetToken = royaltiesByToken[token]; uint totalRoyalties = royaltiesSetNFT.royalties.length + royaltiesSetToken.royalties.length; LibPart.Part[] memory combinedRoyalties; if (royaltiesSetNFT.initialized && royaltiesSetToken.initialized) { combinedRoyalties = new LibPart.Part[]( totalRoyalties ); for (uint256 i = 0; i < royaltiesSetToken.royalties.length; i++) { combinedRoyalties[i] = royaltiesSetToken.royalties[i]; } for (uint256 i = 0; i < royaltiesSetNFT.royalties.length; i++) { combinedRoyalties[ royaltiesSetToken.royalties.length + i ] = royaltiesSetNFT.royalties[i]; } return combinedRoyalties; } else if ( royaltiesSetNFT.initialized ) { return royaltiesSetNFT.royalties; } ( bool result, LibPart.Part[] memory resultRoyalties ) = providerExtractor(token, tokenId); if (result == false) { resultRoyalties = royaltiesFromContract(token, tokenId); } totalRoyalties = resultRoyalties.length + royaltiesSetToken.royalties.length; setRoyaltiesCacheByTokenAndTokenId(token, tokenId, resultRoyalties); combinedRoyalties = new LibPart.Part[]( totalRoyalties ); if (resultRoyalties.length > 0) { for (uint256 i = 0; i < royaltiesSetToken.royalties.length; i++) { combinedRoyalties[i] = royaltiesSetToken.royalties[i]; } for (uint256 i = 0; i < resultRoyalties.length; i++) { combinedRoyalties[ royaltiesSetToken.royalties.length + i ] = resultRoyalties[i]; } return combinedRoyalties; } if (royaltiesSetToken.initialized) { return royaltiesSetToken.royalties; } } function setRoyaltiesCacheByTokenAndTokenId( address token, uint256 tokenId, LibPart.Part[] memory royalties ) internal { uint256 sumRoyalties = 0; bytes32 key = keccak256(abi.encode(token, tokenId)); delete royaltiesByTokenAndTokenId[key].royalties; for (uint256 i = 0; i < royalties.length; i++) { require( royalties[i].account != address(0x0), "RoyaltiesByTokenAndTokenId recipient should be present" ); require( royalties[i].value != 0, "Royalty value for RoyaltiesByTokenAndTokenId should be > 0" ); royaltiesByTokenAndTokenId[key].royalties.push(royalties[i]); sumRoyalties += royalties[i].value; } require( sumRoyalties <= 6800, "Set by token and tokenId royalties sum more, than 68%" ); royaltiesByTokenAndTokenId[key].initialized = true; emit RoyaltiesSetForToken(token, tokenId, royalties); } function royaltiesFromContract( address token, uint256 tokenId ) internal view returns (LibPart.Part[] memory) { if ( IERC165Upgradeable(token).supportsInterface( type(RoyaltiesV1Luxy).interfaceId ) ) { RoyaltiesV1Luxy v1 = RoyaltiesV1Luxy(token); try v1.getRoyalties(tokenId) returns ( LibPart.Part[] memory result ) { return result; } catch {} } else if ( IERC165Upgradeable(token).supportsInterface( type(RoyaltiesV2Rarible).interfaceId ) ) { RoyaltiesV2Rarible v2 = RoyaltiesV2Rarible(token); try v2.getRaribleV2Royalties(tokenId) returns ( LibPart.Part[] memory result ) { return result; } catch {} } else if ( IERC165Upgradeable(token).supportsInterface( type(IERC2981).interfaceId ) ) { IERC2981 standard = IERC2981(token); try standard.royaltyInfo(tokenId, 10000) returns ( address receiver, uint256 royaltyAmount ) { LibPart.Part[] memory result = new LibPart.Part[](1); result[0].account = payable(receiver); result[0].value = uint96(royaltyAmount); return result; } catch {} } return new LibPart.Part[](0); } function providerExtractor( address token, uint256 tokenId ) public returns (bool result, LibPart.Part[] memory royalties) { result = false; address providerAddress = royaltiesProviders[token]; if (providerAddress != address(0x0)) { IRoyaltiesProvider provider = IRoyaltiesProvider(providerAddress); try provider.getRoyalties(token, tokenId) returns ( LibPart.Part[] memory royaltiesByProvider ) { royalties = royaltiesByProvider; result = true; } catch {} } } uint256[50] private __gap; }
contracts/exchange/orderControl/testContracts/LibOrderTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../LibOrder.sol"; contract LibOrderTest { function calculateRemaining(LibOrder.Order calldata order, uint256 fill) external pure returns (uint256 makeAmount, uint256 takeAmount) { return LibOrder.calculateRemaining(order, fill); } function hashKey(LibOrder.Order calldata order) external pure returns (bytes32) { return LibOrder.hashKey(order); } function validate(LibOrder.Order calldata order) external view { LibOrder.validate(order); } }
@openzeppelin/contracts/utils/Strings.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/Math.sol"; /** * @dev String operations. */ library Strings { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = Math.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, Math.log256(value) + 1); } } /** * @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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
@openzeppelin/contracts/utils/Context.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 Context { function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } }
@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 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 functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or 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 { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
contracts/tokens/factory/ERC721PrivateFactory.sol
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "../ERC721/ERC721LuxyPrivate.sol"; contract ERC721LuxyPrivateFactory is Ownable { event Create721LuxyContract(address erc721); constructor() {} function createToken( string memory _name, string memory _symbol, string memory _baseURI, address[] memory _minters, bool _ischangeable, uint256 _maxSupply, uint _salt ) external { address luxy721PrivateToken = deployProxy( getData(_name, _symbol, _baseURI, _minters, _ischangeable,_maxSupply), _salt ); ERC721LuxyPrivate token = ERC721LuxyPrivate(luxy721PrivateToken); token.__ERC721LuxyPrivate_init(_name, _symbol, _baseURI, _minters,_ischangeable,_maxSupply); token.transferOwnership(_msgSender()); emit Create721LuxyContract(luxy721PrivateToken); } //deploying Luxy1155 contract with create2 function deployProxy(bytes memory data, uint salt) internal returns (address proxy) { bytes memory bytecode = getCreationBytecode(data); assembly { proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt) if iszero(extcodesize(proxy)) { revert(0, 0) } } } //adding unnecessary constructor arguments to Luxy1155 bytecode, to get less change for collision on contract address function getCreationBytecode(bytes memory _data) internal pure returns (bytes memory) { return abi.encodePacked( type(ERC721LuxyPrivate).creationCode, abi.encode(_data) ); } //returns address that contract with such arguments will be deployed on function getAddress( string memory _name, string memory _symbol, string memory _baseURI, address[] memory _minters, bool _ischangeable, uint256 _maxSupply, uint _salt ) public view returns (address) { bytes memory bytecode; bytecode = getCreationBytecode( getData(_name, _symbol, _baseURI, _minters,_ischangeable,_maxSupply) ); bytes32 hash = keccak256( abi.encodePacked( bytes1(0xff), address(this), _salt, keccak256(bytecode) ) ); return address(uint160(uint256(hash))); } function getData( string memory _name, string memory _symbol, string memory _baseURI, address[] memory _minters, bool _ischangeable, uint256 _maxSupply ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ERC721LuxyPrivate.__ERC721LuxyPrivate_init.selector, _name, _symbol, _baseURI, _minters, _ischangeable, _maxSupply ); } }
@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev _Available since v3.1._ */ interface IERC1155ReceiverUpgradeable is IERC165Upgradeable { /** * @dev Handles the receipt of a single ERC1155 token type. This function is * called at the end of a `safeTransferFrom` after the balance has been updated. * * NOTE: To accept the transfer, this must return * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` * (i.e. 0xf23a6e61, or its own function selector). * * @param operator The address which initiated the transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param id The ID of the token being transferred * @param value The amount of tokens being transferred * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed */ function onERC1155Received( address operator, address from, uint256 id, uint256 value, bytes calldata data ) external returns (bytes4); /** * @dev Handles the receipt of a multiple ERC1155 token types. This function * is called at the end of a `safeBatchTransferFrom` after the balances have * been updated. * * NOTE: To accept the transfer(s), this must return * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` * (i.e. 0xbc197c81, or its own function selector). * * @param operator The address which initiated the batch transfer (i.e. msg.sender) * @param from The address which previously owned the token * @param ids An array containing ids of each token being transferred (order and length must match values array) * @param values An array containing amounts of each token being transferred (order and length must match ids array) * @param data Additional data with no specified format * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed */ function onERC1155BatchReceived( address operator, address from, uint256[] calldata ids, uint256[] calldata values, bytes calldata data ) external returns (bytes4); }
@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Metadata is IERC721 { /** * @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); }
contracts/LibsDiscount.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library LibTier { bytes32 constant TIER_TYPEHASH = keccak256("Tier(uint256 value,uint96 percentual)"); struct Tier { uint256 value; uint96 percentual; } } library LibNFTHolder { bytes32 constant HOLDER_TYPEHASH = keccak256("NFTHolder(address token,uint96 percentual)"); struct NFTHolder { address token; uint96 percentual; } }
contracts/tokens/ERC1271/ERC1271.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/interfaces/IERC1271Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; abstract contract ERC1271Upgradeable is EIP712Upgradeable { using ECDSAUpgradeable for bytes32; bytes4 public constant ERC1271_INTERFACE_ID = 0xfb855dc9; // this.isValidSignature.selector bytes4 public constant ERC1271_RETURN_VALID_SIGNATURE = 0x1626ba7e; bytes4 public constant ERC1271_RETURN_INVALID_SIGNATURE = 0x00000000; string constant CONTRACT_SIGNATURE_ERROR = "contract signature verification error"; string constant SIGNATURE_ERROR = "signature verification error"; function __ERC1271Upgradeable_init( string memory name, string memory version ) internal initializer { __EIP712_init_unchained(name, version); __ERC1271Upgradeable_init_unchained(); } function __ERC1271Upgradeable_init_unchained() internal initializer {} function isContract(address addr) internal view returns (bool) { uint256 size; assembly { size := extcodesize(addr) } return size > 0; } function returnIsValidSignatureMagicNumber(bool isValid) internal pure returns (bytes4) { return isValid ? ERC1271_RETURN_VALID_SIGNATURE : ERC1271_RETURN_INVALID_SIGNATURE; } function _validate( address signer, bytes32 structHash, bytes memory signature ) internal view { bytes32 hash = _hashTypedDataV4(structHash); if (isContract(signer)) { require( IERC1271Upgradeable(signer).isValidSignature(hash, signature) == ERC1271_RETURN_VALID_SIGNATURE, CONTRACT_SIGNATURE_ERROR ); } else { require(hash.recover(signature) == signer, SIGNATURE_ERROR); } } uint256[50] private __gap; }
@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/extensions/ERC721URIStorage.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev ERC721 token with storage based token URI management. */ abstract contract ERC721URIStorageUpgradeable is Initializable, ERC721Upgradeable { function __ERC721URIStorage_init() internal onlyInitializing { } function __ERC721URIStorage_init_unchained() internal onlyInitializing { } using StringsUpgradeable for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { _requireMinted(tokenId); string memory _tokenURI = _tokenURIs[tokenId]; string memory base = _baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return _tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(_tokenURI).length > 0) { return string(abi.encodePacked(base, _tokenURI)); } return super.tokenURI(tokenId); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual { require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token"); _tokenURIs[tokenId] = _tokenURI; } /** * @dev See {ERC721-_burn}. This override additionally checks to see if a * token-specific URI was set for the token, and if so, it deletes the token URI from * the storage mapping. */ function _burn(uint256 tokenId) internal virtual override { super._burn(tokenId); if (bytes(_tokenURIs[tokenId]).length != 0) { delete _tokenURIs[tokenId]; } } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
contracts/launchpad/DropWithVoucher/DropWithVoucherTest/ERC721LuxyVoucherTest.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,,x _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "../../../royalties-default/RoyaltiesV1Luxy.sol"; import "..//../../tokens/ERC2981-default/IERC2981.sol"; import "../Voucher.sol"; contract ERC721LuxyVoucherTest is Ownable, RoyaltiesV1Luxy, ERC721Enumerable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; string public baseURI; //Uncomment this section to enable whitelist // IERC20Upgradeable luxy; address public artist; address public luxyLaunchpadFeeManagerProxy; uint256 public constant MAX_BATCH_MINT = 10; uint256 public constant MAX_SUPPLY = 50; uint256 public constant DROP_START_TIME = 1; uint256 public constant PRICE_PER_TOKEN = 1 ether; uint256 public whitelistSize; uint256 public constant WHITELIST_EXPIRE_TIME = 0 minutes; struct PrizeMeta { bool isClaimed; address claimer; uint256 time; } mapping(address => bool) private _whitelist; mapping(uint256 => PrizeMeta) public prizeInfo; mapping(uint256 => bool) internal prizeById; mapping(uint256 => uint256) private _assignOrders; ERC721Voucher public voucherContract; event Claim(PrizeMeta prizeInfo); constructor( address _voucherContract, address _luxyLaunchpadFeeManagerProxy, uint256[] memory ids, address _artist ) ERC721("LuxyVoucherTest010", "LVNFT") { voucherContract = ERC721Voucher(_voucherContract); luxyLaunchpadFeeManagerProxy = _luxyLaunchpadFeeManagerProxy; artist = _artist; for (uint256 i = 0; i < ids.length; i++) { prizeById[ids[i]] = true; } } function mint(uint256 num, address minter) external { require( _msgSender() == luxyLaunchpadFeeManagerProxy, "ERC721LuxyVoucher: Not allowed" ); require( block.timestamp > DROP_START_TIME, "ERC721LuxyVoucher: Drop hasnt started yet" ); require( num <= MAX_BATCH_MINT, "ERC721LuxyVoucher: Exceeds max batch per mint" ); require( totalSupply() + num <= MAX_SUPPLY, "ERC721LuxyVoucher: Exceeds drop max supply" ); // Uncomment this section to enable whitelist if (block.timestamp < DROP_START_TIME + WHITELIST_EXPIRE_TIME) { require(isWhitelisted(minter), "Not whitelisted"); } // Uncomment this section to enable LUXY Sale // if (block.timestamp < DROP_START_TIME + LUXY_SALE_EXPIRE_TIME) { // require( // luxy.balanceOf(minter) > MINIMUM_LUXY_AMOUNT, // "Not elegible to Luxy sale" // ); // } for (uint256 i; i < num; i++) { // uint256 genesisRemainingToAssign = MAX_SUPPLY - totalSupply(); // uint256 randIndex = _random() % genesisRemainingToAssign; // uint256 genesisIndex = _fillAssignOrder( // genesisRemainingToAssign, // randIndex // ); uint256 tokenId = _tokenIds.current(); _safeMint(minter, tokenId); // Switch to genesisIndex for random mint, for testing is easier to use linear order // _safeMint(minter, genesisIndex); _tokenIds.increment(); if (prizeById[tokenId]) { voucherContract.mint(tokenId, minter); } } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override(ERC721Enumerable, IERC165) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC721Enumerable).interfaceId || _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}. */ function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } /** * @dev Base URI for computing {tokenURI}. The resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. * See {ERC721Upgradeable-_baseURI}. */ function _baseURI() internal view override returns (string memory) { return baseURI; } /** * @dev See {ERC721EnumerableUpgradeable-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override { super._beforeTokenTransfer(from, to, tokenId,batchSize); } function _afterTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override { if ( prizeById[tokenId] && from != address(0) && !prizeInfo[tokenId].isClaimed ) { voucherContract.safeTransferFrom(from, to, tokenId); } super._afterTokenTransfer(from, to, tokenId,batchSize); } function claim(uint256 tokenId) external { address owner = ERC721.ownerOf(tokenId); require( _msgSender() == owner, "ERC721LuxyVoucher: MSGSender is not the owner" ); require( prizeInfo[tokenId].isClaimed == false, "ERC721LuxyVoucher: Already Claimed" ); voucherContract.burn(tokenId); prizeInfo[tokenId].claimer = _msgSender(); prizeInfo[tokenId].isClaimed = true; prizeInfo[tokenId].time = block.timestamp; emit Claim(prizeInfo[tokenId]); } function isClaimed(uint256 tokenId) external view returns (bool) { require( prizeById[tokenId] == true, "ERC721LuxyVoucher: There is no prize associated to this NFT" ); if ( prizeInfo[tokenId].isClaimed || voucherContract.ownerOf(tokenId) == address(0) ) { return true; } return false; } function claimer(uint256 tokenId) external view returns (address) { return prizeInfo[tokenId].claimer; } function claimDate(uint256 tokenId) external view returns (uint256) { return prizeInfo[tokenId].time; } function _fillAssignOrder(uint256 orderA, uint256 orderB) internal returns (uint256) { uint256 temp = orderA; if (_assignOrders[orderA] > 0) temp = _assignOrders[orderA]; _assignOrders[orderA] = orderB; if (_assignOrders[orderB] > 0) _assignOrders[orderA] = _assignOrders[orderB]; _assignOrders[orderB] = temp; return _assignOrders[orderA]; } // pseudo-random function that's pretty robust because of syscoin's pow chainlocks function _random() internal view returns (uint256) { uint256 genesisRemainingToAssign = MAX_SUPPLY - totalSupply(); return uint256( keccak256( abi.encodePacked( block.timestamp + block.difficulty + (( uint256( keccak256(abi.encodePacked(block.coinbase)) ) ) / block.timestamp) + block.gaslimit + (( uint256( keccak256(abi.encodePacked(_msgSender())) ) ) / block.timestamp) + block.number ) ) ) / genesisRemainingToAssign; } //Uncomment this section to enable whitelist function isWhitelisted(address addr) public view returns (bool) { return _whitelist[addr]; } function addToWhitelist(address[] memory addresses) external onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { if (!isWhitelisted(addresses[i])) { _whitelist[addresses[i]] = true; } whitelistSize++; } } function removeFromWhitelist(address[] memory addresses) external onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { if (isWhitelisted(addresses[i])) { _whitelist[addresses[i]] = false; whitelistSize--; } } } }
@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/ERC1155.sol) pragma solidity ^0.8.0; import "./IERC1155Upgradeable.sol"; import "./IERC1155ReceiverUpgradeable.sol"; import "./extensions/IERC1155MetadataURIUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the basic standard multi-token. * See https://eips.ethereum.org/EIPS/eip-1155 * Originally based on code by Enjin: https://github.com/enjin/erc-1155 * * _Available since v3.1._ */ contract ERC1155Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC1155Upgradeable, IERC1155MetadataURIUpgradeable { using AddressUpgradeable for address; // Mapping from token ID to account balances mapping(uint256 => mapping(address => uint256)) private _balances; // Mapping from account to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; // Used as the URI for all token types by relying on ID substitution, e.g. https://token-cdn-domain/{id}.json string private _uri; /** * @dev See {_setURI}. */ function __ERC1155_init(string memory uri_) internal onlyInitializing { __ERC1155_init_unchained(uri_); } function __ERC1155_init_unchained(string memory uri_) internal onlyInitializing { _setURI(uri_); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC1155Upgradeable).interfaceId || interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC1155MetadataURI-uri}. * * This implementation returns the same URI for *all* token types. It relies * on the token type ID substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * Clients calling this function must replace the `\{id\}` substring with the * actual token type ID. */ function uri(uint256) public view virtual override returns (string memory) { return _uri; } /** * @dev See {IERC1155-balanceOf}. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) public view virtual override returns (uint256) { require(account != address(0), "ERC1155: address zero is not a valid owner"); return _balances[id][account]; } /** * @dev See {IERC1155-balanceOfBatch}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view virtual override returns (uint256[] memory) { require(accounts.length == ids.length, "ERC1155: accounts and ids length mismatch"); uint256[] memory batchBalances = new uint256[](accounts.length); for (uint256 i = 0; i < accounts.length; ++i) { batchBalances[i] = balanceOf(accounts[i], ids[i]); } return batchBalances; } /** * @dev See {IERC1155-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC1155-isApprovedForAll}. */ function isApprovedForAll(address account, address operator) public view virtual override returns (bool) { return _operatorApprovals[account][operator]; } /** * @dev See {IERC1155-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeTransferFrom(from, to, id, amount, data); } /** * @dev See {IERC1155-safeBatchTransferFrom}. */ function safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) public virtual override { require( from == _msgSender() || isApprovedForAll(from, _msgSender()), "ERC1155: caller is not token owner or approved" ); _safeBatchTransferFrom(from, to, ids, amounts, data); } /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, to, ids, amounts, data); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; emit TransferSingle(operator, from, to, id, amount); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, from, to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _safeBatchTransferFrom( address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); require(to != address(0), "ERC1155: transfer to the zero address"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, to, ids, amounts, data); for (uint256 i = 0; i < ids.length; ++i) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: insufficient balance for transfer"); unchecked { _balances[id][from] = fromBalance - amount; } _balances[id][to] += amount; } emit TransferBatch(operator, from, to, ids, amounts); _afterTokenTransfer(operator, from, to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, from, to, ids, amounts, data); } /** * @dev Sets a new URI for all token types, by relying on the token type ID * substitution mechanism * https://eips.ethereum.org/EIPS/eip-1155#metadata[defined in the EIP]. * * By this mechanism, any occurrence of the `\{id\}` substring in either the * URI or any of the amounts in the JSON file at said URI will be replaced by * clients with the token type ID. * * For example, the `https://token-cdn-domain/\{id\}.json` URI would be * interpreted by clients as * `https://token-cdn-domain/000000000000000000000000000000000000000000000000000000000004cce0.json` * for token type ID 0x4cce0. * * See {uri}. * * Because these URIs cannot be meaningfully represented by the {URI} event, * this function emits no events. */ function _setURI(string memory newuri) internal virtual { _uri = newuri; } /** * @dev Creates `amount` tokens of token type `id`, and assigns them to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function _mint( address to, uint256 id, uint256 amount, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); _balances[id][to] += amount; emit TransferSingle(operator, address(0), to, id, amount); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeTransferAcceptanceCheck(operator, address(0), to, id, amount, data); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_mint}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function _mintBatch( address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual { require(to != address(0), "ERC1155: mint to the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, address(0), to, ids, amounts, data); for (uint256 i = 0; i < ids.length; i++) { _balances[ids[i]][to] += amounts[i]; } emit TransferBatch(operator, address(0), to, ids, amounts); _afterTokenTransfer(operator, address(0), to, ids, amounts, data); _doSafeBatchTransferAcceptanceCheck(operator, address(0), to, ids, amounts, data); } /** * @dev Destroys `amount` tokens of token type `id` from `from` * * Emits a {TransferSingle} event. * * Requirements: * * - `from` cannot be the zero address. * - `from` must have at least `amount` tokens of token type `id`. */ function _burn( address from, uint256 id, uint256 amount ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); address operator = _msgSender(); uint256[] memory ids = _asSingletonArray(id); uint256[] memory amounts = _asSingletonArray(amount); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } emit TransferSingle(operator, from, address(0), id, amount); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {_burn}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. */ function _burnBatch( address from, uint256[] memory ids, uint256[] memory amounts ) internal virtual { require(from != address(0), "ERC1155: burn from the zero address"); require(ids.length == amounts.length, "ERC1155: ids and amounts length mismatch"); address operator = _msgSender(); _beforeTokenTransfer(operator, from, address(0), ids, amounts, ""); for (uint256 i = 0; i < ids.length; i++) { uint256 id = ids[i]; uint256 amount = amounts[i]; uint256 fromBalance = _balances[id][from]; require(fromBalance >= amount, "ERC1155: burn amount exceeds balance"); unchecked { _balances[id][from] = fromBalance - amount; } } emit TransferBatch(operator, from, address(0), ids, amounts); _afterTokenTransfer(operator, from, address(0), ids, amounts, ""); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC1155: setting approval status for self"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Hook that is called before any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `ids` and `amounts` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} /** * @dev Hook that is called after any token transfer. This includes minting * and burning, as well as batched variants. * * The same hook is called on both single and batched variants. For single * transfers, the length of the `id` and `amount` arrays will be 1. * * Calling conditions (for each `id` and `amount` pair): * * - When `from` and `to` are both non-zero, `amount` of ``from``'s tokens * of token type `id` will be transferred to `to`. * - When `from` is zero, `amount` tokens of token type `id` will be minted * for `to`. * - when `to` is zero, `amount` of ``from``'s tokens of token type `id` * will be burned. * - `from` and `to` are never both zero. * - `ids` and `amounts` have the same, non-zero length. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) internal virtual {} function _doSafeTransferAcceptanceCheck( address operator, address from, address to, uint256 id, uint256 amount, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155Received(operator, from, id, amount, data) returns (bytes4 response) { if (response != IERC1155ReceiverUpgradeable.onERC1155Received.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _doSafeBatchTransferAcceptanceCheck( address operator, address from, address to, uint256[] memory ids, uint256[] memory amounts, bytes memory data ) private { if (to.isContract()) { try IERC1155ReceiverUpgradeable(to).onERC1155BatchReceived(operator, from, ids, amounts, data) returns ( bytes4 response ) { if (response != IERC1155ReceiverUpgradeable.onERC1155BatchReceived.selector) { revert("ERC1155: ERC1155Receiver rejected tokens"); } } catch Error(string memory reason) { revert(reason); } catch { revert("ERC1155: transfer to non-ERC1155Receiver implementer"); } } } function _asSingletonArray(uint256 element) private pure returns (uint256[] memory) { uint256[] memory array = new uint256[](1); array[0] = element; return array; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[47] private __gap; }
contracts/exchange/orderControl/LibOrderData.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LibOrder.sol"; import "./LibOrderDataV1.sol"; import "../../LibPart.sol"; library LibOrderData { function parse(LibOrder.Order memory order) internal pure returns (LibOrderDataV1.DataV1 memory dataOrder) { if (order.dataType == LibOrderDataV1.V1) { dataOrder = LibOrderDataV1.decodeOrderDataV1(order.data); if (dataOrder.payouts.length == 0) { dataOrder = payoutSet(order.maker, dataOrder); } } else if (order.dataType == 0xffffffff) { dataOrder = payoutSet(order.maker, dataOrder); } else { revert("Unknown Order data type"); } } function payoutSet( address orderAddress, LibOrderDataV1.DataV1 memory dataOrderOnePayoutIn ) internal pure returns (LibOrderDataV1.DataV1 memory) { LibPart.Part[] memory payout = new LibPart.Part[](1); payout[0].account = payable(orderAddress); payout[0].value = 10000; dataOrderOnePayoutIn.payouts = payout; return dataOrderOnePayoutIn; } }
contracts/tokens/ERC721/ERC721LuxyPrivate.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../../RoyaltiesV1Luxy.sol"; import "../ERC1271/ERC1271.sol"; import "../ERC2981/IERC2981.sol"; contract ERC721LuxyPrivate is ERC721URIStorageUpgradeable, ERC721EnumerableUpgradeable, ERC721BurnableUpgradeable, OwnableUpgradeable, RoyaltiesV1Luxy { using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private _tokenIds; mapping(address => bool) private approvedMinters; // Base URI string public baseURI; bool public isChangeable; uint256 public maxSupply; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721LuxyPrivate_init( string memory name_, string memory symbol_, string memory baseURI_, address[] memory minters_, bool isChangeable_, uint256 maxSupply_ ) external initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); _setInitialMinters(minters_); __ERC721Enumerable_init_unchained(); __Ownable_init_unchained(); _setBaseURI(baseURI_); _setChangeable(isChangeable_); _setMaxSupply(maxSupply_); } function __ERC721LuxyPrivate_init_unchained(string memory baseURI_ ,address[] memory minters_, bool isChangeable_, uint256 maxSupply_) internal initializer { _setInitialMinters(minters_); _setBaseURI(baseURI_); _setChangeable(isChangeable_); _setMaxSupply(maxSupply_); } function mint( address payable _recipient, string memory _metadata, LibPart.Part[] memory _royalties ) external returns (uint256) { require( _isApprovedMinterorOwner(_msgSender()), "Sender must be an approved minter or owner" ); uint256 itemId = _tokenIds.current(); if(maxSupply != 0){ require(itemId < maxSupply, "ERC721: minting above the total supply"); } _safeMint(_recipient, itemId); _setTokenURI(itemId, _metadata); _setRoyalties(itemId, _royalties); _tokenIds.increment(); return itemId; } function setApprovedMinter(address _minter, bool _approved) external onlyOwner { approvedMinters[_minter] = _approved; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override( ERC721Upgradeable, ERC721EnumerableUpgradeable, IERC165Upgradeable ) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC721URIStorageUpgradeable).interfaceId || _interfaceId == type(ERC721EnumerableUpgradeable).interfaceId || _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); } /** * @dev External function to allow base URI changes when necessary. */ function setBaseURI(string memory baseURI_) external onlyOwner { require(isChangeable, "Base URI is not changeable."); _setBaseURI(baseURI_); } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}. */ function _setBaseURI(string memory baseURI_) internal virtual { baseURI = baseURI_; } /** * @dev Internal function to set changeability of BaseURI for NFT drops. */ function _setChangeable(bool isChangeable_) internal virtual { isChangeable = isChangeable_; } function _setMaxSupply(uint256 maxSupply_) internal virtual { maxSupply = maxSupply_; } /** * @dev Internal function to set changeability of BaseURI for NFT drops. */ function _setInitialMinters(address[] memory minters) internal virtual { //initializing base minters list for (uint256 i = 0; i < minters.length; i++) { approvedMinters[minters[i]] = true; } } /** * @dev Base URI for computing {tokenURI}. The resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. * See {ERC721Upgradeable-_baseURI}. */ function _baseURI() internal view override returns (string memory) { return baseURI; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view override(ERC721Upgradeable, ERC721URIStorageUpgradeable) returns (string memory) { return super.tokenURI(tokenId); } function getMaxSupply() public view returns (uint256) { require(maxSupply > 0, "There is no MaxSupply for this collection."); return maxSupply; } /** * @dev See {ERC721EnumerableUpgradeable-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { super._beforeTokenTransfer(from, to, tokenId, batchSize); } /** * @dev See {ERC721URIStorageUpgradeable-_burn}. */ function _burn(uint256 tokenId) internal override(ERC721Upgradeable, ERC721URIStorageUpgradeable) { super._burn(tokenId); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedMinterorOwner(address minter) internal view virtual returns (bool) { if (minter == owner()) return true; require(minter != address(0)); return approvedMinters[minter]; } uint256[100] private __gap; }
contracts/RoyaltiesV1Luxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LibPart.sol"; import "./tokens/ERC2981/IERC2981.sol"; import "./exchange/lib/LibBP.sol"; //InterfaceID = 0x25292224 abstract contract RoyaltiesV1Luxy is IERC2981 { using LibBP for uint256; event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties); event RoyaltieAccountUpdate( uint256 tokenId, uint256 index, address previousAccount, address newAccount ); mapping(uint256 => LibPart.Part[]) internal royalties; function getRoyalties(uint256 id) public view virtual returns (LibPart.Part[] memory) { return royalties[id]; } function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view override returns (address receiver, uint256 royaltyAmount) { require(royalties[_tokenId].length != 0, "Royalties not set yet"); require( royalties[_tokenId].length == 1, "Multiples Royalties is not supported by EIP2981, use LuxyRoyaltiesV1" ); require( royalties[_tokenId][0].value <= 9800, "Royalties are too high (>98%)" ); royaltyAmount = _salePrice.bp(royalties[_tokenId][0].value); receiver = royalties[_tokenId][0].account; } //Not deployed yet current InterfaceID is 0x25292224 // function calcRoyaltiesInterfaceId() external pure returns (bytes4) { // return type(RoyaltiesV1Luxy).interfaceId; // } function _setRoyalties(uint256 _id, LibPart.Part[] memory _royalties) internal { require(royalties[_id].length == 0, "Royalties already set"); for (uint256 i = 0; i < _royalties.length; i++) { require( _royalties[i].account != address(0x0), "Recipient should be present" ); require( _royalties[i].value != 0, "Royalty value should be positive" ); royalties[_id].push(_royalties[i]); } emit RoyaltiesSet(_id, _royalties); } function _updateAccount( uint256 _id, address _from, address _to ) internal { uint256 length = royalties[_id].length; address previousAccount = address(0x0); uint256 index = 0; for (uint256 i = 0; i < length; i++) { if (royalties[_id][i].account == _from) { previousAccount = royalties[_id][i].account; index = i; royalties[_id][i].account = payable(address(uint160(_to))); } } require( previousAccount != address(0x0), "Account not found, are you using the correct wallet?" ); emit RoyaltieAccountUpdate( _id, index, previousAccount, royalties[_id][index].account ); } uint256[50] private __gap; }
@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol) pragma solidity ^0.8.0; import "./ECDSAUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @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._ * * @custom:storage-size 52 */ 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 onlyInitializing { __EIP712_init_unchained(name, version); } function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing { 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; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/exchange/exchangeInterfaces/ITransferProxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../assets/LibAsset.sol"; interface ITransferProxy { function transfer( LibAsset.Asset calldata asset, address from, address to ) external; }
contracts/exchange/assets/LibAsset.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library LibAsset { bytes4 public constant ETH_ASSET_CLASS = bytes4(keccak256("ETH")); bytes4 public constant ERC20_ASSET_CLASS = bytes4(keccak256("ERC20")); bytes4 public constant ERC721_ASSET_CLASS = bytes4(keccak256("ERC721")); bytes4 public constant ERC1155_ASSET_CLASS = bytes4(keccak256("ERC1155")); bytes32 constant ASSET_TYPE_TYPEHASH = keccak256("AssetType(bytes4 assetClass,bytes data)"); bytes32 constant ASSET_TYPEHASH = keccak256( "Asset(AssetType assetType,uint256 value)AssetType(bytes4 assetClass,bytes data)" ); struct AssetType { bytes4 assetClass; bytes data; } struct Asset { AssetType assetType; uint256 value; } function hash(AssetType memory assetType) internal pure returns (bytes32) { return keccak256( abi.encode( ASSET_TYPE_TYPEHASH, assetType.assetClass, keccak256(assetType.data) ) ); } function hash(Asset memory asset) internal pure returns (bytes32) { return keccak256( abi.encode(ASSET_TYPEHASH, hash(asset.assetType), asset.value) ); } }
contracts/tokens/testContracts/TestERC20.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol"; contract TestERC20 is ERC20Upgradeable { function __TestERC20_init(string memory name_, string memory symbol_) public initializer { __Context_init_unchained(); __ERC20_init_unchained(name_, symbol_); } function mint(address to, uint256 amount) external { _mint(to, amount); } }
contracts/tokens/ERC2981/IERC2981.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; /// /// @dev Interface for the NFT Royalty Standard /// interface IERC2981 is IERC165Upgradeable { /// ERC165 bytes to add to interface array - set in parent contract /// implementing this standard /// /// bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; /// _registerInterface(_INTERFACE_ID_ERC2981); /// @notice Called with the sale price to determine how much royalty // is owed and to whom. /// @param _tokenId - the NFT asset queried for royalty information /// @param _salePrice - the sale price of the NFT asset specified by _tokenId /// @return receiver - address of who should be sent the royalty payment /// @return royaltyAmount - the royalty payment amount for _salePrice function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view returns (address receiver, uint256 royaltyAmount); }
contracts/exchange/exchangeInterfaces/testContracts/ERC20TrasferProxy.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IERC20TransferProxy.sol"; contract ERC20TransferProxyTest is IERC20TransferProxy { function erc20safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) external override { require( token.transferFrom(from, to, value), "failure while transferring" ); } }
contracts/exchange/lib/LibBP.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; library LibBP { using SafeMathUpgradeable for uint256; function bp(uint256 value, uint256 bpValue) internal pure returns (uint256) { return value.mul(bpValue).div(uint256(10000)); } }
@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.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 `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
contracts/exchange/orderControl/testContracts/OrderValidatorTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../OrderValidator.sol"; contract OrderValidatorTest is OrderValidator { function __OrderValidatorTest_init( string memory name, string memory version ) external initializer { __OrderValidator_init(name, version); } function domainSeparator() external view returns (bytes32) { return _domainSeparatorV4(); } function validateOrderTest( LibOrder.Order calldata order, bytes calldata signature ) external view { return validate(order, signature); } }
contracts/exchange/LuxyCore.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LibFill.sol"; import "./orderControl/LibOrder.sol"; import "./orderControl/OrderValidator.sol"; import "./AssetMatcher.sol"; import "./TransferExecutor.sol"; import "./interfaces/ITransferManager.sol"; import "./lib/LibTransfer.sol"; abstract contract LuxyCore is Initializable, OwnableUpgradeable, AssetMatcher, TransferExecutor, OrderValidator, ITransferManager { using SafeMathUpgradeable for uint256; using LibTransfer for address; uint256 private constant UINT256_MAX = 2**256 - 1; //state of the orders mapping(bytes32 => uint256) public fills; //events event Cancel( bytes32 hash, address maker, LibAsset.AssetType makeAssetType, LibAsset.AssetType takeAssetType ); event Sale( bytes32 leftHash, bytes32 rightHash, address leftMaker, address rightMaker, uint256 newLeftFill, uint256 newRightFill, LibAsset.AssetType leftAsset, LibAsset.AssetType rightAsset ); function cancel(LibOrder.Order memory order) external { require(_msgSender() == order.maker, "not a maker"); require(order.salt != 0, "0 salt can't be used"); bytes32 orderKeyHash = LibOrder.hashKey(order); fills[orderKeyHash] = UINT256_MAX; emit Cancel( orderKeyHash, order.maker, order.makeAsset.assetType, order.takeAsset.assetType ); } function matchOrders( LibOrder.Order memory orderLeft, bytes memory signatureLeft, LibOrder.Order memory orderRight, bytes memory signatureRight ) external payable { validateFull(orderLeft, signatureLeft); validateFull(orderRight, signatureRight); if (orderLeft.taker != address(0)) { require( orderRight.maker == orderLeft.taker, "leftOrder.taker verification failed" ); } if (orderRight.taker != address(0)) { require( orderRight.taker == orderLeft.maker, "rightOrder.taker verification failed" ); } matchAndTransfer(orderLeft, orderRight); } function matchAndTransfer( LibOrder.Order memory orderLeft, LibOrder.Order memory orderRight ) internal { ( LibAsset.AssetType memory makeMatch, LibAsset.AssetType memory takeMatch ) = matchAssets(orderLeft, orderRight); bytes32 leftOrderKeyHash = LibOrder.hashKey(orderLeft); bytes32 rightOrderKeyHash = LibOrder.hashKey(orderRight); uint256 leftOrderFill = getOrderFill(orderLeft, leftOrderKeyHash); uint256 rightOrderFill = getOrderFill(orderRight, rightOrderKeyHash); LibFill.FillResult memory newFill = LibFill.fillOrder( orderLeft, orderRight, leftOrderFill, rightOrderFill ); require(newFill.takeValue > 0, "nothing to fill"); if (orderLeft.salt != 0) { fills[leftOrderKeyHash] = leftOrderFill.add(newFill.takeValue); } if (orderRight.salt != 0) { fills[rightOrderKeyHash] = rightOrderFill.add(newFill.makeValue); } (uint256 totalMakeValue, uint256 totalTakeValue) = doTransfers( makeMatch, takeMatch, newFill, orderLeft, orderRight ); if (makeMatch.assetClass == LibAsset.ETH_ASSET_CLASS) { require(takeMatch.assetClass != LibAsset.ETH_ASSET_CLASS); require(msg.value >= totalMakeValue, "not enough eth"); if (msg.value > totalMakeValue) { address(msg.sender).transferEth(msg.value.sub(totalMakeValue)); } } else if (takeMatch.assetClass == LibAsset.ETH_ASSET_CLASS) { require(msg.value >= totalTakeValue, "not enough eth"); if (msg.value > totalTakeValue) { address(msg.sender).transferEth(msg.value.sub(totalTakeValue)); } } emit Sale( leftOrderKeyHash, rightOrderKeyHash, orderLeft.maker, orderRight.maker, newFill.takeValue, newFill.makeValue, makeMatch, takeMatch ); } function getOrderFill(LibOrder.Order memory order, bytes32 hash) internal view returns (uint256 fill) { if (order.salt == 0) { fill = 0; } else { fill = fills[hash]; } } function matchAssets( LibOrder.Order memory orderLeft, LibOrder.Order memory orderRight ) internal view returns ( LibAsset.AssetType memory makeMatch, LibAsset.AssetType memory takeMatch ) { makeMatch = matchAssets( orderLeft.makeAsset.assetType, orderRight.takeAsset.assetType ); require(makeMatch.assetClass != 0, "assets don't match"); takeMatch = matchAssets( orderLeft.takeAsset.assetType, orderRight.makeAsset.assetType ); require(takeMatch.assetClass != 0, "assets don't match"); } function validateFull(LibOrder.Order memory order, bytes memory signature) internal view { LibOrder.validate(order); validate(order, signature); } uint256[50] private __gap; }
contracts/launchpad/DropWithVoucher/ERC721LuxyVoucher.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,,x _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/utils/Counters.sol"; import "../../royalties-default/RoyaltiesV1Luxy.sol"; import "../../tokens/ERC2981-default/IERC2981.sol"; import "./Voucher.sol"; contract ERC721LuxyVoucher is Ownable, RoyaltiesV1Luxy, ERC721Enumerable { using Counters for Counters.Counter; Counters.Counter private _tokenIds; string public baseURI; //Uncomment this section to enable whitelist // IERC20Upgradeable luxy; address public artist; address public luxyLaunchpadFeeManagerProxy; uint256 public constant MAX_BATCH_MINT = 10; uint256 public constant MAX_SUPPLY = 50; uint256 public constant DROP_START_TIME = 1; uint256 public constant PRICE_PER_TOKEN = 1 ether; uint256 public whitelistSize; uint256 public constant WHITELIST_EXPIRE_TIME = 0 minutes; struct PrizeMeta { bool isClaimed; address claimer; uint256 time; } mapping(address => bool) private _whitelist; mapping(uint256 => PrizeMeta) public prizeInfo; mapping(uint256 => bool) internal prizeById; mapping(uint256 => uint256) private _assignOrders; ERC721Voucher public voucherContract; event Claim(PrizeMeta prizeInfo); constructor( address _voucherContract, address _luxyLaunchpadFeeManagerProxy, uint256[] memory ids, address _artist ) ERC721("LuxyVoucherTest010", "LVNFT") { voucherContract = ERC721Voucher(_voucherContract); luxyLaunchpadFeeManagerProxy = _luxyLaunchpadFeeManagerProxy; artist = _artist; for (uint256 i = 0; i < ids.length; i++) { prizeById[ids[i]] = true; } } function mint(uint256 num, address minter) external { require( _msgSender() == luxyLaunchpadFeeManagerProxy, "ERC721LuxyVoucher: Not allowed" ); require( block.timestamp > DROP_START_TIME, "ERC721LuxyVoucher: Drop hasnt started yet" ); require( num <= MAX_BATCH_MINT, "ERC721LuxyVoucher: Exceeds max batch per mint" ); require( totalSupply() + num <= MAX_SUPPLY, "ERC721LuxyVoucher: Exceeds drop max supply" ); // Uncomment this section to enable whitelist if (block.timestamp < DROP_START_TIME + WHITELIST_EXPIRE_TIME) { require(isWhitelisted(minter), "Not whitelisted"); } // Uncomment this section to enable LUXY Sale // if (block.timestamp < DROP_START_TIME + LUXY_SALE_EXPIRE_TIME) { // require( // luxy.balanceOf(minter) > MINIMUM_LUXY_AMOUNT, // "Not elegible to Luxy sale" // ); // } for (uint256 i; i < num; i++) { // uint256 genesisRemainingToAssign = MAX_SUPPLY - totalSupply(); // uint256 randIndex = _random() % genesisRemainingToAssign; // uint256 genesisIndex = _fillAssignOrder( // genesisRemainingToAssign, // randIndex // ); uint256 tokenId = _tokenIds.current(); _safeMint(minter, tokenId); // Switch to genesisIndex for random mint, for testing is easier to use linear order // _safeMint(minter, genesisIndex); _tokenIds.increment(); if (prizeById[tokenId]) { voucherContract.mint(tokenId, minter); } } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override(ERC721Enumerable, IERC165) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC721Enumerable).interfaceId || _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}. */ function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } /** * @dev Base URI for computing {tokenURI}. The resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. * See {ERC721Upgradeable-_baseURI}. */ function _baseURI() internal view override returns (string memory) { return baseURI; } /** * @dev See {ERC721EnumerableUpgradeable-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override { super._beforeTokenTransfer(from, to, tokenId, batchSize); } function _afterTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override { if ( prizeById[tokenId] && from != address(0) && !prizeInfo[tokenId].isClaimed ) { voucherContract.safeTransferFrom(from, to, tokenId); } super._afterTokenTransfer(from, to, tokenId, batchSize); } function claim(uint256 tokenId) external { address owner = ERC721.ownerOf(tokenId); require( _msgSender() == owner, "ERC721LuxyVoucher: MSGSender is not the owner" ); require( prizeInfo[tokenId].isClaimed == false, "ERC721LuxyVoucher: Already Claimed" ); voucherContract.burn(tokenId); prizeInfo[tokenId].claimer = _msgSender(); prizeInfo[tokenId].isClaimed = true; prizeInfo[tokenId].time = block.timestamp; emit Claim(prizeInfo[tokenId]); } function isClaimed(uint256 tokenId) external view returns (bool) { require( prizeById[tokenId] == true, "ERC721LuxyVoucher: There is no prize associated to this NFT" ); if ( prizeInfo[tokenId].isClaimed || voucherContract.ownerOf(tokenId) == address(0) ) { return true; } return false; } function claimer(uint256 tokenId) external view returns (address) { return prizeInfo[tokenId].claimer; } function claimDate(uint256 tokenId) external view returns (uint256) { return prizeInfo[tokenId].time; } function _fillAssignOrder(uint256 orderA, uint256 orderB) internal returns (uint256) { uint256 temp = orderA; if (_assignOrders[orderA] > 0) temp = _assignOrders[orderA]; _assignOrders[orderA] = orderB; if (_assignOrders[orderB] > 0) _assignOrders[orderA] = _assignOrders[orderB]; _assignOrders[orderB] = temp; return _assignOrders[orderA]; } // pseudo-random function that's pretty robust because of syscoin's pow chainlocks function _random() internal view returns (uint256) { uint256 genesisRemainingToAssign = MAX_SUPPLY - totalSupply(); return uint256( keccak256( abi.encodePacked( block.timestamp + block.difficulty + (( uint256( keccak256(abi.encodePacked(block.coinbase)) ) ) / block.timestamp) + block.gaslimit + (( uint256( keccak256(abi.encodePacked(_msgSender())) ) ) / block.timestamp) + block.number ) ) ) / genesisRemainingToAssign; } //Uncomment this section to enable whitelist function isWhitelisted(address addr) public view returns (bool) { return _whitelist[addr]; } function addToWhitelist(address[] memory addresses) external onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { if (!isWhitelisted(addresses[i])) { _whitelist[addresses[i]] = true; } whitelistSize++; } } function removeFromWhitelist(address[] memory addresses) external onlyOwner { for (uint256 i = 0; i < addresses.length; i++) { if (isWhitelisted(addresses[i])) { _whitelist[addresses[i]] = false; whitelistSize--; } } } }
@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721Enumerable is IERC721 { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
contracts/tokens/testContracts/TestERC721Royalty.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "../../RoyaltiesV1Luxy.sol"; contract TestERC721Royalty is ERC721Upgradeable, RoyaltiesV1Luxy { function __TestERC721_init(string memory name_, string memory symbol_) public initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function mint(address to, uint256 tokenId, LibPart.Part[] memory _royalties) external { _mint(to, tokenId); _setRoyalties(tokenId, _royalties); } }
contracts/RoyaltiesV2Rarible.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LibPart.sol"; interface RoyaltiesV2Rarible { event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties); function getRaribleV2Royalties(uint256 id) external view returns (LibPart.Part[] memory); }
@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721EnumerableUpgradeable is IERC721Upgradeable { /** * @dev Returns the total amount of tokens stored by the contract. */ function totalSupply() external view returns (uint256); /** * @dev Returns a token ID owned by `owner` at a given `index` of its token list. * Use along with {balanceOf} to enumerate all of ``owner``'s tokens. */ function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256); /** * @dev Returns a token ID at a given `index` of all the tokens stored by the contract. * Use along with {totalSupply} to enumerate all tokens. */ function tokenByIndex(uint256 index) external view returns (uint256); }
@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "./IERC721EnumerableUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable { function __ERC721Enumerable_init() internal onlyInitializing { } function __ERC721Enumerable_init_unchained() internal onlyInitializing { } // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) { return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721Upgradeable.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[46] private __gap; }
@openzeppelin/contracts-upgradeable/interfaces/IERC1271Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC1271 standard signature validation method for * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271]. * * _Available since v4.1._ */ interface IERC1271Upgradeable { /** * @dev Should return whether the signature provided is valid for the provided data * @param hash Hash of the data to be signed * @param signature Signature byte array associated with _data */ function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue); }
@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol) pragma solidity ^0.8.2; import "../../utils/AddressUpgradeable.sol"; /** * @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 proxied contracts do not make use of 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. * * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in * case an upgrade adds a module that needs to be initialized. * * For example: * * [.hljs-theme-light.nopadding] * ``` * contract MyToken is ERC20Upgradeable { * function initialize() initializer public { * __ERC20_init("MyToken", "MTK"); * } * } * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable { * function initializeV2() reinitializer(2) public { * __ERC20Permit_init("MyToken"); * } * } * ``` * * 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 prevent the implementation contract from being used, you should invoke * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() { * _disableInitializers(); * } * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. * @custom:oz-retyped-from bool */ uint8 private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Triggered when the contract has been initialized or reinitialized. */ event Initialized(uint8 version); /** * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope, * `onlyInitializing` functions can be used to initialize parent contracts. * * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a * constructor. * * Emits an {Initialized} event. */ modifier initializer() { bool isTopLevelCall = !_initializing; require( (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1), "Initializable: contract is already initialized" ); _initialized = 1; if (isTopLevelCall) { _initializing = true; } _; if (isTopLevelCall) { _initializing = false; emit Initialized(1); } } /** * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be * used to initialize parent contracts. * * A reinitializer may be used after the original initialization step. This is essential to configure modules that * are added through upgrades and that require initialization. * * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer` * cannot be nested. If one is invoked in the context of another, execution will revert. * * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in * a contract, executing them in the right order is up to the developer or operator. * * WARNING: setting the version to 255 will prevent any future reinitialization. * * Emits an {Initialized} event. */ modifier reinitializer(uint8 version) { require(!_initializing && _initialized < version, "Initializable: contract is already initialized"); _initialized = version; _initializing = true; _; _initializing = false; emit Initialized(version); } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} and {reinitializer} modifiers, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } /** * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call. * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized * to any version. It is recommended to use this to lock implementation contracts that are designed to be called * through proxies. * * Emits an {Initialized} event the first time it is successfully executed. */ function _disableInitializers() internal virtual { require(!_initializing, "Initializable: contract is initializing"); if (_initialized < type(uint8).max) { _initialized = type(uint8).max; emit Initialized(type(uint8).max); } } /** * @dev Returns the highest version that has been initialized. See {reinitializer}. */ function _getInitializedVersion() internal view returns (uint8) { return _initialized; } /** * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}. */ function _isInitializing() internal view returns (bool) { return _initializing; } }
@openzeppelin/contracts/token/ERC721/IERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721 is IERC165 { /** * @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`. * * 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; /** * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 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 the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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); }
contracts/exchange/lib/LibFeeSide.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../assets/LibAsset.sol"; library LibFeeSide { enum FeeSide { NONE, MAKE, TAKE } function getFeeSide(bytes4 make, bytes4 take) internal pure returns (FeeSide) { if (make == LibAsset.ETH_ASSET_CLASS) { return FeeSide.MAKE; } if (take == LibAsset.ETH_ASSET_CLASS) { return FeeSide.TAKE; } if (make == LibAsset.ERC20_ASSET_CLASS) { return FeeSide.MAKE; } if (take == LibAsset.ERC20_ASSET_CLASS) { return FeeSide.TAKE; } if (make == LibAsset.ERC1155_ASSET_CLASS) { return FeeSide.MAKE; } if (take == LibAsset.ERC1155_ASSET_CLASS) { return FeeSide.TAKE; } return FeeSide.NONE; } }
contracts/exchange/AssetMatcher.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./interfaces/IAssetMatcher.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; abstract contract AssetMatcher is Initializable, OwnableUpgradeable { bytes constant EMPTY = ""; mapping(bytes4 => address) matchers; event MatcherChange(bytes4 indexed assetType, address matcher); function setAssetMatcher(bytes4 assetType, address matcher) external onlyOwner { matchers[assetType] = matcher; emit MatcherChange(assetType, matcher); } function matchAssets( LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType ) internal view returns (LibAsset.AssetType memory) { LibAsset.AssetType memory result = matchAssetOneSide( leftAssetType, rightAssetType ); if (result.assetClass == 0) { return matchAssetOneSide(rightAssetType, leftAssetType); } else { return result; } } function matchAssetOneSide( LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType ) private view returns (LibAsset.AssetType memory) { bytes4 classLeft = leftAssetType.assetClass; bytes4 classRight = rightAssetType.assetClass; if (classLeft == LibAsset.ETH_ASSET_CLASS) { if (classRight == LibAsset.ETH_ASSET_CLASS) { return leftAssetType; } return LibAsset.AssetType(0, EMPTY); } if (classLeft == LibAsset.ERC20_ASSET_CLASS) { if (classRight == LibAsset.ERC20_ASSET_CLASS) { return simpleMatch(leftAssetType, rightAssetType); } return LibAsset.AssetType(0, EMPTY); } if (classLeft == LibAsset.ERC721_ASSET_CLASS) { if (classRight == LibAsset.ERC721_ASSET_CLASS) { return simpleMatch(leftAssetType, rightAssetType); } return LibAsset.AssetType(0, EMPTY); } if (classLeft == LibAsset.ERC1155_ASSET_CLASS) { if (classRight == LibAsset.ERC1155_ASSET_CLASS) { return simpleMatch(leftAssetType, rightAssetType); } return LibAsset.AssetType(0, EMPTY); } address matcher = matchers[classLeft]; if (matcher != address(0)) { return IAssetMatcher(matcher).matchAssets( leftAssetType, rightAssetType ); } if (classLeft == classRight) { return simpleMatch(leftAssetType, rightAssetType); } revert("not found IAssetMatcher"); } function simpleMatch( LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType ) private pure returns (LibAsset.AssetType memory) { bytes32 leftHash = keccak256(leftAssetType.data); bytes32 rightHash = keccak256(rightAssetType.data); if (leftHash == rightHash) { return leftAssetType; } return LibAsset.AssetType(0, EMPTY); } uint256[50] private __gap; }
@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165Storage.sol) pragma solidity ^0.8.0; import "./ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Storage based implementation of the {IERC165} interface. * * Contracts may inherit from this and call {_registerInterface} to declare * their support of an interface. */ abstract contract ERC165StorageUpgradeable is Initializable, ERC165Upgradeable { function __ERC165Storage_init() internal onlyInitializing { } function __ERC165Storage_init_unchained() internal onlyInitializing { } /** * @dev Mapping of interface ids to whether or not it's supported. */ mapping(bytes4 => bool) private _supportedInterfaces; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return super.supportsInterface(interfaceId) || _supportedInterfaces[interfaceId]; } /** * @dev Registers the contract as an implementer of the interface defined by * `interfaceId`. Support of the actual ERC165 interface is automatic and * registering its interface id is not required. * * See {IERC165-supportsInterface}. * * Requirements: * * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`). */ function _registerInterface(bytes4 interfaceId) internal virtual { require(interfaceId != 0xffffffff, "ERC165: invalid interface id"); _supportedInterfaces[interfaceId] = true; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.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 IERC721Receiver { /** * @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 `IERC721Receiver.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
contracts/exchange/orderControl/testContracts/LibSignatureTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../lib/LibSignature.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; contract LibSignatureTest is EIP712Upgradeable { using LibSignature for bytes32; function recoverFromSigTest(bytes32 hash, bytes memory signature) external pure returns (address) { return hash.recover(signature); } function recoverFromParamsTest( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) external pure returns (address) { return hash.recover(v, r, s); } function getKeccak(string memory message) external pure returns (bytes32) { return keccak256(bytes(message)); } }
@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol) pragma solidity ^0.8.0; import "./math/MathUpgradeable.sol"; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _SYMBOLS = "0123456789abcdef"; uint8 private constant _ADDRESS_LENGTH = 20; /** * @dev Converts a `uint256` to its ASCII `string` decimal representation. */ function toString(uint256 value) internal pure returns (string memory) { unchecked { uint256 length = MathUpgradeable.log10(value) + 1; string memory buffer = new string(length); uint256 ptr; /// @solidity memory-safe-assembly assembly { ptr := add(buffer, add(32, length)) } while (true) { ptr--; /// @solidity memory-safe-assembly assembly { mstore8(ptr, byte(mod(value, 10), _SYMBOLS)) } value /= 10; if (value == 0) break; } return buffer; } } /** * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation. */ function toHexString(uint256 value) internal pure returns (string memory) { unchecked { return toHexString(value, MathUpgradeable.log256(value) + 1); } } /** * @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] = _SYMBOLS[value & 0xf]; value >>= 4; } require(value == 0, "Strings: hex length insufficient"); return string(buffer); } /** * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation. */ function toHexString(address addr) internal pure returns (string memory) { return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH); } }
@openzeppelin/contracts-upgradeable/token/ERC20/extensions/IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol) pragma solidity ^0.8.0; import "../IERC20Upgradeable.sol"; /** * @dev Interface for the optional metadata functions from the ERC20 standard. * * _Available since v4.1._ */ interface IERC20MetadataUpgradeable is IERC20Upgradeable { /** * @dev Returns the name of the token. */ function name() external view returns (string memory); /** * @dev Returns the symbol of the token. */ function symbol() external view returns (string memory); /** * @dev Returns the decimals places of the token. */ function decimals() external view returns (uint8); }
contracts/tokens/testContracts/TestERC1155.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; contract TestERC1155 is ERC1155Upgradeable { function __TestERC1155_init(string memory uri_) public initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC1155_init_unchained(uri_); } function mint( address to, uint256 tokenId, uint256 amount ) external { _mint(to, tokenId, amount, ""); } }
@openzeppelin/contracts/utils/introspection/IERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 IERC165 { /** * @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); }
contracts/exchange/testContracts/LibFillTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../LibFill.sol"; import "../orderControl/LibOrder.sol"; contract LibFillTest { function fillOrder( LibOrder.Order calldata leftOrder, LibOrder.Order calldata rightOrder, uint256 leftOrderFill, uint256 rightOrderFill ) external pure returns (LibFill.FillResult memory) { return LibFill.fillOrder( leftOrder, rightOrder, leftOrderFill, rightOrderFill ); } }
contracts/exchange/LibFill.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./orderControl/LibOrder.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol"; library LibFill { using SafeMathUpgradeable for uint256; struct FillResult { uint256 makeValue; uint256 takeValue; } /** * @dev Should return filled values * @param leftOrder left order * @param rightOrder right order * @param leftOrderFill current fill of the left order (0 if order is unfilled) * @param rightOrderFill current fill of the right order (0 if order is unfilled) */ function fillOrder( LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder, uint256 leftOrderFill, uint256 rightOrderFill ) internal pure returns (FillResult memory) { (uint256 leftMakeValue, uint256 leftTakeValue) = LibOrder .calculateRemaining(leftOrder, leftOrderFill); (uint256 rightMakeValue, uint256 rightTakeValue) = LibOrder .calculateRemaining(rightOrder, rightOrderFill); //We have 3 cases here: if (rightTakeValue > leftMakeValue) { //1nd: left order should be fully filled return fillLeft( leftMakeValue, leftTakeValue, rightOrder.makeAsset.value, rightOrder.takeAsset.value ); } //2st: right order should be fully filled or 3d: both should be fully filled if required values are the same return fillRight( leftOrder.makeAsset.value, leftOrder.takeAsset.value, rightMakeValue, rightTakeValue ); } function fillRight( uint256 leftMakeValue, uint256 leftTakeValue, uint256 rightMakeValue, uint256 rightTakeValue ) internal pure returns (FillResult memory result) { uint256 makerValue = LibMath.safeGetPartialAmountFloor( rightTakeValue, leftMakeValue, leftTakeValue ); require(makerValue <= rightMakeValue, "fillRight: unable to fill"); return FillResult(rightTakeValue, makerValue); } function fillLeft( uint256 leftMakeValue, uint256 leftTakeValue, uint256 rightMakeValue, uint256 rightTakeValue ) internal pure returns (FillResult memory result) { uint256 rightTake = LibMath.safeGetPartialAmountFloor( leftTakeValue, rightMakeValue, rightTakeValue ); require(rightTake <= leftMakeValue, "fillLeft: unable to fill"); return FillResult(leftMakeValue, leftTakeValue); } }
@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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); }
contracts/tokens/ERC1155/ERC1155Luxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; import "./ERC1155BaseUri.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "../../RoyaltiesV1Luxy.sol"; import "../ERC1271/ERC1271.sol"; contract ERC1155Luxy is OwnableUpgradeable, ERC1155BurnableUpgradeable, ERC1155BaseURI, RoyaltiesV1Luxy { string public name; string public symbol; bool public isChangeable; uint256 public maxSupply; mapping(address => bool) private defaultApprovals; event DefaultApproval(address indexed operator, bool hasApproval); using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private _tokenIds; function __ERC1155Luxy_init( string memory _name, string memory _symbol, string memory _baseURI, bool _isChangeable, uint256 _maxSupply ) public initializer { name = _name; symbol = _symbol; __Ownable_init_unchained(); __ERC1155Burnable_init_unchained(); __Context_init_unchained(); __ERC165_init_unchained(); _setBaseURI(_baseURI); _setChangeable(_isChangeable); _setMaxSupply(_maxSupply); } function __ERC1155Luxy_init_unchained(string memory _baseURI, bool _isChangeable, uint256 _maxSupply) internal initializer { _setBaseURI(_baseURI); _setChangeable(_isChangeable); _setMaxSupply(_maxSupply); } function _setDefaultApproval(address operator, bool hasApproval) internal { defaultApprovals[operator] = hasApproval; emit DefaultApproval(operator, hasApproval); } function isApprovedForAll(address _owner, address _operator) public view override returns (bool) { return defaultApprovals[_operator] || super.isApprovedForAll(_owner, _operator); } function setDefaultApproval(address operator, bool hasApproval) external onlyOwner { _setDefaultApproval(operator, hasApproval); } function uri(uint256 id) public view virtual override(ERC1155BaseURI, ERC1155Upgradeable) returns (string memory) { return _tokenURI(id); } function mint( address account, uint256 amount, LibPart.Part[] memory royalties, string memory tokenURI ) public { uint256 id = _tokenIds.current(); if(maxSupply != 0){ require(id < maxSupply, "ERC721: minting above the total supply"); } _mint(account, id, amount, ""); _setRoyalties(id, royalties); _setTokenURI(id, tokenURI); _tokenIds.increment(); } function transferFrom( uint256 id, address from, address to, uint256 amount ) public { uint256 balance = balanceOf(from, id); if (balance != 0) { require(balance >= amount, "Insufficient balance"); super.safeTransferFrom(from, to, id, amount, ""); } } function updateAccount( uint256 _id, address _from, address _to ) external { require(_msgSender() == _from, "not allowed"); super._updateAccount(_id, _from, _to); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override(ERC1155Upgradeable, ERC1155BaseURI, IERC165Upgradeable) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC1155BaseURI).interfaceId || _interfaceId == type(ERC1155BurnableUpgradeable).interfaceId || _interfaceId == type(OwnableUpgradeable).interfaceId || _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); } function _setMaxSupply(uint256 maxSupply_) internal virtual { maxSupply = maxSupply_; } function getMaxSupply() public view returns (uint256) { require(maxSupply > 0, "There is no MaxSupply for this collection."); return maxSupply; } /** * @dev External function to allow base URI changes when necessary. */ function setBaseURI(string memory baseURI_) external onlyOwner { require(isChangeable, "Base URI is not changeable."); _setBaseURI(baseURI_); } /** * @dev Internal function to set changeability of BaseURI for NFT drops. */ function _setChangeable(bool isChangeable_) internal virtual { isChangeable = isChangeable_; } uint256[100] private __gap; }
@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC20 standard as defined in the EIP. */ interface IERC20Upgradeable { /** * @dev Emitted when `value` tokens are moved from one account (`from`) to * another (`to`). * * Note that `value` may be zero. */ event Transfer(address indexed from, address indexed to, uint256 value); /** * @dev Emitted when the allowance of a `spender` for an `owner` is set by * a call to {approve}. `value` is the new allowance. */ event Approval(address indexed owner, address indexed spender, uint256 value); /** * @dev Returns the amount of tokens in existence. */ function totalSupply() external view returns (uint256); /** * @dev Returns the amount of tokens owned by `account`. */ function balanceOf(address account) external view returns (uint256); /** * @dev Moves `amount` tokens from the caller's account to `to`. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transfer(address to, uint256 amount) external returns (bool); /** * @dev Returns the remaining number of tokens that `spender` will be * allowed to spend on behalf of `owner` through {transferFrom}. This is * zero by default. * * This value changes when {approve} or {transferFrom} are called. */ function allowance(address owner, address spender) external view returns (uint256); /** * @dev Sets `amount` as the allowance of `spender` over the caller's tokens. * * Returns a boolean value indicating whether the operation succeeded. * * IMPORTANT: Beware that changing an allowance with this method brings the risk * that someone may use both the old and the new allowance by unfortunate * transaction ordering. One possible solution to mitigate this race * condition is to first reduce the spender's allowance to 0 and set the * desired value afterwards: * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729 * * Emits an {Approval} event. */ function approve(address spender, uint256 amount) external returns (bool); /** * @dev Moves `amount` tokens from `from` to `to` using the * allowance mechanism. `amount` is then deducted from the caller's * allowance. * * Returns a boolean value indicating whether the operation succeeded. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 amount ) external returns (bool); }
contracts/exchange/TransferExecutor.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./assets/LibAsset.sol"; import "./exchangeInterfaces/ITransferProxy.sol"; import "./exchangeInterfaces/INftTransferProxy.sol"; import "./exchangeInterfaces/IERC20TransferProxy.sol"; import "./interfaces/ITransferExecutor.sol"; import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "./lib/LibTransfer.sol"; abstract contract TransferExecutor is Initializable, OwnableUpgradeable, ITransferExecutor { using LibTransfer for address; using SafeMathUpgradeable for uint256; address public feeWallet; address public burningWallet; address luxyAddress; uint256 public burningPercent; mapping(bytes4 => address) proxies; event ProxyChange(bytes4 indexed assetType, address proxy); bool burnMode; bytes4 private constant PROTOCOL = bytes4(keccak256("PROTOCOL")); function __TransferExecutor_init_unchained( INftTransferProxy transferProxy, IERC20TransferProxy erc20TransferProxy, address _feeWallet, address _burningWallet, address _luxyAddress, uint256 _burningPercent ) internal { proxies[LibAsset.ERC20_ASSET_CLASS] = address(erc20TransferProxy); proxies[LibAsset.ERC721_ASSET_CLASS] = address(transferProxy); proxies[LibAsset.ERC1155_ASSET_CLASS] = address(transferProxy); feeWallet = _feeWallet; burningWallet = _burningWallet; luxyAddress = _luxyAddress; burningPercent = _burningPercent; burnMode = false; } function setBurnMode(bool _burnMode) external onlyOwner { burnMode = _burnMode; } function setLuxyAddress(address _luxyAddress) external onlyOwner { luxyAddress = _luxyAddress; } function setBurningPercent(uint256 _burningPercent) external onlyOwner { require(_burningPercent <= 100); require(_burningPercent > 0); burningPercent = _burningPercent; } function setFeeWallet(address _feeWallet) external onlyOwner { feeWallet = _feeWallet; } function setBurningWallet(address _burningWallet) external onlyOwner { burningWallet = _burningWallet; } function setTransferProxy(bytes4 assetType, address proxy) external onlyOwner { proxies[assetType] = proxy; emit ProxyChange(assetType, proxy); } function transfer( LibAsset.Asset memory asset, address from, address to, bytes4 transferDirection, bytes4 transferType ) internal override { if (asset.assetType.assetClass == LibAsset.ETH_ASSET_CLASS) { if (transferType == PROTOCOL && burnMode == true) { uint256 amountBurn = asset.value.mul(burningPercent).div(100); uint256 amountFee = asset.value.sub(amountBurn); if (amountBurn > 0) { burningWallet.transferEth(amountBurn); } feeWallet.transferEth(amountFee); } else { to.transferEth(asset.value); } } else if (asset.assetType.assetClass == LibAsset.ERC20_ASSET_CLASS) { address token = abi.decode(asset.assetType.data, (address)); if (transferType == PROTOCOL && burnMode == true) { uint256 amountBurn = asset.value.mul(burningPercent).div(100); uint256 amountFee = asset.value.sub(amountBurn); if (token == luxyAddress) { IERC20TransferProxy(proxies[LibAsset.ERC20_ASSET_CLASS]) .erc20safeTransferFrom( IERC20Upgradeable(token), from, burningWallet, asset.value ); } else { IERC20TransferProxy(proxies[LibAsset.ERC20_ASSET_CLASS]) .erc20safeTransferFrom( IERC20Upgradeable(token), from, feeWallet, amountFee ); if (amountBurn > 0) { IERC20TransferProxy(proxies[LibAsset.ERC20_ASSET_CLASS]) .erc20safeTransferFrom( IERC20Upgradeable(token), from, burningWallet, amountBurn ); } } } else { IERC20TransferProxy(proxies[LibAsset.ERC20_ASSET_CLASS]) .erc20safeTransferFrom( IERC20Upgradeable(token), from, to, asset.value ); } } else if (asset.assetType.assetClass == LibAsset.ERC721_ASSET_CLASS) { (address token, uint256 tokenId) = abi.decode( asset.assetType.data, (address, uint256) ); require(asset.value == 1, "erc721 value error"); INftTransferProxy(proxies[LibAsset.ERC721_ASSET_CLASS]) .erc721safeTransferFrom( IERC721Upgradeable(token), from, to, tokenId ); } else if (asset.assetType.assetClass == LibAsset.ERC1155_ASSET_CLASS) { (address token, uint256 tokenId) = abi.decode( asset.assetType.data, (address, uint256) ); INftTransferProxy(proxies[LibAsset.ERC1155_ASSET_CLASS]) .erc1155safeTransferFrom( IERC1155Upgradeable(token), from, to, tokenId, asset.value, "" ); } else { ITransferProxy(proxies[asset.assetType.assetClass]).transfer( asset, from, to ); } emit Transfer(asset, from, to, transferDirection, transferType); } uint256[50] private __gap; }
contracts/exchange/lib/LibTransfer.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library LibTransfer { function transferEth(address to, uint256 value) internal { (bool success, ) = to.call{value: value}(""); require(success, "transfer failed"); } }
contracts/exchange/LuxyTransferManager.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; import "./assets/LibAsset.sol"; import "../tokens/ERC721/ERC721Luxy.sol"; import "../tokens/ERC1155/ERC1155Luxy.sol"; import "./LibFill.sol"; import "./lib/LibFeeSide.sol"; import "./interfaces/ITransferManager.sol"; import "./interfaces/ITransferExecutor.sol"; import "./orderControl/LibOrderData.sol"; import "./lib/LibBP.sol"; import "./orderControl/LibOrderDataV1.sol"; import "../Royalties-registry/IRoyaltiesProvider.sol"; import "../LibsDiscount.sol"; abstract contract LuxyTransferManager is OwnableUpgradeable, ITransferManager { using LibBP for uint256; using SafeMathUpgradeable for uint256; uint256 public protocolFee; IRoyaltiesProvider public royaltiesRegistry; address public defaultFeeReceiver; uint256 public maxPercentRoyalties; mapping(address => address) public feeReceivers; mapping(address => uint256) public protocolFeeMake; mapping(address => uint256) public protocolFeeTake; mapping(address => bool) public protocolFeeSet; address public tierToken; LibTier.Tier[] public tiers; LibNFTHolder.NFTHolder[] public nftHolders; struct Fee { uint256 maker; uint256 taker; address token; address token2; } function __LuxyTransferManager_init_unchained( uint256 newProtocolFee, address newDefaultFeeReceiver, IRoyaltiesProvider newRoyaltiesProvider ) internal initializer { protocolFee = newProtocolFee; defaultFeeReceiver = newDefaultFeeReceiver; royaltiesRegistry = newRoyaltiesProvider; maxPercentRoyalties = 98000; } function setRoyaltiesRegistry(IRoyaltiesProvider newRoyaltiesRegistry) external onlyOwner { royaltiesRegistry = newRoyaltiesRegistry; } function setProtocolFee(uint256 newProtocolFee) external onlyOwner { protocolFee = newProtocolFee; } function setMaxPercentRoyalties(uint256 newPercentage) external onlyOwner { maxPercentRoyalties = newPercentage; } function setDefaultFeeReceiver(address payable newDefaultFeeReceiver) external onlyOwner { require( newDefaultFeeReceiver != address(0), "Default receiving address must be different than 0" ); defaultFeeReceiver = newDefaultFeeReceiver; } function setSpecialProtocolFee( address token, uint256 newProtocolFeeMake, uint256 newProtocolFeeTake ) external onlyOwner { protocolFeeMake[token] = newProtocolFeeMake; protocolFeeTake[token] = newProtocolFeeTake; protocolFeeSet[token] = true; } function setMakeProtocolFee(address token, uint256 newProtocolFeeMake) external onlyOwner { protocolFeeMake[token] = newProtocolFeeMake; protocolFeeSet[token] = true; } function setTakeProtocolFee(address token, uint256 newProtocolFeeTake) external onlyOwner { protocolFeeTake[token] = newProtocolFeeTake; protocolFeeSet[token] = true; } function setFeeReceiver(address token, address wallet) external onlyOwner { feeReceivers[token] = wallet; } function setNFTHolder(address token, uint96 percentual) external onlyOwner { require( token != address(0), "NFT contract address for holder must be different than 0" ); for (uint256 i = 0; i < nftHolders.length; i++) { if (nftHolders[i].token == token) { nftHolders[i].percentual = percentual; return; } } LibNFTHolder.NFTHolder memory newToken; newToken.token = token; newToken.percentual = percentual; nftHolders.push(newToken); } function removeNFTHolder(address token) external onlyOwner { for (uint256 i = 0; i < nftHolders.length; i++) { if (nftHolders[i].token == token) { delete nftHolders[i]; break; } } } function setTiers(LibTier.Tier[] memory _tiers) external onlyOwner { require( tierToken != address(0), "You must first set address of the tierToken at setTierToken" ); for (uint256 i = 0; i < tiers.length; i++) { delete tiers[i]; } for (uint256 i = 0; i < _tiers.length; i++) { require( _tiers[i].value >= 0, "Value can't be negative for tiers amount" ); require( _tiers[i].percentual >= 0, "Percentual of Protocol Fee must be greater or equal to zero" ); tiers.push(_tiers[i]); } } function setTierToken(address _token) external onlyOwner { require(_token != address(0), "Tier Token can't be address(0)"); tierToken = _token; } function getUserTier(address account) public view returns (uint256) { if (tierToken == address(0)) { return 200; } IERC20Upgradeable token = IERC20Upgradeable(tierToken); uint256 balance = token.balanceOf(account); uint256 feepercentual = 200; for (uint256 i = 0; i < tiers.length; i++) { if (tiers[i].value <= balance) { if (tiers[i].percentual <= feepercentual) { feepercentual = tiers[i].percentual; } } } return feepercentual; } function getHolderDiscount(address account) public view returns (uint256) { uint256 discount = 200; for (uint256 i = 0; i < nftHolders.length; i++) { if (nftHolders[i].token != address(0)) { if ( IERC721Upgradeable(nftHolders[i].token).balanceOf(account) > 0 ) { discount = nftHolders[i].percentual; } } } return discount; } function getFeeReceiver(address token) internal view returns (address) { address wallet = feeReceivers[token]; if (wallet != address(0)) { return wallet; } return defaultFeeReceiver; } function doTransfers( LibAsset.AssetType memory makeMatch, LibAsset.AssetType memory takeMatch, LibFill.FillResult memory fill, LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder ) internal override returns (uint256 totalMakeValue, uint256 totalTakeValue) { LibFeeSide.FeeSide feeSide = LibFeeSide.getFeeSide( makeMatch.assetClass, takeMatch.assetClass ); totalMakeValue = fill.makeValue; totalTakeValue = fill.takeValue; LibOrderDataV1.DataV1 memory leftOrderData = LibOrderData.parse( leftOrder ); LibOrderDataV1.DataV1 memory rightOrderData = LibOrderData.parse( rightOrder ); if (feeSide == LibFeeSide.FeeSide.MAKE) { totalMakeValue = doTransfersWithFees( fill.makeValue, (leftOrder.maker == address(0)) ? _msgSender() : leftOrder.maker, (rightOrder.maker == address(0)) ? _msgSender() : rightOrder.maker, rightOrderData, makeMatch, takeMatch, TO_TAKER ); transferPayouts( takeMatch, fill.takeValue, (rightOrder.maker == address(0)) ? _msgSender() : rightOrder.maker, leftOrderData.payouts, TO_MAKER ); } else if (feeSide == LibFeeSide.FeeSide.TAKE) { totalTakeValue = doTransfersWithFees( fill.takeValue, (rightOrder.maker == address(0)) ? _msgSender() : rightOrder.maker, (leftOrder.maker == address(0)) ? _msgSender() : leftOrder.maker, leftOrderData, takeMatch, makeMatch, TO_MAKER ); transferPayouts( makeMatch, fill.makeValue, (leftOrder.maker == address(0)) ? _msgSender() : leftOrder.maker, rightOrderData.payouts, TO_TAKER ); } else { transferPayouts( makeMatch, fill.makeValue, (leftOrder.maker == address(0)) ? _msgSender() : leftOrder.maker, rightOrderData.payouts, TO_TAKER ); transferPayouts( takeMatch, fill.takeValue, (rightOrder.maker == address(0)) ? _msgSender() : rightOrder.maker, leftOrderData.payouts, TO_MAKER ); } } function doTransfersWithFees( uint256 amount, address from, address to, LibOrderDataV1.DataV1 memory dataNft, LibAsset.AssetType memory matchCalculate, LibAsset.AssetType memory matchNft, bytes4 transferDirection ) internal returns (uint256 totalAmount) { uint256[2] memory specialFee; bool isEspecialFee; (totalAmount, specialFee, isEspecialFee) = calculateTotalAmount( amount, from, to, protocolFee, matchNft, matchCalculate, transferDirection ); uint256 rest = transferProtocolFee( totalAmount, specialFee, isEspecialFee, amount, from, matchCalculate, transferDirection ); rest = transferRoyalties( matchCalculate, matchNft, rest, amount, from, transferDirection ); transferPayouts( matchCalculate, rest, from, dataNft.payouts, transferDirection ); } function transferProtocolFee( uint256 totalAmount, uint256[2] memory specialFee, bool isEspecialFee, uint256 amount, address from, LibAsset.AssetType memory matchCalculate, bytes4 transferDirection ) internal returns (uint256) { uint256 rest; uint256 fee; if (!isEspecialFee) { (rest, fee) = subFeeInBp(totalAmount, amount, protocolFee.mul(2)); } else { (rest, fee) = subFeeInBp( totalAmount, amount, specialFee[0].add(specialFee[1]) ); } if (fee > 0) { address tokenAddress = address(0); if (matchCalculate.assetClass == LibAsset.ERC20_ASSET_CLASS) { tokenAddress = abi.decode(matchCalculate.data, (address)); } else if ( matchCalculate.assetClass == LibAsset.ERC1155_ASSET_CLASS ) { uint256 tokenId; (tokenAddress, tokenId) = abi.decode( matchCalculate.data, (address, uint256) ); } transfer( LibAsset.Asset(matchCalculate, fee), from, getFeeReceiver(tokenAddress), transferDirection, PROTOCOL ); } return rest; } function transferRoyalties( LibAsset.AssetType memory matchCalculate, LibAsset.AssetType memory matchNft, uint256 rest, uint256 amount, address from, bytes4 transferDirection ) internal returns (uint256) { LibPart.Part[] memory fees = getRoyaltiesByAssetType(matchNft); (uint256 result, uint256 totalRoyalties) = transferFees( matchCalculate, rest, amount, fees, from, transferDirection, ROYALTY ); require( totalRoyalties <= maxPercentRoyalties, "Royalties are too high (>98%)" ); return result; } function getRoyaltiesByAssetType(LibAsset.AssetType memory matchNft) internal returns (LibPart.Part[] memory) { if ( matchNft.assetClass == LibAsset.ERC1155_ASSET_CLASS || matchNft.assetClass == LibAsset.ERC721_ASSET_CLASS ) { (address token, uint256 tokenId) = abi.decode( matchNft.data, (address, uint256) ); return royaltiesRegistry.getRoyalties(token, tokenId); } LibPart.Part[] memory empty; return empty; } function transferFees( LibAsset.AssetType memory matchCalculate, uint256 rest, uint256 amount, LibPart.Part[] memory fees, address from, bytes4 transferDirection, bytes4 transferType ) internal returns (uint256 restValue, uint256 totalFees) { totalFees = 0; restValue = rest; for (uint256 i = 0; i < fees.length; i++) { totalFees = totalFees.add(fees[i].value); (uint256 newRestValue, uint256 feeValue) = subFeeInBp( restValue, amount, fees[i].value ); restValue = newRestValue; if (feeValue > 0) { transfer( LibAsset.Asset(matchCalculate, feeValue), from, fees[i].account, transferDirection, transferType ); } } } function transferPayouts( LibAsset.AssetType memory matchCalculate, uint256 amount, address from, LibPart.Part[] memory payouts, bytes4 transferDirection ) internal { uint256 sumBps = 0; uint256 restValue = amount; for (uint256 i = 0; i < payouts.length - 1; i++) { uint256 currentAmount = amount.bp(payouts[i].value); sumBps = sumBps.add(payouts[i].value); if (currentAmount > 0) { restValue = restValue.sub(currentAmount); transfer( LibAsset.Asset(matchCalculate, currentAmount), from, payouts[i].account, transferDirection, PAYOUT ); } } LibPart.Part memory lastPayout = payouts[payouts.length - 1]; sumBps = sumBps.add(lastPayout.value); require(sumBps == 10000, "Sum payouts Bps not equal 100%"); if (restValue > 0) { transfer( LibAsset.Asset(matchCalculate, restValue), from, lastPayout.account, transferDirection, PAYOUT ); } } function calculateTotalAmount( uint256 amount, address from, address to, uint256 feeOnTopBp, LibAsset.AssetType memory matchNft, LibAsset.AssetType memory matchCalculate, bytes4 transferDirection ) internal view returns ( uint256 total, uint256[2] memory specialFee, bool isSpecialFee ) { Fee memory discountFee; discountFee.maker = getUserTier(from); discountFee.taker = getUserTier(to); if (transferDirection == TO_MAKER) { if (discountFee.maker > getHolderDiscount(from)) { discountFee.maker = getHolderDiscount(from); } if (discountFee.taker > getHolderDiscount(to)) { discountFee.taker = getHolderDiscount(to); } } else { discountFee.maker = getUserTier(to); discountFee.taker = getUserTier(from); if (discountFee.maker > getHolderDiscount(to)) { discountFee.maker = getHolderDiscount(to); } if (discountFee.taker > getHolderDiscount(from)) { discountFee.taker = getHolderDiscount(from); } } discountFee.token2 = address(0); discountFee.token = abi.decode(matchNft.data, (address)); if (LibAsset.ETH_ASSET_CLASS != matchCalculate.assetClass) { (discountFee.token2) = abi.decode(matchCalculate.data, (address)); } if ( protocolFeeSet[discountFee.token] && protocolFeeSet[discountFee.token2] ) { uint256 totalFeeToken = protocolFeeMake[discountFee.token].add( protocolFeeTake[discountFee.token] ); uint256 totalFeeToken2 = protocolFeeMake[discountFee.token2].add( protocolFeeTake[discountFee.token2] ); if (totalFeeToken > totalFeeToken2) { specialFee[0] = (protocolFeeMake[discountFee.token2]); specialFee[1] = (protocolFeeTake[discountFee.token2]); isSpecialFee = true; } else { specialFee[0] = (protocolFeeMake[discountFee.token]); specialFee[1] = (protocolFeeTake[discountFee.token]); isSpecialFee = true; } } else if (protocolFeeSet[discountFee.token]) { specialFee[0] = (protocolFeeMake[discountFee.token]); specialFee[1] = (protocolFeeTake[discountFee.token]); isSpecialFee = true; } else if (protocolFeeSet[discountFee.token2]) { specialFee[0] = (protocolFeeMake[discountFee.token2]); specialFee[1] = (protocolFeeTake[discountFee.token2]); isSpecialFee = true; } if (!isSpecialFee) { if ( discountFee.maker < feeOnTopBp || discountFee.taker < feeOnTopBp ) { isSpecialFee = true; specialFee[0] = (discountFee.maker); specialFee[1] = (discountFee.taker); total = amount.add( amount.bp( transferDirection == TO_MAKER ? specialFee[0] : specialFee[1] ) ); } else { total = amount.add(amount.bp(feeOnTopBp)); } } else { if (specialFee[0] > discountFee.maker) { specialFee[0] = discountFee.maker; } if (specialFee[1] > discountFee.taker) { specialFee[1] = discountFee.taker; } total = amount.add( amount.bp( transferDirection == TO_MAKER ? specialFee[0] : specialFee[1] ) ); } } function subFeeInBp( uint256 value, uint256 total, uint256 feeInBp ) internal pure returns (uint256 newValue, uint256 realFee) { return subFee(value, total.bp(feeInBp)); } function subFee(uint256 value, uint256 fee) internal pure returns (uint256 newValue, uint256 realFee) { if (value > fee) { newValue = value.sub(fee); realFee = fee; } else { newValue = 0; realFee = value; } } uint256[50] private __gap; }
contracts/royalties-default/RoyaltiesV1Luxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../LibPart.sol"; import "../tokens/ERC2981-default/IERC2981.sol"; import "../exchange/lib/LibBP.sol"; //InterfaceID = 0x25292224 abstract contract RoyaltiesV1Luxy is IERC2981 { using LibBP for uint256; event RoyaltiesSet(uint256 tokenId, LibPart.Part[] royalties); event RoyaltieAccountUpdate( uint256 tokenId, uint256 index, address previousAccount, address newAccount ); mapping(uint256 => LibPart.Part[]) internal royalties; function getRoyalties(uint256 id) public view virtual returns (LibPart.Part[] memory) { return royalties[id]; } function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view override returns (address receiver, uint256 royaltyAmount) { require(royalties[_tokenId].length != 0, "Royalties not set yet"); require( royalties[_tokenId].length == 1, "Multiples Royalties is not supported by EIP2981, use LuxyRoyaltiesV1" ); require( royalties[_tokenId][0].value <= 9800, "Royalties are too high (>98%)" ); royaltyAmount = _salePrice.bp(royalties[_tokenId][0].value); receiver = royalties[_tokenId][0].account; } //Not deployed yet current InterfaceID is 0x25292224 // function calcRoyaltiesInterfaceId() external pure returns (bytes4) { // return type(RoyaltiesV1Luxy).interfaceId; // } function _setRoyalties(uint256 _id, LibPart.Part[] memory _royalties) internal { require(royalties[_id].length == 0, "Royalties already set"); for (uint256 i = 0; i < _royalties.length; i++) { require( _royalties[i].account != address(0x0), "Recipient should be present" ); require( _royalties[i].value != 0, "Royalty value should be positive" ); royalties[_id].push(_royalties[i]); } emit RoyaltiesSet(_id, _royalties); } function _updateAccount( uint256 _id, address _from, address _to ) internal { uint256 length = royalties[_id].length; address previousAccount = address(0x0); uint256 index = 0; for (uint256 i = 0; i < length; i++) { if (royalties[_id][i].account == _from) { previousAccount = royalties[_id][i].account; index = i; royalties[_id][i].account = payable(address(uint160(_to))); } } require( previousAccount != address(0x0), "Account not found, are you using the correct wallet?" ); emit RoyaltieAccountUpdate( _id, index, previousAccount, royalties[_id][index].account ); } uint256[50] private __gap; }
contracts/exchange/testContracts/LibFeeSideTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../lib/LibFeeSide.sol"; contract LibFeeSideTest { function getFeeSideTest(bytes4 maker, bytes4 taker) external pure returns (LibFeeSide.FeeSide) { return LibFeeSide.getFeeSide(maker, taker); } }
@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol) pragma solidity ^0.8.0; import "./IERC20Upgradeable.sol"; import "./extensions/IERC20MetadataUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC20} interface. * * This implementation is agnostic to the way tokens are created. This means * that a supply mechanism has to be added in a derived contract using {_mint}. * For a generic mechanism see {ERC20PresetMinterPauser}. * * TIP: For a detailed writeup see our guide * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How * to implement supply mechanisms]. * * We have followed general OpenZeppelin Contracts guidelines: functions revert * instead returning `false` on failure. This behavior is nonetheless * conventional and does not conflict with the expectations of ERC20 * applications. * * Additionally, an {Approval} event is emitted on calls to {transferFrom}. * This allows applications to reconstruct the allowance for all accounts just * by listening to said events. Other implementations of the EIP may not emit * these events, as it isn't required by the specification. * * Finally, the non-standard {decreaseAllowance} and {increaseAllowance} * functions have been added to mitigate the well-known issues around setting * allowances. See {IERC20-approve}. */ contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable { mapping(address => uint256) private _balances; mapping(address => mapping(address => uint256)) private _allowances; uint256 private _totalSupply; string private _name; string private _symbol; /** * @dev Sets the values for {name} and {symbol}. * * The default value of {decimals} is 18. To select a different value for * {decimals} you should overload it. * * All two of these values are immutable: they can only be set once during * construction. */ function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing { __ERC20_init_unchained(name_, symbol_); } function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev Returns the name of the token. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev Returns the symbol of the token, usually a shorter version of the * name. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev Returns the number of decimals used to get its user representation. * For example, if `decimals` equals `2`, a balance of `505` tokens should * be displayed to a user as `5.05` (`505 / 10 ** 2`). * * Tokens usually opt for a value of 18, imitating the relationship between * Ether and Wei. This is the value {ERC20} uses, unless this function is * overridden; * * NOTE: This information is only used for _display_ purposes: it in * no way affects any of the arithmetic of the contract, including * {IERC20-balanceOf} and {IERC20-transfer}. */ function decimals() public view virtual override returns (uint8) { return 18; } /** * @dev See {IERC20-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _totalSupply; } /** * @dev See {IERC20-balanceOf}. */ function balanceOf(address account) public view virtual override returns (uint256) { return _balances[account]; } /** * @dev See {IERC20-transfer}. * * Requirements: * * - `to` cannot be the zero address. * - the caller must have a balance of at least `amount`. */ function transfer(address to, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _transfer(owner, to, amount); return true; } /** * @dev See {IERC20-allowance}. */ function allowance(address owner, address spender) public view virtual override returns (uint256) { return _allowances[owner][spender]; } /** * @dev See {IERC20-approve}. * * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on * `transferFrom`. This is semantically equivalent to an infinite approval. * * Requirements: * * - `spender` cannot be the zero address. */ function approve(address spender, uint256 amount) public virtual override returns (bool) { address owner = _msgSender(); _approve(owner, spender, amount); return true; } /** * @dev See {IERC20-transferFrom}. * * Emits an {Approval} event indicating the updated allowance. This is not * required by the EIP. See the note at the beginning of {ERC20}. * * NOTE: Does not update the allowance if the current allowance * is the maximum `uint256`. * * Requirements: * * - `from` and `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. * - the caller must have allowance for ``from``'s tokens of at least * `amount`. */ function transferFrom( address from, address to, uint256 amount ) public virtual override returns (bool) { address spender = _msgSender(); _spendAllowance(from, spender, amount); _transfer(from, to, amount); return true; } /** * @dev Atomically increases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. */ function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) { address owner = _msgSender(); _approve(owner, spender, allowance(owner, spender) + addedValue); return true; } /** * @dev Atomically decreases the allowance granted to `spender` by the caller. * * This is an alternative to {approve} that can be used as a mitigation for * problems described in {IERC20-approve}. * * Emits an {Approval} event indicating the updated allowance. * * Requirements: * * - `spender` cannot be the zero address. * - `spender` must have allowance for the caller of at least * `subtractedValue`. */ function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) { address owner = _msgSender(); uint256 currentAllowance = allowance(owner, spender); require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero"); unchecked { _approve(owner, spender, currentAllowance - subtractedValue); } return true; } /** * @dev Moves `amount` of tokens from `from` to `to`. * * This internal function is equivalent to {transfer}, and can be used to * e.g. implement automatic token fees, slashing mechanisms, etc. * * Emits a {Transfer} event. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `from` must have a balance of at least `amount`. */ function _transfer( address from, address to, uint256 amount ) internal virtual { require(from != address(0), "ERC20: transfer from the zero address"); require(to != address(0), "ERC20: transfer to the zero address"); _beforeTokenTransfer(from, to, amount); uint256 fromBalance = _balances[from]; require(fromBalance >= amount, "ERC20: transfer amount exceeds balance"); unchecked { _balances[from] = fromBalance - amount; // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by // decrementing then incrementing. _balances[to] += amount; } emit Transfer(from, to, amount); _afterTokenTransfer(from, to, amount); } /** @dev Creates `amount` tokens and assigns them to `account`, increasing * the total supply. * * Emits a {Transfer} event with `from` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. */ function _mint(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: mint to the zero address"); _beforeTokenTransfer(address(0), account, amount); _totalSupply += amount; unchecked { // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above. _balances[account] += amount; } emit Transfer(address(0), account, amount); _afterTokenTransfer(address(0), account, amount); } /** * @dev Destroys `amount` tokens from `account`, reducing the * total supply. * * Emits a {Transfer} event with `to` set to the zero address. * * Requirements: * * - `account` cannot be the zero address. * - `account` must have at least `amount` tokens. */ function _burn(address account, uint256 amount) internal virtual { require(account != address(0), "ERC20: burn from the zero address"); _beforeTokenTransfer(account, address(0), amount); uint256 accountBalance = _balances[account]; require(accountBalance >= amount, "ERC20: burn amount exceeds balance"); unchecked { _balances[account] = accountBalance - amount; // Overflow not possible: amount <= accountBalance <= totalSupply. _totalSupply -= amount; } emit Transfer(account, address(0), amount); _afterTokenTransfer(account, address(0), amount); } /** * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens. * * This internal function is equivalent to `approve`, and can be used to * e.g. set automatic allowances for certain subsystems, etc. * * Emits an {Approval} event. * * Requirements: * * - `owner` cannot be the zero address. * - `spender` cannot be the zero address. */ function _approve( address owner, address spender, uint256 amount ) internal virtual { require(owner != address(0), "ERC20: approve from the zero address"); require(spender != address(0), "ERC20: approve to the zero address"); _allowances[owner][spender] = amount; emit Approval(owner, spender, amount); } /** * @dev Updates `owner` s allowance for `spender` based on spent `amount`. * * Does not update the allowance amount in case of infinite allowance. * Revert if not enough allowance is available. * * Might emit an {Approval} event. */ function _spendAllowance( address owner, address spender, uint256 amount ) internal virtual { uint256 currentAllowance = allowance(owner, spender); if (currentAllowance != type(uint256).max) { require(currentAllowance >= amount, "ERC20: insufficient allowance"); unchecked { _approve(owner, spender, currentAllowance - amount); } } } /** * @dev Hook that is called before any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * will be transferred to `to`. * - when `from` is zero, `amount` tokens will be minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens 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 amount ) internal virtual {} /** * @dev Hook that is called after any transfer of tokens. This includes * minting and burning. * * Calling conditions: * * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens * has been transferred to `to`. * - when `from` is zero, `amount` tokens have been minted for `to`. * - when `to` is zero, `amount` of ``from``'s tokens have been 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 _afterTokenTransfer( address from, address to, uint256 amount ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[45] private __gap; }
contracts/tokens/ERC2981-default/IERC2981.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // import "@openzeppelin/contracts-upgradeable/utils/introspection/IERC165Upgradeable.sol"; import "@openzeppelin/contracts/utils/introspection/IERC165.sol"; /// /// @dev Interface for the NFT Royalty Standard /// interface IERC2981 is IERC165 { /// ERC165 bytes to add to interface array - set in parent contract /// implementing this standard /// /// bytes4(keccak256("royaltyInfo(uint256,uint256)")) == 0x2a55205a /// bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; /// _registerInterface(_INTERFACE_ID_ERC2981); /// @notice Called with the sale price to determine how much royalty // is owed and to whom. /// @param _tokenId - the NFT asset queried for royalty information /// @param _salePrice - the sale price of the NFT asset specified by _tokenId /// @return receiver - address of who should be sent the royalty payment /// @return royaltyAmount - the royalty payment amount for _salePrice function royaltyInfo(uint256 _tokenId, uint256 _salePrice) external view returns (address receiver, uint256 royaltyAmount); }
contracts/tokens/ERC1155/ERC1155Private.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol"; import "./ERC1155BaseUri.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "../../RoyaltiesV1Luxy.sol"; import "../ERC1271/ERC1271.sol"; contract ERC1155LuxyPrivate is OwnableUpgradeable, ERC1155BurnableUpgradeable, ERC1155BaseURI, RoyaltiesV1Luxy { string public name; string public symbol; bool public isChangeable; uint256 public maxSupply; mapping(address => bool) private defaultApprovals; event DefaultApproval(address indexed operator, bool hasApproval); using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private _tokenIds; mapping(address => bool) private approvedMinters; function __ERC1155PrivateLuxy_init( string memory _name, string memory _symbol, string memory _baseURI, address[] memory _minters, bool _isChangeable, uint256 _maxSupply ) public initializer { name = _name; symbol = _symbol; __Ownable_init_unchained(); __ERC1155Burnable_init_unchained(); __Context_init_unchained(); __ERC165_init_unchained(); _setBaseURI(_baseURI); _setInitialMinters(_minters); _setChangeable(_isChangeable); _setMaxSupply(_maxSupply); } function __ERC1155PrivateLuxy_init_unchained(string memory _baseURI, address[] memory _minters, bool _isChangeable, uint256 _maxSupply) internal initializer { _setBaseURI(_baseURI); _setInitialMinters(_minters); _setChangeable(_isChangeable); _setMaxSupply(_maxSupply); } function _setDefaultApproval(address operator, bool hasApproval) internal { defaultApprovals[operator] = hasApproval; emit DefaultApproval(operator, hasApproval); } function setApprovedMinter(address _minter, bool _approved) external onlyOwner { approvedMinters[_minter] = _approved; } function _isApprovedMinterorOwner(address minter) internal view virtual returns (bool) { if (minter == owner()) return true; require(minter != address(0)); return approvedMinters[minter]; } function isApprovedForAll(address _owner, address _operator) public view override returns (bool) { return defaultApprovals[_operator] || super.isApprovedForAll(_owner, _operator); } function setDefaultApproval(address operator, bool hasApproval) external onlyOwner { _setDefaultApproval(operator, hasApproval); } function uri(uint256 id) public view virtual override(ERC1155BaseURI, ERC1155Upgradeable) returns (string memory) { return _tokenURI(id); } function mint( address account, uint256 amount, LibPart.Part[] memory royalties, string memory tokenURI ) public { require( _isApprovedMinterorOwner(_msgSender()), "Sender must be an approved minter or owner" ); uint256 id = _tokenIds.current(); if(maxSupply != 0){ require(id < maxSupply, "ERC721: minting above the total supply"); } _mint(account, id, amount, ""); _setRoyalties(id, royalties); _setTokenURI(id, tokenURI); _tokenIds.increment(); } function transferFrom( uint256 id, address from, address to, uint256 amount ) public { uint256 balance = balanceOf(from, id); if (balance != 0) { require(balance >= amount, "Insufficient balance"); super.safeTransferFrom(from, to, id, amount, ""); } } function updateAccount( uint256 _id, address _from, address _to ) external { require(_msgSender() == _from, "not allowed"); super._updateAccount(_id, _from, _to); } function setBaseURI(string memory _baseURI) external onlyOwner { require(isChangeable, "Base URI is not changeable."); _setBaseURI(_baseURI); } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override(ERC1155Upgradeable, ERC1155BaseURI, IERC165Upgradeable) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC1155BaseURI).interfaceId || _interfaceId == type(ERC1155BurnableUpgradeable).interfaceId || _interfaceId == type(OwnableUpgradeable).interfaceId || super.supportsInterface(_interfaceId); } function _setMaxSupply(uint256 maxSupply_) internal virtual { maxSupply = maxSupply_; } function getMaxSupply() public view returns (uint256) { require(maxSupply > 0, "There is no MaxSupply for this collection."); return maxSupply; } /** * @dev Internal function to set changeability of BaseURI for NFT drops. */ function _setInitialMinters(address[] memory minters) internal virtual { //initializing base minters list for (uint256 i = 0; i < minters.length; i++) { approvedMinters[minters[i]] = true; } } /** * @dev Internal function to set changeability of BaseURI for NFT drops. */ function _setChangeable(bool isChangeable_) internal virtual { isChangeable = isChangeable_; } uint256[100] private __gap; }
contracts/exchange/lib/LibSignature.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library LibSignature { /** * @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) { // Check the signature length if (signature.length != 65) { revert("ECDSA: invalid signature length"); } // Divide the signature in r, s and v variables bytes32 r; bytes32 s; uint8 v; // ecrecover takes the signature parameters, and the only way to get them // currently is to use assembly. // solhint-disable-next-line no-inline-assembly assembly { r := mload(add(signature, 0x20)) s := mload(add(signature, 0x40)) v := byte(0, mload(add(signature, 0x60))) } return recover(hash, v, r, s); } /** * @dev Overload of {ECDSA-recover-bytes32-bytes-} that receives the `v`, * `r` and `s` signature fields separately. */ function recover( bytes32 hash, uint8 v, bytes32 r, bytes32 s ) internal pure returns (address) { // 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 (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): 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. require( uint256(s) <= 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0, "ECDSA: invalid signature 's' value" ); // If the signature is valid (and not malleable), return the signer address // v > 30 is a special case, we need to adjust hash with "\x19Ethereum Signed Message:\n32" // and v = v - 4 address signer; if (v > 30) { require( v - 4 == 27 || v - 4 == 28, "ECDSA: invalid signature 'v' value" ); signer = ecrecover(toEthSignedMessageHash(hash), v - 4, r, s); } else { require(v == 27 || v == 28, "ECDSA: invalid signature 'v' value"); signer = ecrecover(hash, v, r, s); } require(signer != address(0), "ECDSA: invalid signature"); return signer; } /** * @dev Returns an Ethereum Signed Message, created from a `hash`. This * replicates the behavior of the * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`] * JSON-RPC method. * * 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) ); } }
contracts/exchange/testContracts/TestAssetMatcher.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../interfaces/IAssetMatcher.sol"; contract TestAssetMatcher is IAssetMatcher { function matchAssets( LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType ) external pure override returns (LibAsset.AssetType memory) { if (leftAssetType.assetClass == bytes4(keccak256("BLA"))) { address leftToken = abi.decode(leftAssetType.data, (address)); address rightToken = abi.decode(rightAssetType.data, (address)); if (leftToken == rightToken) { return LibAsset.AssetType( rightAssetType.assetClass, rightAssetType.data ); } } return LibAsset.AssetType(0, ""); } }
contracts/tokens/factory/ERC1155PrivateFactory.sol
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "../ERC1155/ERC1155Private.sol"; contract ERC1155LuxyPrivateFactory is Ownable { event Create1155LuxyContract(address erc1155); event Create1155LuxyPrivateContract(address erc1155); constructor() {} function createToken( string memory _name, string memory _symbol, string memory _baseURI, address[] memory _minters, bool _isChangeable, uint256 _maxSupply, uint256 _salt ) external { address luxy1155Token = deployProxy( getData(_name, _symbol, _baseURI, _minters, _isChangeable,_maxSupply), _salt ); ERC1155LuxyPrivate token = ERC1155LuxyPrivate(luxy1155Token); token.__ERC1155PrivateLuxy_init( _name, _symbol, _baseURI, _minters, _isChangeable, _maxSupply ); token.transferOwnership(_msgSender()); emit Create1155LuxyContract(luxy1155Token); } //deploying Luxy1155 contract with create2 function deployProxy(bytes memory data, uint256 salt) internal returns (address proxy) { bytes memory bytecode = getCreationBytecode(data); assembly { proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt) if iszero(extcodesize(proxy)) { revert(0, 0) } } } //adding unnecessary constructor arguments to Luxy1155 bytecode, to get less change for collision on contract address function getCreationBytecode(bytes memory _data) internal pure returns (bytes memory) { return abi.encodePacked( type(ERC1155LuxyPrivate).creationCode, abi.encode(_data) ); } //returns address that contract with such arguments will be deployed on function getAddress( string memory _name, string memory _symbol, string memory baseURI, address[] memory _minters, bool isChangeable, uint256 _maxSupply, uint256 _salt ) public view returns (address) { bytes memory bytecode = getCreationBytecode( getData(_name, _symbol, baseURI, _minters, isChangeable,_maxSupply) ); bytes32 hash = keccak256( abi.encodePacked( bytes1(0xff), address(this), _salt, keccak256(bytecode) ) ); return address(uint160(uint256(hash))); } function getData( string memory _name, string memory _symbol, string memory baseURI, address[] memory _minters, bool _isChangeable, uint256 _maxSupply ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ERC1155LuxyPrivate.__ERC1155PrivateLuxy_init.selector, _name, _symbol, baseURI, _minters, _isChangeable, _maxSupply ); } }
contracts/exchange/interfaces/IAssetMatcher.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../assets/LibAsset.sol"; interface IAssetMatcher { function matchAssets( LibAsset.AssetType memory leftAssetType, LibAsset.AssetType memory rightAssetType ) external pure returns (LibAsset.AssetType memory); }
contracts/exchange/interfaces/ITransferManager.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../assets/LibAsset.sol"; import "../LibFill.sol"; import "../TransferExecutor.sol"; abstract contract ITransferManager is ITransferExecutor { bytes4 constant TO_MAKER = bytes4(keccak256("TO_MAKER")); bytes4 constant TO_TAKER = bytes4(keccak256("TO_TAKER")); bytes4 constant PROTOCOL = bytes4(keccak256("PROTOCOL")); bytes4 constant ROYALTY = bytes4(keccak256("ROYALTY")); bytes4 constant ORIGIN = bytes4(keccak256("ORIGIN")); bytes4 constant PAYOUT = bytes4(keccak256("PAYOUT")); function doTransfers( LibAsset.AssetType memory makeMatch, LibAsset.AssetType memory takeMatch, LibFill.FillResult memory fill, LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder ) internal virtual returns (uint256 totalMakeValue, uint256 totalTakeValue); }
contracts/transfer-proxy/proxy/ERC20TransferProxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../exchange/exchangeInterfaces/IERC20TransferProxy.sol"; contract ERC20TransferProxy is IERC20TransferProxy { function erc20safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) external override { require( token.transferFrom(from, to, value), "failure while transferring" ); } }
contracts/exchange/exchangeInterfaces/INftTransferProxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; interface INftTransferProxy { function erc721safeTransferFrom( IERC721Upgradeable token, address from, address to, uint256 tokenId ) external; function erc1155safeTransferFrom( IERC1155Upgradeable token, address from, address to, uint256 id, uint256 value, bytes calldata data ) external; }
@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @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`. * * 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; /** * @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 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: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721 * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must * understand this adds an external call which potentially creates a reentrancy vulnerability. * * 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 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 the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @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); }
@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[49] private __gap; }
@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Enumerable.sol) pragma solidity ^0.8.0; import "../ERC721.sol"; import "./IERC721Enumerable.sol"; /** * @dev This implements an optional extension of {ERC721} defined in the EIP that adds * enumerability of all the token ids in the contract as well as all token ids owned by each * account. */ abstract contract ERC721Enumerable is ERC721, IERC721Enumerable { // Mapping from owner to list of owned token IDs mapping(address => mapping(uint256 => uint256)) private _ownedTokens; // Mapping from token ID to index of the owner tokens list mapping(uint256 => uint256) private _ownedTokensIndex; // Array with all token ids, used for enumeration uint256[] private _allTokens; // Mapping from token id to position in the allTokens array mapping(uint256 => uint256) private _allTokensIndex; /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) { return interfaceId == type(IERC721Enumerable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}. */ function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) { require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds"); return _ownedTokens[owner][index]; } /** * @dev See {IERC721Enumerable-totalSupply}. */ function totalSupply() public view virtual override returns (uint256) { return _allTokens.length; } /** * @dev See {IERC721Enumerable-tokenByIndex}. */ function tokenByIndex(uint256 index) public view virtual override returns (uint256) { require(index < ERC721Enumerable.totalSupply(), "ERC721Enumerable: global index out of bounds"); return _allTokens[index]; } /** * @dev See {ERC721-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual override { super._beforeTokenTransfer(from, to, firstTokenId, batchSize); if (batchSize > 1) { // Will only trigger during construction. Batch transferring (minting) is not available afterwards. revert("ERC721Enumerable: consecutive transfers not supported"); } uint256 tokenId = firstTokenId; if (from == address(0)) { _addTokenToAllTokensEnumeration(tokenId); } else if (from != to) { _removeTokenFromOwnerEnumeration(from, tokenId); } if (to == address(0)) { _removeTokenFromAllTokensEnumeration(tokenId); } else if (to != from) { _addTokenToOwnerEnumeration(to, tokenId); } } /** * @dev Private function to add a token to this extension's ownership-tracking data structures. * @param to address representing the new owner of the given token ID * @param tokenId uint256 ID of the token to be added to the tokens list of the given address */ function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private { uint256 length = ERC721.balanceOf(to); _ownedTokens[to][length] = tokenId; _ownedTokensIndex[tokenId] = length; } /** * @dev Private function to add a token to this extension's token tracking data structures. * @param tokenId uint256 ID of the token to be added to the tokens list */ function _addTokenToAllTokensEnumeration(uint256 tokenId) private { _allTokensIndex[tokenId] = _allTokens.length; _allTokens.push(tokenId); } /** * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for * gas optimizations e.g. when performing a transfer operation (avoiding double writes). * This has O(1) time complexity, but alters the order of the _ownedTokens array. * @param from address representing the previous owner of the given token ID * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address */ function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private { // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = ERC721.balanceOf(from) - 1; uint256 tokenIndex = _ownedTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary if (tokenIndex != lastTokenIndex) { uint256 lastTokenId = _ownedTokens[from][lastTokenIndex]; _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index } // This also deletes the contents at the last position of the array delete _ownedTokensIndex[tokenId]; delete _ownedTokens[from][lastTokenIndex]; } /** * @dev Private function to remove a token from this extension's token tracking data structures. * This has O(1) time complexity, but alters the order of the _allTokens array. * @param tokenId uint256 ID of the token to be removed from the tokens list */ function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private { // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and // then delete the last slot (swap and pop). uint256 lastTokenIndex = _allTokens.length - 1; uint256 tokenIndex = _allTokensIndex[tokenId]; // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding // an 'if' statement (like in _removeTokenFromOwnerEnumeration) uint256 lastTokenId = _allTokens[lastTokenIndex]; _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index // This also deletes the contents at the last position of the array delete _allTokensIndex[tokenId]; _allTokens.pop(); } }
contracts/exchange/exchangeInterfaces/testContracts/TransferProxyTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../INftTransferProxy.sol"; contract TransferProxyTest is INftTransferProxy { function erc721safeTransferFrom( IERC721Upgradeable token, address from, address to, uint256 tokenId ) external override { token.safeTransferFrom(from, to, tokenId); } function erc1155safeTransferFrom( IERC1155Upgradeable token, address from, address to, uint256 id, uint256 value, bytes calldata data ) external override { token.safeTransferFrom(from, to, id, value, data); } }
@openzeppelin/contracts/token/ERC721/ERC721.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721.sol"; import "./IERC721Receiver.sol"; import "./extensions/IERC721Metadata.sol"; import "../../utils/Address.sol"; import "../../utils/Context.sol"; import "../../utils/Strings.sol"; import "../../utils/introspection/ERC165.sol"; /** * @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 ERC721 is Context, ERC165, IERC721, IERC721Metadata { using Address for address; using Strings 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. */ constructor(string memory name_, string memory symbol_) { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) { return interfaceId == type(IERC721).interfaceId || interfaceId == type(IERC721Metadata).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); 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) { _requireMinted(tokenId); 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 overridden 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 = ERC721.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); 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: caller is not token owner or 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: caller is not token owner or 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 the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @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 _ownerOf(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) { address owner = ERC721.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == 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, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits an {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 Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @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 IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) { return retval == IERC721Receiver.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; } if (to != address(0)) { _balances[to] += batchSize; } } } /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} }
@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/draft-EIP712.sol) pragma solidity ^0.8.0; // EIP-712 is Final as of 2022-08-11. This file is deprecated. import "./EIP712Upgradeable.sol";
contracts/tokens/factory/ERC721Factory.sol
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "../ERC721/ERC721Luxy.sol"; contract ERC721LuxyFactory is Ownable { event Create721LuxyContract(address erc721); constructor() {} function createToken( string memory _name, string memory _symbol, string memory _baseURI, bool _isChangeable, uint256 _maxSupply, uint256 _salt ) external { address luxy721Token = deployProxy( getData(_name, _symbol, _baseURI, _isChangeable,_maxSupply), _salt ); ERC721Luxy token = ERC721Luxy(luxy721Token); token.__ERC721Luxy_init(_name, _symbol, _baseURI, _isChangeable,_maxSupply); token.transferOwnership(_msgSender()); emit Create721LuxyContract(luxy721Token); } //deploying Luxy1155 contract with create2 function deployProxy(bytes memory data, uint256 salt) internal returns (address proxy) { bytes memory bytecode = getCreationBytecode(data); assembly { proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt) if iszero(extcodesize(proxy)) { revert(0, 0) } } } //adding unnecessary constructor arguments to Luxy1155 bytecode, to get less change for collision on contract address function getCreationBytecode(bytes memory _data) internal pure returns (bytes memory) { return abi.encodePacked(type(ERC721Luxy).creationCode, abi.encode(_data)); } //returns address that contract with such arguments will be deployed on function getAddress( string memory _name, string memory _symbol, string memory _baseURI, bool _isChangeable, uint256 _maxSupply, uint256 _salt ) public view returns (address) { bytes memory bytecode = getCreationBytecode( getData(_name, _symbol, _baseURI, _isChangeable,_maxSupply) ); bytes32 hash = keccak256( abi.encodePacked( bytes1(0xff), address(this), _salt, keccak256(bytecode) ) ); return address(uint160(uint256(hash))); } function getData( string memory _name, string memory _symbol, string memory _baseURI, bool _isChangeable, uint256 _maxSupply ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ERC721Luxy.__ERC721Luxy_init.selector, _name, _symbol, _baseURI, _isChangeable, _maxSupply ); } }
contracts/transfer-proxy/roles/OperatorRole.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; contract OperatorRole is OwnableUpgradeable { mapping(address => bool) operators; function __OperatorRole_init() external initializer { __Context_init_unchained(); __Ownable_init_unchained(); } function addOperator(address operator) external onlyOwner { operators[operator] = true; } function removeOperator(address operator) external onlyOwner { operators[operator] = false; } modifier onlyOperator() { require( operators[_msgSender()], "OperatorRole: caller is not the operator" ); _; } }
contracts/tokens/factory/ERC1155Factory.sol
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/access/Ownable.sol"; import "../ERC1155/ERC1155Luxy.sol"; contract ERC1155LuxyFactory is Ownable { event Create1155LuxyContract(address erc1155); event Create1155LuxyPrivateContract(address erc1155); constructor() {} function createToken( string memory _name, string memory _symbol, string memory _baseURI, bool _isChangeable, uint256 _maxSupply, uint256 _salt ) external { address luxy1155Token = deployProxy( getData(_name, _symbol, _baseURI, _isChangeable,_maxSupply), _salt ); ERC1155Luxy token = ERC1155Luxy(luxy1155Token); token.__ERC1155Luxy_init(_name, _symbol, _baseURI, _isChangeable,_maxSupply); token.transferOwnership(_msgSender()); emit Create1155LuxyContract(luxy1155Token); } //deploying Luxy1155 contract with create2 function deployProxy(bytes memory data, uint256 salt) internal returns (address proxy) { bytes memory bytecode = getCreationBytecode(data); assembly { proxy := create2(0, add(bytecode, 0x20), mload(bytecode), salt) if iszero(extcodesize(proxy)) { revert(0, 0) } } } //adding unnecessary constructor arguments to Luxy1155 bytecode, to get less change for collision on contract address function getCreationBytecode(bytes memory _data) internal pure returns (bytes memory) { return abi.encodePacked(type(ERC1155Luxy).creationCode, abi.encode(_data)); } //returns address that contract with such arguments will be deployed on function getAddress( string memory _name, string memory _symbol, string memory _baseURI, bool _isChangeable, uint256 _maxSupply, uint256 _salt ) public view returns (address) { bytes memory bytecode = getCreationBytecode( getData(_name, _symbol, _baseURI, _isChangeable,_maxSupply) ); bytes32 hash = keccak256( abi.encodePacked( bytes1(0xff), address(this), _salt, keccak256(bytecode) ) ); return address(uint160(uint256(hash))); } function getData( string memory _name, string memory _symbol, string memory _baseURI, bool _isChangeable, uint256 _maxSupply ) internal pure returns (bytes memory) { return abi.encodeWithSelector( ERC1155Luxy.__ERC1155Luxy_init.selector, _name, _symbol, _baseURI, _isChangeable, _maxSupply ); } }
contracts/transfer-proxy/proxy/TransferProxyOperator.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../roles/OperatorRole.sol"; import "../../exchange/exchangeInterfaces/INftTransferProxy.sol"; contract TransferProxyOperator is INftTransferProxy, Initializable, OperatorRole { function __TransferProxy_init() external initializer { __Ownable_init(); } function erc721safeTransferFrom( IERC721Upgradeable token, address from, address to, uint256 tokenId ) external override onlyOperator { token.safeTransferFrom(from, to, tokenId); } function erc1155safeTransferFrom( IERC1155Upgradeable token, address from, address to, uint256 id, uint256 value, bytes calldata data ) external override onlyOperator { token.safeTransferFrom(from, to, id, value, data); } }
@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.sol"; /** * @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 onlyInitializing { } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/exchange/testContracts/LuxyTransferManagerTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../LuxyTransferManager.sol"; import "../interfaces/ITransferExecutor.sol"; import "../orderControl/OrderValidator.sol"; import "../../Royalties-registry/IRoyaltiesProvider.sol"; contract LuxyTransferManagerTest is LuxyTransferManager, TransferExecutor, OrderValidator { function encode(LibOrderDataV1.DataV1 memory data) external pure returns (bytes memory) { return abi.encode(data); } function checkDoTransfers( LibAsset.AssetType memory makeMatch, LibAsset.AssetType memory takeMatch, LibFill.FillResult memory fill, LibOrder.Order memory leftOrder, LibOrder.Order memory rightOrder ) external payable { doTransfers(makeMatch, takeMatch, fill, leftOrder, rightOrder); } function checkFeeReceiver(address token) external view returns (address) { return getFeeReceiver(token); } function __TransferManager_init( INftTransferProxy _transferProxy, IERC20TransferProxy _erc20TransferProxy, uint256 newProtocolFee, address newCommunityWallet, IRoyaltiesProvider newRoyaltiesProvider, address _feeWallet, address _burningWallet, address _luxyAddress, uint256 _burningPercent ) external initializer { __Context_init_unchained(); __Ownable_init_unchained(); __TransferExecutor_init_unchained( _transferProxy, _erc20TransferProxy, _feeWallet, _burningWallet, _luxyAddress, _burningPercent ); __LuxyTransferManager_init_unchained( newProtocolFee, newCommunityWallet, newRoyaltiesProvider ); __OrderValidator_init_unchained("Exchange", "1"); } }
@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library MathUpgradeable { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/ERC1155BurnableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC1155/extensions/ERC1155Burnable.sol) pragma solidity ^0.8.0; import "../ERC1155Upgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @dev Extension of {ERC1155} that allows token holders to destroy both their * own tokens and those that they have been approved to use. * * _Available since v3.1._ */ abstract contract ERC1155BurnableUpgradeable is Initializable, ERC1155Upgradeable { function __ERC1155Burnable_init() internal onlyInitializing { } function __ERC1155Burnable_init_unchained() internal onlyInitializing { } function burn( address account, uint256 id, uint256 value ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" ); _burn(account, id, value); } function burnBatch( address account, uint256[] memory ids, uint256[] memory values ) public virtual { require( account == _msgSender() || isApprovedForAll(account, _msgSender()), "ERC1155: caller is not token owner or approved" ); _burnBatch(account, ids, values); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/tokens/ERC721/ERC721Luxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721URIStorageUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../../RoyaltiesV1Luxy.sol"; import "../ERC1271/ERC1271.sol"; import "../ERC2981/IERC2981.sol"; contract ERC721Luxy is ERC721URIStorageUpgradeable, ERC721EnumerableUpgradeable, ERC721BurnableUpgradeable, OwnableUpgradeable, RoyaltiesV1Luxy { using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private _tokenIds; // Base URI string public baseURI; bool public isChangeable; uint256 public maxSupply; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721Luxy_init( string memory name_, string memory symbol_, string memory baseURI_, bool isChangeable_, uint256 maxSupply_ ) external initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); __ERC721Enumerable_init_unchained(); __Ownable_init_unchained(); _setBaseURI(baseURI_); _setChangeable(isChangeable_); _setMaxSupply(maxSupply_); } function __ERC721Luxy_init_unchained( string memory baseURI_, bool isChangeable_, uint256 maxSupply_ ) internal initializer { _setBaseURI(baseURI_); _setChangeable(isChangeable_); _setMaxSupply(maxSupply_); } function mint( address payable _recipient, string memory _metadata, LibPart.Part[] memory _royalties ) external returns (uint256) { uint256 itemId = _tokenIds.current(); if(maxSupply != 0){ require(itemId < maxSupply, "ERC721: minting above the total supply"); } _safeMint(_recipient, itemId); _setTokenURI(itemId, _metadata); _setRoyalties(itemId, _royalties); _tokenIds.increment(); return itemId; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override( ERC721Upgradeable, ERC721EnumerableUpgradeable, IERC165Upgradeable ) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC721URIStorageUpgradeable).interfaceId || _interfaceId == type(ERC721EnumerableUpgradeable).interfaceId || _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); } /** * @dev External function to allow base URI changes when necessary. */ function setBaseURI(string memory baseURI_) external onlyOwner { require(isChangeable, "Base URI is not changeable."); _setBaseURI(baseURI_); } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}. */ function _setBaseURI(string memory baseURI_) internal virtual { baseURI = baseURI_; } function _setChangeable(bool isChangeable_) internal virtual { isChangeable = isChangeable_; } function _setMaxSupply(uint256 maxSupply_) internal virtual { maxSupply = maxSupply_; } /** * @dev Base URI for computing {tokenURI}. The resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. * See {ERC721Upgradeable-_baseURI}. */ function _baseURI() internal view override returns (string memory) { return baseURI; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view override(ERC721Upgradeable, ERC721URIStorageUpgradeable) returns (string memory) { return super.tokenURI(tokenId); } function getMaxSupply() public view returns (uint256) { require(maxSupply > 0, "There is no MaxSupply for this collection."); return maxSupply; } /** * @dev See {ERC721EnumerableUpgradeable-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { super._beforeTokenTransfer(from, to, tokenId, batchSize); } /** * @dev See {ERC721URIStorageUpgradeable-_burn}. */ function _burn(uint256 tokenId) internal override(ERC721Upgradeable, ERC721URIStorageUpgradeable) { super._burn(tokenId); } uint256[100] private __gap; }
contracts/exchange/Luxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LuxyCore.sol"; import "./LuxyTransferManager.sol"; import "../Royalties-registry/IRoyaltiesProvider.sol"; contract Luxy is LuxyCore, LuxyTransferManager { function __LuxyCore_init( INftTransferProxy _transferProxy, IERC20TransferProxy _erc20TransferProxy, uint256 newProtocolFee, address newDefaultFeeReceiver, IRoyaltiesProvider newRoyaltiesProvider, address _feeWallet, address _burningWallet, address _luxyAddress, uint256 _burningPercent ) external initializer { __Context_init_unchained(); __Ownable_init_unchained(); __TransferExecutor_init_unchained(_transferProxy, _erc20TransferProxy,_feeWallet, _burningWallet, _luxyAddress, _burningPercent); __LuxyTransferManager_init_unchained( newProtocolFee, newDefaultFeeReceiver, newRoyaltiesProvider ); __OrderValidator_init_unchained("LuxyValidator", "1"); } }
@openzeppelin/contracts/utils/math/Math.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol) pragma solidity ^0.8.0; /** * @dev Standard math utilities missing in the Solidity language. */ library Math { enum Rounding { Down, // Toward negative infinity Up, // Toward infinity Zero // Toward zero } /** * @dev Returns the largest of two numbers. */ function max(uint256 a, uint256 b) internal pure returns (uint256) { return a > b ? a : b; } /** * @dev Returns the smallest of two numbers. */ function min(uint256 a, uint256 b) internal pure returns (uint256) { return a < b ? a : b; } /** * @dev Returns the average of two numbers. The result is rounded towards * zero. */ function average(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b) / 2 can overflow. return (a & b) + (a ^ b) / 2; } /** * @dev Returns the ceiling of the division of two numbers. * * This differs from standard division with `/` in that it rounds up instead * of rounding down. */ function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) { // (a + b - 1) / b can overflow on addition, so we distribute. return a == 0 ? 0 : (a - 1) / b + 1; } /** * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0 * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv) * with further edits by Uniswap Labs also under MIT license. */ function mulDiv( uint256 x, uint256 y, uint256 denominator ) internal pure returns (uint256 result) { unchecked { // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256 // variables such that product = prod1 * 2^256 + prod0. uint256 prod0; // Least significant 256 bits of the product uint256 prod1; // Most significant 256 bits of the product assembly { let mm := mulmod(x, y, not(0)) prod0 := mul(x, y) prod1 := sub(sub(mm, prod0), lt(mm, prod0)) } // Handle non-overflow cases, 256 by 256 division. if (prod1 == 0) { return prod0 / denominator; } // Make sure the result is less than 2^256. Also prevents denominator == 0. require(denominator > prod1); /////////////////////////////////////////////// // 512 by 256 division. /////////////////////////////////////////////// // Make division exact by subtracting the remainder from [prod1 prod0]. uint256 remainder; assembly { // Compute remainder using mulmod. remainder := mulmod(x, y, denominator) // Subtract 256 bit number from 512 bit number. prod1 := sub(prod1, gt(remainder, prod0)) prod0 := sub(prod0, remainder) } // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1. // See https://cs.stackexchange.com/q/138556/92363. // Does not overflow because the denominator cannot be zero at this stage in the function. uint256 twos = denominator & (~denominator + 1); assembly { // Divide denominator by twos. denominator := div(denominator, twos) // Divide [prod1 prod0] by twos. prod0 := div(prod0, twos) // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one. twos := add(div(sub(0, twos), twos), 1) } // Shift in bits from prod1 into prod0. prod0 |= prod1 * twos; // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for // four bits. That is, denominator * inv = 1 mod 2^4. uint256 inverse = (3 * denominator) ^ 2; // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works // in modular arithmetic, doubling the correct bits in each step. inverse *= 2 - denominator * inverse; // inverse mod 2^8 inverse *= 2 - denominator * inverse; // inverse mod 2^16 inverse *= 2 - denominator * inverse; // inverse mod 2^32 inverse *= 2 - denominator * inverse; // inverse mod 2^64 inverse *= 2 - denominator * inverse; // inverse mod 2^128 inverse *= 2 - denominator * inverse; // inverse mod 2^256 // Because the division is now exact we can divide by multiplying with the modular inverse of denominator. // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1 // is no longer required. result = prod0 * inverse; return result; } } /** * @notice Calculates x * y / denominator with full precision, following the selected rounding direction. */ function mulDiv( uint256 x, uint256 y, uint256 denominator, Rounding rounding ) internal pure returns (uint256) { uint256 result = mulDiv(x, y, denominator); if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) { result += 1; } return result; } /** * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down. * * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11). */ function sqrt(uint256 a) internal pure returns (uint256) { if (a == 0) { return 0; } // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target. // // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`. // // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)` // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))` // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)` // // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit. uint256 result = 1 << (log2(a) >> 1); // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128, // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision // into the expected uint128 result. unchecked { result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; result = (result + a / result) >> 1; return min(result, a / result); } } /** * @notice Calculates sqrt(a), following the selected rounding direction. */ function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = sqrt(a); return result + (rounding == Rounding.Up && result * result < a ? 1 : 0); } } /** * @dev Return the log in base 2, rounded down, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 128; } if (value >> 64 > 0) { value >>= 64; result += 64; } if (value >> 32 > 0) { value >>= 32; result += 32; } if (value >> 16 > 0) { value >>= 16; result += 16; } if (value >> 8 > 0) { value >>= 8; result += 8; } if (value >> 4 > 0) { value >>= 4; result += 4; } if (value >> 2 > 0) { value >>= 2; result += 2; } if (value >> 1 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 2, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log2(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log2(value); return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0); } } /** * @dev Return the log in base 10, rounded down, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >= 10**64) { value /= 10**64; result += 64; } if (value >= 10**32) { value /= 10**32; result += 32; } if (value >= 10**16) { value /= 10**16; result += 16; } if (value >= 10**8) { value /= 10**8; result += 8; } if (value >= 10**4) { value /= 10**4; result += 4; } if (value >= 10**2) { value /= 10**2; result += 2; } if (value >= 10**1) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log10(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log10(value); return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0); } } /** * @dev Return the log in base 256, rounded down, of a positive value. * Returns 0 if given 0. * * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string. */ function log256(uint256 value) internal pure returns (uint256) { uint256 result = 0; unchecked { if (value >> 128 > 0) { value >>= 128; result += 16; } if (value >> 64 > 0) { value >>= 64; result += 8; } if (value >> 32 > 0) { value >>= 32; result += 4; } if (value >> 16 > 0) { value >>= 16; result += 2; } if (value >> 8 > 0) { result += 1; } } return result; } /** * @dev Return the log in base 10, following the selected rounding direction, of a positive value. * Returns 0 if given 0. */ function log256(uint256 value, Rounding rounding) internal pure returns (uint256) { unchecked { uint256 result = log256(value); return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0); } } }
@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol) pragma solidity ^0.8.0; import "../StringsUpgradeable.sol"; /** * @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 // Deprecated in v4.8 } 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"); } } /** * @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) { 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. /// @solidity memory-safe-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 { 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 = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff); uint8 v = uint8((uint256(vs) >> 255) + 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 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)); } }
contracts/exchange/testContracts/TrasferExecutorTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../TransferExecutor.sol"; contract TransferExecutorTest is Initializable, OwnableUpgradeable, TransferExecutor { function __TransferExecutorTest_init( INftTransferProxy _transferProxy, IERC20TransferProxy _erc20TransferProxy, address _feeWallet, address _burningWallet, address _luxyAddress, uint256 _burningPercent ) external initializer { __Ownable_init_unchained(); __TransferExecutor_init_unchained( _transferProxy, _erc20TransferProxy, _feeWallet, _burningWallet, _luxyAddress, _burningPercent ); } function transferTest( LibAsset.Asset calldata asset, address from, address to ) external payable { TransferExecutor.transfer(asset, from, to, 0x00000000, 0x00000000); } }
@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC1155/extensions/IERC1155MetadataURI.sol) pragma solidity ^0.8.0; import "../IERC1155Upgradeable.sol"; /** * @dev Interface of the optional ERC1155MetadataExtension interface, as defined * in the https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[EIP]. * * _Available since v3.1._ */ interface IERC1155MetadataURIUpgradeable is IERC1155Upgradeable { /** * @dev Returns the URI for token type `id`. * * If the `\{id\}` substring is present in the URI, it must be replaced by * clients with the actual token type ID. */ function uri(uint256 id) external view returns (string memory); }
@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/extensions/ERC721Burnable.sol) pragma solidity ^0.8.0; import "../ERC721Upgradeable.sol"; import "../../../utils/ContextUpgradeable.sol"; import "../../../proxy/utils/Initializable.sol"; /** * @title ERC721 Burnable Token * @dev ERC721 Token that can be burned (destroyed). */ abstract contract ERC721BurnableUpgradeable is Initializable, ContextUpgradeable, ERC721Upgradeable { function __ERC721Burnable_init() internal onlyInitializing { } function __ERC721Burnable_init_unchained() internal onlyInitializing { } /** * @dev Burns `tokenId`. See {ERC721-_burn}. * * Requirements: * * - The caller must own `tokenId` or be an approved operator. */ function burn(uint256 tokenId) public virtual { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: caller is not token owner or approved"); _burn(tokenId); } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/launchpad/DropWithVoucher/Voucher.sol
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721Enumerable.sol"; contract ERC721Voucher is ERC721Enumerable, Ownable { ERC721 public parentContract; constructor() ERC721("VoucherTest", "VNFT") {} function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override { require( _msgSender() == address(parentContract), "Voucher: You only can transfer the voucher along with the P24 NFT" ); super._beforeTokenTransfer(from, to, tokenId, batchSize); } function mint(uint256 id, address minter) external { require( _msgSender() == address(parentContract), "Voucher: Not allowed " ); // for (uint256 i; i < num; i++) { // uint256 tokenId = _tokenIds.current(); // _safeMint(minter, tokenId); // _tokenIds.increment(); // } _safeMint(minter, id); } function burn(uint256 id) public { require( _msgSender() == address(parentContract), "Voucher: Not allowed" ); super._burn(id); } function setParent(address _parentContract) public onlyOwner { parentContract = ERC721(_parentContract); } function isApprovedForAll(address owner, address operator) public view override returns (bool) { if (_msgSender() == address(parentContract)) { return true; } return false; } }
contracts/tokens/testContracts/TestERC1155Royalties.sol
//SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; import "../../RoyaltiesV1Luxy.sol"; import "@openzeppelin/contracts-upgradeable/utils/introspection/ERC165StorageUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/extensions/IERC1155MetadataURIUpgradeable.sol"; contract TestERC1155Royalties is ERC165StorageUpgradeable, RoyaltiesV1Luxy, ERC1155Upgradeable { function __TestERC1155Royalties_init(string memory uri_) public initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC1155_init_unchained(uri_); } function mint( address to, uint256 tokenId, LibPart.Part[] memory _fees, uint256 amount ) external { _registerInterface(type(RoyaltiesV1Luxy).interfaceId); _mint(to, tokenId, amount, ""); _setRoyalties(tokenId, _fees); } function supportsInterface(bytes4 _interfaceId) public view override( ERC165StorageUpgradeable, ERC1155Upgradeable, IERC165Upgradeable ) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC165StorageUpgradeable).interfaceId || _interfaceId == type(IERC1155Upgradeable).interfaceId || _interfaceId == type(IERC1155MetadataURIUpgradeable).interfaceId || super.supportsInterface(_interfaceId); } function getRoyalties(uint256) public pure override returns (LibPart.Part[] memory) { revert("getRaribleV2Royalties failed"); } }
@openzeppelin/contracts/utils/Address.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol) pragma solidity ^0.8.1; /** * @dev Collection of functions related to the address type */ library Address { /** * @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 * ==== * * [IMPORTANT] * ==== * You shouldn't rely on `isContract` to protect against flash loan attacks! * * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract * constructor. * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize/address.code.length, which returns 0 // for contracts in construction, since the code is only stored at the end // of the constructor execution. return account.code.length > 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 functionCallWithValue(target, data, 0, "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"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResultFromTarget(target, 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) { (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) { return functionDelegateCall(target, data, "Address: low-level delegate call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a delegate call. * * _Available since v3.4._ */ function functionDelegateCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { (bool success, bytes memory returndata) = target.delegatecall(data); return verifyCallResultFromTarget(target, success, returndata, errorMessage); } /** * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract. * * _Available since v4.8._ */ function verifyCallResultFromTarget( address target, bool success, bytes memory returndata, string memory errorMessage ) internal view returns (bytes memory) { if (success) { if (returndata.length == 0) { // only check isContract if the call was successful and the return data is empty // otherwise we already know that it was a contract require(isContract(target), "Address: call to non-contract"); } return returndata; } else { _revert(returndata, errorMessage); } } /** * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason or 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 { _revert(returndata, errorMessage); } } function _revert(bytes memory returndata, string memory errorMessage) private pure { // 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 /// @solidity memory-safe-assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } }
@openzeppelin/contracts/utils/Counters.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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 Counters { 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; } }
@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.6.0) (utils/math/SafeMath.sol) pragma solidity ^0.8.0; // CAUTION // This version of SafeMath should only be used with Solidity 0.8 or later, // because it relies on the compiler's built in overflow checks. /** * @dev Wrappers over Solidity's arithmetic operations. * * NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler * now has built in overflow checking. */ library SafeMathUpgradeable { /** * @dev Returns the addition of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { uint256 c = a + b; if (c < a) return (false, 0); return (true, c); } } /** * @dev Returns the subtraction of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b > a) return (false, 0); return (true, a - b); } } /** * @dev Returns the multiplication of two unsigned integers, with an overflow flag. * * _Available since v3.4._ */ function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { // Gas optimization: this is cheaper than requiring 'a' not being zero, but the // benefit is lost if 'b' is also tested. // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522 if (a == 0) return (true, 0); uint256 c = a * b; if (c / a != b) return (false, 0); return (true, c); } } /** * @dev Returns the division of two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a / b); } } /** * @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag. * * _Available since v3.4._ */ function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) { unchecked { if (b == 0) return (false, 0); return (true, a % b); } } /** * @dev Returns the addition of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `+` operator. * * Requirements: * * - Addition cannot overflow. */ function add(uint256 a, uint256 b) internal pure returns (uint256) { return a + b; } /** * @dev Returns the subtraction of two unsigned integers, reverting on * overflow (when the result is negative). * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub(uint256 a, uint256 b) internal pure returns (uint256) { return a - b; } /** * @dev Returns the multiplication of two unsigned integers, reverting on * overflow. * * Counterpart to Solidity's `*` operator. * * Requirements: * * - Multiplication cannot overflow. */ function mul(uint256 a, uint256 b) internal pure returns (uint256) { return a * b; } /** * @dev Returns the integer division of two unsigned integers, reverting on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. * * Requirements: * * - The divisor cannot be zero. */ function div(uint256 a, uint256 b) internal pure returns (uint256) { return a / b; } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting when dividing by zero. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod(uint256 a, uint256 b) internal pure returns (uint256) { return a % b; } /** * @dev Returns the subtraction of two unsigned integers, reverting with custom message on * overflow (when the result is negative). * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {trySub}. * * Counterpart to Solidity's `-` operator. * * Requirements: * * - Subtraction cannot overflow. */ function sub( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b <= a, errorMessage); return a - b; } } /** * @dev Returns the integer division of two unsigned integers, reverting with custom message on * division by zero. The result is rounded towards zero. * * Counterpart to Solidity's `/` operator. Note: this function uses a * `revert` opcode (which leaves remaining gas untouched) while Solidity * uses an invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function div( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a / b; } } /** * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo), * reverting with custom message when dividing by zero. * * CAUTION: This function is deprecated because it requires allocating memory for the error * message unnecessarily. For custom revert reasons use {tryMod}. * * Counterpart to Solidity's `%` operator. This function uses a `revert` * opcode (which leaves remaining gas untouched) while Solidity uses an * invalid opcode to revert (consuming all remaining gas). * * Requirements: * * - The divisor cannot be zero. */ function mod( uint256 a, uint256 b, string memory errorMessage ) internal pure returns (uint256) { unchecked { require(b > 0, errorMessage); return a % b; } } }
contracts/exchange/exchangeInterfaces/IERC20TransferProxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; interface IERC20TransferProxy { function erc20safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) external; }
contracts/exchange/orderControl/LibOrder.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../lib/LibMath.sol"; import "../assets/LibAsset.sol"; library LibOrder { using SafeMathUpgradeable for uint256; bytes32 constant ORDER_TYPEHASH = keccak256( "Order(address maker,Asset makeAsset,address taker,Asset takeAsset,uint256 salt,uint256 start,uint256 end,bytes4 dataType,bytes data)Asset(AssetType assetType,uint256 value)AssetType(bytes4 assetClass,bytes data)" ); struct Order { address maker; LibAsset.Asset makeAsset; address taker; LibAsset.Asset takeAsset; uint256 salt; uint256 start; uint256 end; bytes4 dataType; bytes data; } function calculateRemaining(Order memory order, uint256 fill) internal pure returns (uint256 makeValue, uint256 takeValue) { takeValue = order.takeAsset.value.sub(fill); makeValue = LibMath.safeGetPartialAmountFloor( order.makeAsset.value, order.takeAsset.value, takeValue ); } function hashKey(Order memory order) internal pure returns (bytes32) { return keccak256( abi.encode( order.maker, LibAsset.hash(order.makeAsset.assetType), LibAsset.hash(order.takeAsset.assetType), order.salt ) ); } function hash(Order memory order) internal pure returns (bytes32) { return keccak256( abi.encode( ORDER_TYPEHASH, order.maker, LibAsset.hash(order.makeAsset), order.taker, LibAsset.hash(order.takeAsset), order.salt, order.start, order.end, order.dataType, keccak256(order.data) ) ); } function validate(LibOrder.Order memory order) internal view { require( order.start == 0 || order.start < block.timestamp, "Order start validation failed" ); require( order.end == 0 || order.end > block.timestamp, "Order end validation failed" ); } }
@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @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 onlyInitializing { __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _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: address zero is not a valid owner"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _ownerOf(tokenId); require(owner != address(0), "ERC721: invalid token ID"); 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) { _requireMinted(tokenId); 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 overridden 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 token owner or approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { _requireMinted(tokenId); 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: caller is not token owner or 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: caller is not token owner or 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 the owner of the `tokenId`. Does NOT revert if token doesn't exist */ function _ownerOf(uint256 tokenId) internal view virtual returns (address) { return _owners[tokenId]; } /** * @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 _ownerOf(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) { address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == 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, 1); // Check that tokenId was not minted by `_beforeTokenTransfer` hook require(!_exists(tokenId), "ERC721: token already minted"); unchecked { // Will not overflow unless all 2**256 token ids are minted to the same owner. // Given that tokens are minted one by one, it is impossible in practice that // this ever happens. Might change if we allow batch minting. // The ERC fails to describe this case. _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); _afterTokenTransfer(address(0), to, tokenId, 1); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * This is an internal function that does not check if the sender is authorized to operate on the token. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId, 1); // Update ownership in case tokenId was transferred by `_beforeTokenTransfer` hook owner = ERC721Upgradeable.ownerOf(tokenId); // Clear approvals delete _tokenApprovals[tokenId]; unchecked { // Cannot overflow, as that would require more tokens to be burned/transferred // out than the owner initially received through minting and transferring in. _balances[owner] -= 1; } delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); _afterTokenTransfer(owner, address(0), tokenId, 1); } /** * @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 from incorrect owner"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId, 1); // Check that tokenId was not transferred by `_beforeTokenTransfer` hook require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner"); // Clear approvals from the previous owner delete _tokenApprovals[tokenId]; unchecked { // `_balances[from]` cannot overflow for the same reason as described in `_burn`: // `from`'s balance is the number of token held, which is at least one before the current // transfer. // `_balances[to]` could overflow in the conditions described in `_mint`. That would require // all 2**256 token ids to be minted, which in practice is impossible. _balances[from] -= 1; _balances[to] += 1; } _owners[tokenId] = to; emit Transfer(from, to, tokenId); _afterTokenTransfer(from, to, tokenId, 1); } /** * @dev Approve `to` to operate on `tokenId` * * Emits an {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 an {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 Reverts if the `tokenId` has not been minted yet. */ function _requireMinted(uint256 tokenId) internal view virtual { require(_exists(tokenId), "ERC721: invalid token ID"); } /** * @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 { /// @solidity memory-safe-assembly assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens will be transferred to `to`. * - When `from` is zero, the tokens will be minted for `to`. * - When `to` is zero, ``from``'s tokens will be burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256, /* firstTokenId */ uint256 batchSize ) internal virtual { if (batchSize > 1) { if (from != address(0)) { _balances[from] -= batchSize; } if (to != address(0)) { _balances[to] += batchSize; } } } /** * @dev Hook that is called after any token transfer. This includes minting and burning. If {ERC721Consecutive} is * used, the hook may be called as part of a consecutive (batch) mint, as indicated by `batchSize` greater than 1. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s tokens were transferred to `to`. * - When `from` is zero, the tokens were minted for `to`. * - When `to` is zero, ``from``'s tokens were burned. * - `from` and `to` are never both zero. * - `batchSize` is non-zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _afterTokenTransfer( address from, address to, uint256 firstTokenId, uint256 batchSize ) internal virtual {} /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[44] private __gap; }
contracts/tokens/ERC1155/ERC1155BaseUri.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC1155/ERC1155Upgradeable.sol"; abstract contract ERC1155BaseURI is ERC1155Upgradeable { using StringsUpgradeable for uint256; // Optional mapping for token URIs mapping(uint256 => string) private _tokenURIs; // Base URI string private _baseURI; // event URI(string uri, uint256 id); /** * @dev Returns the base URI set via {_setBaseURI}. This will be * automatically added as a prefix in {tokenURI} to each token's URI, or * to the token ID if no specific URI is set for that token ID. */ function baseURI() public view virtual returns (string memory) { return _baseURI; } function uri(uint256 id) public view virtual override returns (string memory) { return _tokenURI(id); } function _tokenURI(uint256 tokenId) internal view virtual returns (string memory) { string memory tokenURI = _tokenURIs[tokenId]; string memory base = baseURI(); // If there is no base URI, return the token URI. if (bytes(base).length == 0) { return tokenURI; } // If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked). if (bytes(tokenURI).length > 0) { return string(abi.encodePacked(base, tokenURI)); } // If there is a baseURI but no tokenURI, concatenate the tokenID to the baseURI. return string(abi.encodePacked(base, tokenId.toString())); } /** * @dev Sets `_tokenURI` as the tokenURI of `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _setTokenURI(uint256 tokenId, string memory _uri) internal virtual { _tokenURIs[tokenId] = _uri; emit URI(_tokenURI(tokenId), tokenId); } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}, * or to the token ID if {tokenURI} is empty. */ function _setBaseURI(string memory baseURI_) internal virtual { _baseURI = baseURI_; } function supportsInterface(bytes4 interfaceId) public view virtual override(ERC1155Upgradeable) returns (bool) { return super.supportsInterface(interfaceId); } uint256[50] private __gap; }
contracts/exchange/interfaces/ITransferExecutor.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../assets/LibAsset.sol"; abstract contract ITransferExecutor { //events event Transfer( LibAsset.Asset asset, address from, address to, bytes4 transferDirection, bytes4 transferType ); function transfer( LibAsset.Asset memory asset, address from, address to, bytes4 transferDirection, bytes4 transferType ) internal virtual; }
contracts/Royalties-registry/IRoyaltiesProvider.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../LibPart.sol"; interface IRoyaltiesProvider { function getRoyalties(address token, uint256 tokenId) external returns (LibPart.Part[] memory); }
contracts/launchpad/ERC721LuxyDrop.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,,x _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; //Uncomment this below line to enable whitelist //import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../RoyaltiesV1Luxy.sol"; import "../tokens/ERC2981/IERC2981.sol"; contract ERC721LuxyDrop is ERC721EnumerableUpgradeable, ERC721BurnableUpgradeable, OwnableUpgradeable, RoyaltiesV1Luxy { using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private _tokenIds; //Uncomment this section to enable whitelist // mapping(address => bool) private _whitelist; // uint256 public whitelistSize; string public baseURI; //Uncomment this section to enable whitelist // IERC20Upgradeable luxy; address public artist; address public luxyLaunchpadFeeManagerProxy; uint256 public constant MAX_BATCH_MINT = 1; uint256 public constant MAX_SUPPLY = 1; uint256 public constant DROP_START_TIME = 1; uint256 public constant PRICE_PER_TOKEN = 1 ether; //Uncomment this section to enable LUXY Sale // uint256 public constant MINIMUM_LUXY_AMOUNT = 1000 ether; // uint256 public constant LUXY_SALE_EXPIRE_TIME = 2 days; //Uncomment this section to enable whitelist // uint256 public constant WHITELIST_EXPIRE_TIME = 1 days; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721LuxyDrop_init( string memory baseURI_, // IERC20Upgradeable luxy_, address artist_, address luxyLaunchpadFeeManagerProxy_ ) external initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained("ERC721LuxyDrop", "LuxyDrop"); __ERC721Enumerable_init_unchained(); __Ownable_init_unchained(); __ERC721LuxyDrop_init_unchained( baseURI_, artist_, // luxy_, luxyLaunchpadFeeManagerProxy_ ); } function __ERC721LuxyDrop_init_unchained( string memory baseURI_, address artist_, // IERC20Upgradeable luxy_, address luxyLaunchpadFeeManagerProxy_ ) internal initializer { baseURI = baseURI_; artist = artist_; luxyLaunchpadFeeManagerProxy = luxyLaunchpadFeeManagerProxy_; // luxy = luxy_; } function mint(uint256 num, address minter) external { require(_msgSender() == luxyLaunchpadFeeManagerProxy, "Not allowed"); require(block.timestamp > DROP_START_TIME, "Drop hasnt started yet"); require(num <= MAX_BATCH_MINT, "Exceeds max batch per mint"); require(totalSupply() + num <= MAX_SUPPLY, "Exceeds drop max supply"); //Uncomment this section to enable whitelist // if (block.timestamp < DROP_START_TIME + WHITELIST_EXPIRE_TIME) { // require(isWhitelisted(minter), "Not whitelisted"); // } else if (block.timestamp < DROP_START_TIME + LUXY_SALE_EXPIRE_TIME) { // require( // luxy.balanceOf(minter) > MINIMUM_LUXY_AMOUNT, // "Not elegible to Luxy sale" // ); // } for (uint256 i; i < num; i++) { uint256 tokenId = _tokenIds.current(); _safeMint(minter, tokenId); _tokenIds.increment(); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override( ERC721Upgradeable, ERC721EnumerableUpgradeable, IERC165Upgradeable ) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC721EnumerableUpgradeable).interfaceId || _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}. */ function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } /** * @dev Base URI for computing {tokenURI}. The resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. * See {ERC721Upgradeable-_baseURI}. */ function _baseURI() internal view override returns (string memory) { return baseURI; } /** * @dev See {ERC721EnumerableUpgradeable-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { super._beforeTokenTransfer(from, to, tokenId, batchSize); } //Uncomment this section to enable whitelist // function isWhitelisted(address addr) public view returns (bool) { // return _whitelist[addr]; // } // function addToWhitelist(address[] memory addresses) external onlyOwner { // for (uint256 i = 0; i < addresses.length; i++) { // if (!isWhitelisted(addresses[i])) { // _whitelist[addresses[i]] = true; // whitelistSize++; // } // } // } // function removeFromWhitelist(address[] memory addresses) // external // onlyOwner // { // for (uint256 i = 0; i < addresses.length; i++) { // if (isWhitelisted(addresses[i])) { // _whitelist[addresses[i]] = false; // whitelistSize--; // } // } // } uint256[100] private __gap; }
contracts/LibPart.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; library LibPart { bytes32 public constant TYPE_HASH = keccak256("Part(address account,uint96 value)"); struct Part { address payable account; uint96 value; } }
contracts/exchange/testContracts/AssetMatcherTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../AssetMatcher.sol"; contract AssetMatcherTest is Initializable, OwnableUpgradeable, AssetMatcher { function __AssetMatcherTest_init() external initializer { __Ownable_init_unchained(); } function matchAssetsTest( LibAsset.AssetType calldata leftAssetType, LibAsset.AssetType calldata rightAssetType ) external view returns (LibAsset.AssetType memory) { return matchAssets(leftAssetType, rightAssetType); } }
contracts/launchpad/LuxyLaunchpadFeeManager.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,,x _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "./ERC721LuxyDrop.sol"; contract LuxyLaunchpadFeeManager is OwnableUpgradeable { uint256 public fee; address public team; function __LuxyLaunchpadFeeManager_init(uint256 fee_, address team_) external initializer { __Ownable_init_unchained(); __LuxyLaunchpadFeeManager_init_unchained(fee_, team_); } function __LuxyLaunchpadFeeManager_init_unchained( uint256 fee_, address team_ ) internal initializer { fee = fee_; team = team_; } function mint( ERC721LuxyDrop drop, uint256 amount, address minter ) external payable { require(drop.PRICE_PER_TOKEN() * amount <= msg.value, "Invalid amount"); uint256 feeCalculated = (msg.value * fee) / 100; (bool teamTx, ) = payable(team).call{value: feeCalculated}(""); require(teamTx, "Transfer failed."); (bool artistTx, ) = payable(drop.artist()).call{ value: msg.value - feeCalculated }(""); require(artistTx, "Transfer failed."); drop.mint(amount, minter); } function setFee(uint256 fee_) external onlyOwner { fee = fee_; } function setTeam(address team_) external onlyOwner { team = team_; } }
@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC1155 compliant contract, as defined in the * https://eips.ethereum.org/EIPS/eip-1155[EIP]. * * _Available since v3.1._ */ interface IERC1155Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`. */ event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value); /** * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all * transfers. */ event TransferBatch( address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values ); /** * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to * `approved`. */ event ApprovalForAll(address indexed account, address indexed operator, bool approved); /** * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI. * * If an {URI} event was emitted for `id`, the standard * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value * returned by {IERC1155MetadataURI-uri}. */ event URI(string value, uint256 indexed id); /** * @dev Returns the amount of tokens of token type `id` owned by `account`. * * Requirements: * * - `account` cannot be the zero address. */ function balanceOf(address account, uint256 id) external view returns (uint256); /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}. * * Requirements: * * - `accounts` and `ids` must have the same length. */ function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids) external view returns (uint256[] memory); /** * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`, * * Emits an {ApprovalForAll} event. * * Requirements: * * - `operator` cannot be the caller. */ function setApprovalForAll(address operator, bool approved) external; /** * @dev Returns true if `operator` is approved to transfer ``account``'s tokens. * * See {setApprovalForAll}. */ function isApprovedForAll(address account, address operator) external view returns (bool); /** * @dev Transfers `amount` tokens of token type `id` from `from` to `to`. * * Emits a {TransferSingle} event. * * Requirements: * * - `to` cannot be the zero address. * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}. * - `from` must have a balance of tokens of type `id` of at least `amount`. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the * acceptance magic value. */ function safeTransferFrom( address from, address to, uint256 id, uint256 amount, bytes calldata data ) external; /** * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}. * * Emits a {TransferBatch} event. * * Requirements: * * - `ids` and `amounts` must have the same length. * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the * acceptance magic value. */ function safeBatchTransferFrom( address from, address to, uint256[] calldata ids, uint256[] calldata amounts, bytes calldata data ) external; }
@openzeppelin/contracts/utils/introspection/ERC165.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165.sol"; /** * @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 ERC165 is IERC165 { /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165).interfaceId; } }
@openzeppelin/contracts/access/Ownable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/Context.sol"; /** * @dev Contract module which provides a basic access control mechanism, where * there is an account (an owner) that can be granted exclusive access to * specific functions. * * By default, the owner account will be the one that deploys the contract. This * can later be changed with {transferOwnership}. * * This module is used through inheritance. It will make available the modifier * `onlyOwner`, which can be applied to your functions to restrict their use to * the owner. */ abstract contract Ownable is Context { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ constructor() { _transferOwnership(_msgSender()); } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { _checkOwner(); _; } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if the sender is not the owner. */ function _checkOwner() internal view virtual { require(owner() == _msgSender(), "Ownable: caller is not the owner"); } /** * @dev Leaves the contract without owner. It will not be possible to call * `onlyOwner` functions anymore. Can only be called by the current owner. * * NOTE: Renouncing ownership will leave the contract without an owner, * thereby removing any functionality that is only available to the owner. */ function renounceOwnership() public virtual onlyOwner { _transferOwnership(address(0)); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Can only be called by the current owner. */ function transferOwnership(address newOwner) public virtual onlyOwner { require(newOwner != address(0), "Ownable: new owner is the zero address"); _transferOwnership(newOwner); } /** * @dev Transfers ownership of the contract to a new account (`newOwner`). * Internal function without access restriction. */ function _transferOwnership(address newOwner) internal virtual { address oldOwner = _owner; _owner = newOwner; emit OwnershipTransferred(oldOwner, newOwner); } }
contracts/transfer-proxy/proxy/TransferProxy.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../exchange/exchangeInterfaces/INftTransferProxy.sol"; contract TransferProxy is INftTransferProxy { function erc721safeTransferFrom( IERC721Upgradeable token, address from, address to, uint256 tokenId ) external override { token.safeTransferFrom(from, to, tokenId); } function erc1155safeTransferFrom( IERC1155Upgradeable token, address from, address to, uint256 id, uint256 value, bytes calldata data ) external override { token.safeTransferFrom(from, to, id, value, data); } }
contracts/launchpad/LuxyGenesis.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,,x _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721BurnableUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import "../RoyaltiesV1Luxy.sol"; import "../tokens/ERC2981/IERC2981.sol"; contract LuxyGenesis is ERC721EnumerableUpgradeable, ERC721BurnableUpgradeable, OwnableUpgradeable, RoyaltiesV1Luxy { mapping(address => bool) private _whitelist; mapping(uint256 => uint256) private _assignOrders; uint256 public whitelistSize; string public baseURI; IERC20Upgradeable luxy; address public artist; address public luxyLaunchpadFeeManagerProxy; uint256 public constant MAX_BATCH_MINT = 10; uint256 public constant MAX_SUPPLY = 10000; uint256 public constant DROP_START_TIME = 0; uint256 public constant PRICE_PER_TOKEN = 0.0001 ether; uint256 public constant WHITELIST_EXPIRE_TIME = 1 days; uint256 public constant LUXY_SALE_EXPIRE_TIME = 2 days; uint256 public constant MINIMUM_LUXY_AMOUNT = 1000 ether; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __LuxyGenesis_init( string memory baseURI_, IERC20Upgradeable luxy_, address artist_, address luxyLaunchpadFeeManagerProxy_ ) external initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained("LuxyGenesis", "LuxyGenesis"); __ERC721Enumerable_init_unchained(); __Ownable_init_unchained(); __LuxyGenesis_init_unchained( baseURI_, luxy_, artist_, luxyLaunchpadFeeManagerProxy_ ); } function __LuxyGenesis_init_unchained( string memory baseURI_, IERC20Upgradeable luxy_, address artist_, address luxyLaunchpadFeeManagerProxy_ ) internal initializer { baseURI = baseURI_; luxy = luxy_; artist = artist_; luxyLaunchpadFeeManagerProxy = luxyLaunchpadFeeManagerProxy_; whitelistSize = 0; } function mint(uint256 num) external { require(_msgSender() == luxyLaunchpadFeeManagerProxy, "Not allowed"); require(block.timestamp > DROP_START_TIME, "Drop hasnt started yet"); require(num <= MAX_BATCH_MINT, "Exceeds max batch per mint"); require(totalSupply() + num <= MAX_SUPPLY, "Exceeds drop max supply"); if (block.timestamp < DROP_START_TIME + WHITELIST_EXPIRE_TIME) { require(isWhitelisted(tx.origin), "Not whitelisted"); } else if (block.timestamp < DROP_START_TIME + LUXY_SALE_EXPIRE_TIME) { require( luxy.balanceOf(tx.origin) > MINIMUM_LUXY_AMOUNT, "Not elegible to Luxy sale" ); } for (uint256 i; i < num; i++) { uint256 genesisRemainingToAssign = MAX_SUPPLY - totalSupply(); uint256 randIndex = _random() % genesisRemainingToAssign; uint256 genesisIndex = _fillAssignOrder( genesisRemainingToAssign, randIndex ); _safeMint(tx.origin, genesisIndex); } } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 _interfaceId) public view override( ERC721Upgradeable, ERC721EnumerableUpgradeable, IERC165Upgradeable ) returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == type(ERC721EnumerableUpgradeable).interfaceId || _interfaceId == type(IERC2981).interfaceId || super.supportsInterface(_interfaceId); } /** * @dev Internal function to set the base URI for all token IDs. It is * automatically added as a prefix to the value returned in {tokenURI}. */ function setBaseURI(string memory baseURI_) external onlyOwner { baseURI = baseURI_; } /** * @dev Base URI for computing {tokenURI}. The resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. * See {ERC721Upgradeable-_baseURI}. */ function _baseURI() internal view override returns (string memory) { return baseURI; } /** * @dev See {ERC721EnumerableUpgradeable-_beforeTokenTransfer}. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId, uint256 batchSize ) internal override(ERC721Upgradeable, ERC721EnumerableUpgradeable) { super._beforeTokenTransfer(from, to, tokenId, batchSize); } function isWhitelisted(address addr) public view returns (bool) { return _whitelist[addr]; } function addToWhitelist(address[] memory addresses) external onlyOwner { for (uint i = 0; i < addresses.length; i++) { if (!isWhitelisted(addresses[i])) { _whitelist[addresses[i]] = true; whitelistSize++; } } } function removeFromWhitelist(address[] memory addresses) external onlyOwner { for (uint i = 0; i < addresses.length; i++) { if (isWhitelisted(addresses[i])) { _whitelist[addresses[i]] = false; whitelistSize--; } } } function _fillAssignOrder(uint256 orderA, uint256 orderB) internal returns (uint256) { uint256 temp = orderA; if (_assignOrders[orderA] > 0) temp = _assignOrders[orderA]; _assignOrders[orderA] = orderB; if (_assignOrders[orderB] > 0) _assignOrders[orderA] = _assignOrders[orderB]; _assignOrders[orderB] = temp; return _assignOrders[orderA]; } // pseudo-random function that's pretty robust because of syscoin's pow chainlocks function _random() internal view returns (uint256) { uint256 genesisRemainingToAssign = MAX_SUPPLY - totalSupply(); return uint256( keccak256( abi.encodePacked( block.timestamp + block.difficulty + (( uint256( keccak256(abi.encodePacked(block.coinbase)) ) ) / block.timestamp) + block.gaslimit + (( uint256( keccak256(abi.encodePacked(_msgSender())) ) ) / block.timestamp) + block.number ) ) ) / genesisRemainingToAssign; } uint256[100] private __gap; }
contracts/exchange/lib/LibMath.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/utils/math/SafeMathUpgradeable.sol"; library LibMath { using SafeMathUpgradeable for uint256; /// @dev Calculates partial value given a numerator and denominator rounded down. /// Reverts if rounding error is >= 0.1% /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to calculate partial of. /// @return partialAmount value of target rounded down. function safeGetPartialAmountFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { if (isRoundingErrorFloor(numerator, denominator, target)) { revert("rounding error"); } partialAmount = numerator.mul(target).div(denominator); } /// @dev Checks if rounding error >= 0.1% when rounding down. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to multiply with numerator/denominator. /// @return isError Rounding error is present. function isRoundingErrorFloor( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (bool isError) { if (denominator == 0) { revert("division by zero"); } // The absolute rounding error is the difference between the rounded // value and the ideal value. The relative rounding error is the // absolute rounding error divided by the absolute value of the // ideal value. This is undefined when the ideal value is zero. // // The ideal value is `numerator * target / denominator`. // Let's call `numerator * target % denominator` the remainder. // The absolute error is `remainder / denominator`. // // When the ideal value is zero, we require the absolute error to // be zero. Fortunately, this is always the case. The ideal value is // zero iff `numerator == 0` and/or `target == 0`. In this case the // remainder and absolute error are also zero. if (target == 0 || numerator == 0) { return false; } // Otherwise, we want the relative rounding error to be strictly // less than 0.1%. // The relative error is `remainder / (numerator * target)`. // We want the relative error less than 1 / 1000: // remainder / (numerator * target) < 1 / 1000 // or equivalently: // 1000 * remainder < numerator * target // so we have a rounding error iff: // 1000 * remainder >= numerator * target uint256 remainder = mulmod(target, numerator, denominator); isError = remainder.mul(1000) >= numerator.mul(target); } function safeGetPartialAmountCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (uint256 partialAmount) { if (isRoundingErrorCeil(numerator, denominator, target)) { revert("rounding error"); } partialAmount = numerator.mul(target).add(denominator.sub(1)).div( denominator ); } /// @dev Checks if rounding error >= 0.1% when rounding up. /// @param numerator Numerator. /// @param denominator Denominator. /// @param target Value to multiply with numerator/denominator. /// @return isError Rounding error is present. function isRoundingErrorCeil( uint256 numerator, uint256 denominator, uint256 target ) internal pure returns (bool isError) { if (denominator == 0) { revert("division by zero"); } // See the comments in `isRoundingError`. if (target == 0 || numerator == 0) { // When either is zero, the ideal value and rounded value are zero // and there is no rounding error. (Although the relative error // is undefined.) return false; } // Compute remainder as before uint256 remainder = mulmod(target, numerator, denominator); remainder = denominator.sub(remainder) % denominator; isError = remainder.mul(1000) >= numerator.mul(target); return isError; } }
contracts/transfer-proxy/proxy/ERC20TransferProxyOperator.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../roles/OperatorRole.sol"; import "../../exchange/exchangeInterfaces/IERC20TransferProxy.sol"; contract ERC20TransferProxyOperator is IERC20TransferProxy, Initializable, OperatorRole { function __ERC20TransferProxy_init() external initializer { __Ownable_init(); } function erc20safeTransferFrom( IERC20Upgradeable token, address from, address to, uint256 value ) external override onlyOperator { require( token.transferFrom(from, to, value), "failure while transferring" ); } }
@openzeppelin/contracts-upgradeable/utils/introspection/ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @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 onlyInitializing { } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } /** * @dev This empty reserved space is put in place to allow future versions to add new * variables without shifting down storage in the inheritance chain. * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps */ uint256[50] private __gap; }
contracts/exchange/orderControl/LibOrderDataV1.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../../LibPart.sol"; library LibOrderDataV1 { bytes4 public constant V1 = bytes4(keccak256("V1")); struct DataV1 { LibPart.Part[] payouts; } function decodeOrderDataV1(bytes memory data) internal pure returns (DataV1 memory orderData) { orderData = abi.decode(data, (DataV1)); } }
contracts/tokens/testContracts/TestERC721Dep.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; contract TestERC721Dep is ERC721Upgradeable { function mint(address to, uint256 tokenId) external { _mint(to, tokenId); } function safeTransferFrom( address, address, uint256 ) public virtual override { revert(); } function safeTransferFrom( address, address, uint256, bytes memory ) public virtual override { revert(); } }
contracts/tokens/testContracts/TestERC721.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; contract TestERC721 is ERC721Upgradeable { function __TestERC721_init(string memory name_, string memory symbol_) public initializer { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function mint(address to, uint256 tokenId) external { _mint(to, tokenId); } }
contracts/exchange/orderControl/OrderValidator.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./LibOrder.sol"; import "../lib/LibSignature.sol"; import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/interfaces/IERC1271Upgradeable.sol"; import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol"; abstract contract OrderValidator is Initializable, ContextUpgradeable, EIP712Upgradeable { using LibSignature for bytes32; using AddressUpgradeable for address; bytes4 internal constant MAGICVALUE = 0x1626ba7e; function __OrderValidator_init(string memory name, string memory version) internal initializer { __OrderValidator_init_unchained(name, version); } function __OrderValidator_init_unchained( string memory name, string memory version ) internal initializer { __EIP712_init_unchained(name, version); } function validate(LibOrder.Order memory order, bytes memory signature) internal view { if (order.salt == 0) { if (order.maker != address(0)) { require(_msgSender() == order.maker, "maker is not tx sender"); } } else { if (_msgSender() != order.maker) { bytes32 hash = LibOrder.hash(order); if (_hashTypedDataV4(hash).recover(signature) != order.maker) { if (order.maker.isContract()) { require( IERC1271Upgradeable(order.maker).isValidSignature( _hashTypedDataV4(hash), signature ) == MAGICVALUE, "function selector was not recognized and there's no fallback function" ); } else { revert("order signature verification error"); } } } else { require (order.maker != address(0), "no maker"); } } } uint256[50] private __gap; }
contracts/Royalties-registry/testContracts/RoyaltiesRegistryTest.sol
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "../IRoyaltiesProvider.sol"; import "../../LibPart.sol"; contract RoyaltiesRegistryTest { event getRoyaltiesTest(LibPart.Part[] royalties); function _getRoyalties(address royaltiesTest, address token, uint tokenId) external returns (LibPart.Part[] memory) { IRoyaltiesProvider withRoyalties = IRoyaltiesProvider(royaltiesTest); LibPart.Part[] memory royalties = withRoyalties.getRoyalties(token, tokenId); emit getRoyaltiesTest(royalties); return royalties; } }
contracts/RoyaltiesV1LuxyTest.sol
/* __;φφφ≥,,╓╓,__ _φ░░░░░░░░░░░░░φ,_ φ░░░░░░░░░░░░╚░░░░_ ░░░░░░░░░░░░░░░▒▒░▒_ _░░░░░░░░░░░░░░░░╬▒░░_ _≤, _░░░░░░░░░░░░░░░░╠░░ε _Σ░≥_ `░░░░░░░░░░░░░░░╚░░░_ _φ░░ ░░░░░░░░░░░░░░░▒░░ ░░░, `░░░░░░░░░░░░░╠░░___ _░░░░░≥, _`░░░░░░░░░░░░░░░░░φ≥, _ ▒░░░░░░░░,_ _ ░░░░░░░░░░░░░░░░░░░░░≥,_ ▐░░░░░░░░░░░ φ░░░░░░░░░░░░░░░░░░░░░░░▒, ░░░░░░░░░░░[ _;░░░░░░░░░░░░░░░░░░░░░░░░░░░ \░░░░░░░░░░░»;;--,,. _ ,░░░░░░░░░░░░░░░░░░░░░░░░░░░░░Γ _`░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ,, _"░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░"=░░░░░░░░░░░░░░░░░ Σ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ `╙δ░░░░Γ" ²░Γ_ ,φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░_ _φ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░φ░░≥_ ,▒░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░≥ ,░░░░░░░░░░░░░░░░░╠▒░▐░░░░░░░░░░░░░░░╚░░░░░≥ _░░░░░░░░░░░░░░░░░░▒░░▐░░░░░░░░░░░░░░░░╚▒░░░░░ φ░░░░░░░░░░░░░░░░░φ░░Γ'░░░░░░░░░░░░░░░░░░░░░░░░ ░░░░░░░░░░░░░░░░░░░░░_ ░░░░░░░░░░░░░░░░░░░░░░░░[ ╚░░░░░░░░░░░░░░░░░░░_ └░░░░░░░░░░░░░░░░░░░░░░░░ _╚░░░░░░░░░░░░░▒"^ _7░░░░░░░░░░░░░░░░░░░░░░Γ _`╚░░░░░░░░╚²_ \░░░░░░░░░░░░░░░░░░░░Γ ____ _`░░░░░░░░░░░░░░░Γ╙` _"φ░░░░░░░░░░╚_ _ `""²ⁿ"" ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██╗ ██║ ██║ ██║ ╚██╗██╔╝ ╚██╗ ██╔╝ ██║ ██║ ██║ ╚███╔╝ ╚████╔╝ ██║ ██║ ██║ ██╔██╗ ╚██╔╝ ███████╗ ╚██████╔╝ ██╔╝ ██╗ ██║ ╚══════╝ ╚═════╝ ╚═╝ ╚═╝ ╚═╝ */ //SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./RoyaltiesV1Luxy.sol"; import "./LibPart.sol"; import "./tokens/ERC2981/IERC2981.sol"; contract RoyaltiesV1LuxyTest is RoyaltiesV1Luxy { bytes4 private constant _INTERFACE_ID_ERC2981 = 0x2a55205a; function setRoyalties(uint256 _id, LibPart.Part[] memory _royalties) external { _setRoyalties(_id, _royalties); } function updateAccount( uint256 id, address from, address to ) external { _updateAccount(id, from, to); } function supportsInterface(bytes4 _interfaceId) external pure override returns (bool) { return _interfaceId == type(RoyaltiesV1Luxy).interfaceId || _interfaceId == _INTERFACE_ID_ERC2981; } }
@openzeppelin/contracts-upgradeable/token/ERC721/extensions/IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @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); }
@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (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; } }
Compiler Settings
{"outputSelection":{"*":{"*":["abi","evm.bytecode","evm.deployedBytecode","evm.methodIdentifiers","metadata","storageLayout"],"":["ast"]}},"optimizer":{"runs":200,"enabled":true}}
Contract ABI
[{"type":"event","name":"Initialized","inputs":[{"type":"uint8","name":"version","internalType":"uint8","indexed":false}],"anonymous":false},{"type":"event","name":"OwnershipTransferred","inputs":[{"type":"address","name":"previousOwner","internalType":"address","indexed":true},{"type":"address","name":"newOwner","internalType":"address","indexed":true}],"anonymous":false},{"type":"event","name":"RoyaltiesSetForContract","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"tuple[]","name":"royalties","internalType":"struct LibPart.Part[]","indexed":false,"components":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint96","name":"value","internalType":"uint96"}]}],"anonymous":false},{"type":"event","name":"RoyaltiesSetForToken","inputs":[{"type":"address","name":"token","internalType":"address","indexed":true},{"type":"uint256","name":"tokenId","internalType":"uint256","indexed":true},{"type":"tuple[]","name":"royalties","internalType":"struct LibPart.Part[]","indexed":false,"components":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint96","name":"value","internalType":"uint96"}]}],"anonymous":false},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"__RoyaltiesRegistry_init","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"tuple[]","name":"","internalType":"struct LibPart.Part[]","components":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint96","name":"value","internalType":"uint96"}]}],"name":"getRoyalties","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct LibPart.Part[]","components":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint96","name":"value","internalType":"uint96"}]}],"name":"getRoyaltiesByToken","inputs":[{"type":"address","name":"token","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"tuple[]","name":"","internalType":"struct LibPart.Part[]","components":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint96","name":"value","internalType":"uint96"}]}],"name":"getRoyaltiesByTokenAndTokenId","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"bool","name":"result","internalType":"bool"},{"type":"tuple[]","name":"royalties","internalType":"struct LibPart.Part[]","components":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint96","name":"value","internalType":"uint96"}]}],"name":"providerExtractor","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"uint256","name":"tokenId","internalType":"uint256"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"initialized","internalType":"bool"}],"name":"royaltiesByToken","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"initialized","internalType":"bool"}],"name":"royaltiesByTokenAndTokenId","inputs":[{"type":"bytes32","name":"","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"royaltiesProviders","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setProviderByToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"address","name":"provider","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setRoyaltiesByToken","inputs":[{"type":"address","name":"token","internalType":"address"},{"type":"tuple[]","name":"royalties","internalType":"struct LibPart.Part[]","components":[{"type":"address","name":"account","internalType":"address payable"},{"type":"uint96","name":"value","internalType":"uint96"}]}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]}]
Contract Creation Code
0x608060405234801561001057600080fd5b50611dce806100206000396000f3fe608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063ab1deb921161008c578063d1da3cce11610066578063d1da3cce146101bd578063d836f013146101e0578063f2fde38b146101f3578063f39cc7061461020657600080fd5b8063ab1deb9214610184578063acf14efb14610197578063ad3e8e94146101aa57600080fd5b806305df952f146100d457806327fff8ab1461010c578063715018a6146101165780638da5cb5b1461011e57806390e88be5146101435780639ca7dc7a14610164575b600080fd5b6100f76100e2366004611956565b60666020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61011461022f565b005b610114610345565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610103565b610156610151366004611aae565b610359565b604051610103929190611c6e565b610177610172366004611aae565b61041b565b6040516101039190611c5b565b610177610192366004611956565b61094a565b6101146101a53660046119cd565b6109df565b6101776101b8366004611aae565b610e2a565b6100f76101cb366004611bec565b60656020526000908152604090205460ff1681565b6101146101ee366004611995565b610ef0565b610114610201366004611956565b610f27565b61012b610214366004611956565b6067602052600090815260409020546001600160a01b031681565b600054610100900460ff161580801561024f5750600054600160ff909116105b806102695750303b158015610269575060005460ff166001145b6102d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156102f4576000805461ff0019166101001790555b6102fc610f9d565b8015610342576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b61034d611011565b610357600061106b565b565b6001600160a01b03808316600090815260676020526040812054909160609116801561041357604051634e53ee3d60e11b81526001600160a01b03868116600483015260248201869052829190821690639ca7dc7a90604401600060405180830381600087803b1580156103cc57600080fd5b505af192505050801561040157506040513d6000823e601f3d908101601f191682016040526103fe9190810190611b06565b60015b61040a57610411565b6001945092505b505b509250929050565b604080516001600160a01b038416602080830191909152818301849052825180830384018152606080840180865282519284019290922060009081526065845285812060a086018752805460ff16151584526001810180548851818802810188019099528089529397929694959194608001939091879084015b828210156104e457600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610495565b505050915250506001600160a01b038516600090815260666020908152604080832081518083018352815460ff161515815260018201805484518187028101870190955280855296975094959094919385810193929190879084015b8282101561058f57600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610540565b5050505081525050905060008160200151518360200151516105b19190611d0f565b90506060836000015180156105c4575082515b15610749578167ffffffffffffffff8111156105f057634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561063557816020015b604080518082019091526000808252602082015281526020019060019003908161060e5790505b50905060005b8360200151518110156106b2578360200151818151811061066c57634e487b7160e01b600052603260045260246000fd5b602002602001015182828151811061069457634e487b7160e01b600052603260045260246000fd5b602002602001018190525080806106aa90611d27565b91505061063b565b5060005b84602001515181101561073d57846020015181815181106106e757634e487b7160e01b600052603260045260246000fd5b602002602001015182828660200151516107019190611d0f565b8151811061071f57634e487b7160e01b600052603260045260246000fd5b6020026020010181905250808061073590611d27565b9150506106b6565b50935061094492505050565b83511561075e57505050602001519050610944565b60008061076b8989610359565b9092509050816107825761077f89896110bd565b90505b84602001515181516107949190611d0f565b93506107a189898361149e565b8367ffffffffffffffff8111156107c857634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561080d57816020015b60408051808201909152600080825260208201528152602001906001900390816107e65790505b508151909350156109245760005b856020015151811015610892578560200151818151811061084c57634e487b7160e01b600052603260045260246000fd5b602002602001015184828151811061087457634e487b7160e01b600052603260045260246000fd5b6020026020010181905250808061088a90611d27565b91505061081b565b5060005b8151811015610915578181815181106108bf57634e487b7160e01b600052603260045260246000fd5b602002602001015184828860200151516108d99190611d0f565b815181106108f757634e487b7160e01b600052603260045260246000fd5b6020026020010181905250808061090d90611d27565b915050610896565b50829650505050505050610944565b84511561093d5784602001519650505050505050610944565b5050505050505b92915050565b6001600160a01b0381166000908152606660209081526040808320600101805482518185028101850190935280835260609492939192909184015b828210156109d457600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610985565b505050509050919050565b6109e882611801565b6001600160a01b0382166000908152606660205260408120805460ff1916815581610a166001830182611924565b505060005b8251811015610d665760006001600160a01b0316838281518110610a4f57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b03161415610ac75760405162461bcd60e51b815260206004820152602c60248201527f526f79616c746965734279546f6b656e20726563697069656e742073686f756c60448201526b19081899481c1c995cd95b9d60a21b60648201526084016102c8565b828181518110610ae757634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b031660001415610b655760405162461bcd60e51b815260206004820152603060248201527f526f79616c74792076616c756520666f7220526f79616c746965734279546f6b60448201526f0656e2073686f756c64206265203e20360841b60648201526084016102c8565b60005b6001600160a01b038516600090815260666020526040902060010154811015610c85576001600160a01b0385166000908152606660205260409020600101805482908110610bc657634e487b7160e01b600052603260045260246000fd5b60009182526020909120015484516001600160a01b0390911690859084908110610c0057634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b03161415610c735760405162461bcd60e51b815260206004820152602760248201527f4475706c6963617465206163636f756e7420646574656374656420696e20726f60448201526679616c7469657360c81b60648201526084016102c8565b80610c7d81611d27565b915050610b68565b5060666000856001600160a01b03166001600160a01b03168152602001908152602001600020600101838281518110610cce57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101518254600181018455600093845292829020815191909201516001600160601b0316600160a01b026001600160a01b03909116179101558251839082908110610d3257634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b031682610d529190611d0f565b915080610d5e81611d27565b915050610a1b565b50610bb8811115610dca5760405162461bcd60e51b815260206004820152602860248201527f53657420627920746f6b656e20726f79616c746965732073756d206d6f7265206044820152677468616e2033302560c01b60648201526084016102c8565b6001600160a01b03831660008181526066602052604090819020805460ff19166001179055517fc026171b9a7c9009d6a748a19a0a3cb877978a585e1647a87a786d724bbde12790610e1d908590611c5b565b60405180910390a2505050565b604080516001600160a01b03841660208201529081018290526060906065906000908301604051602081830303815290604052805190602001208152602001908152602001600020600101805480602002602001604051908101604052809291908181526020016000905b82821015610ee457600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610e95565b50505050905092915050565b610ef982611801565b6001600160a01b03918216600090815260676020526040902080546001600160a01b03191691909216179055565b610f2f611011565b6001600160a01b038116610f945760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102c8565b6103428161106b565b600054610100900460ff166110085760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016102c8565b6103573361106b565b6033546001600160a01b031633146103575760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102c8565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516301ffc9a760e01b815263245ba3e360e21b60048201526060906001600160a01b038416906301ffc9a79060240160206040518083038186803b15801561110657600080fd5b505afa15801561111a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113e9190611bcc565b156111d357604051635d9dd7eb60e11b81526004810183905283906001600160a01b0382169063bb3bafd6906024015b60006040518083038186803b15801561118657600080fd5b505afa9250505080156111bb57506040513d6000823e601f3d908101601f191682016040526111b89190810190611b06565b60015b6111c4576111cd565b91506109449050565b50611459565b6040516301ffc9a760e01b815263656cb66560e11b60048201526001600160a01b038416906301ffc9a79060240160206040518083038186803b15801561121957600080fd5b505afa15801561122d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112519190611bcc565b156112855760405163656cb66560e11b81526004810183905283906001600160a01b0382169063cad96cca9060240161116e565b6040516301ffc9a760e01b815263152a902d60e11b60048201526001600160a01b038416906301ffc9a79060240160206040518083038186803b1580156112cb57600080fd5b505afa1580156112df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113039190611bcc565b156114595760405163152a902d60e11b815260048101839052612710602482015283906001600160a01b03821690632a55205a90604401604080518083038186803b15801561135157600080fd5b505afa925050508015611381575060408051601f3d908101601f1916820190925261137e91810190611ad9565b60015b61138a57611457565b604080516001808252818301909252600091816020015b60408051808201909152600080825260208201528152602001906001900390816113a157905050905082816000815181106113ec57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001906001600160a01b031690816001600160a01b031681525050818160008151811061143257634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160601b03909216910152935061094492505050565b505b6040805160008082526020820190925290611496565b604080518082019091526000808252602082015281526020019060019003908161146f5790505b509392505050565b604080516001600160a01b038516602082015290810183905260009081906060016040516020818303038152906040528051906020012090506065600082815260200190815260200160002060010160006114f99190611924565b60005b835181101561172b5760006001600160a01b031684828151811061153057634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b031614156115b25760405162461bcd60e51b815260206004820152603660248201527f526f79616c746965734279546f6b656e416e64546f6b656e49642072656369706044820152751a595b9d081cda1bdd5b19081899481c1c995cd95b9d60521b60648201526084016102c8565b8381815181106115d257634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b03166000141561165d5760405162461bcd60e51b815260206004820152603a60248201527f526f79616c74792076616c756520666f7220526f79616c746965734279546f6b60448201527f656e416e64546f6b656e49642073686f756c64206265203e203000000000000060648201526084016102c8565b6065600083815260200190815260200160002060010184828151811061169357634e487b7160e01b600052603260045260246000fd5b6020908102919091018101518254600181018455600093845292829020815191909201516001600160601b0316600160a01b026001600160a01b039091161791015583518490829081106116f757634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b0316836117179190611d0f565b92508061172381611d27565b9150506114fc565b50611a9082111561179c5760405162461bcd60e51b815260206004820152603560248201527f53657420627920746f6b656e20616e6420746f6b656e496420726f79616c746960448201527465732073756d206d6f72652c207468616e2036382560581b60648201526084016102c8565b60008181526065602052604090819020805460ff191660011790555184906001600160a01b038716907feb39ff9fa01427567623bcdf507c38c3661f0febd78123a35951895dc9ec7315906117f2908790611c5b565b60405180910390a35050505050565b6033546001600160a01b0316331461034257806001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561184c57600080fd5b505afa92505050801561187c575060408051601f3d908101601f1916820190925261187991810190611979565b60015b6118c85760405162461bcd60e51b815260206004820152601860248201527f546f6b656e206f776e6572206e6f74206465746563746564000000000000000060448201526064016102c8565b6001600160a01b03811633146119205760405162461bcd60e51b815260206004820181905260248201527f53656e646572206973206e6f74206f776e6572206f662074686520746f6b656e60448201526064016102c8565b5050565b508054600082559060005260206000209081019061034291905b80821115611952576000815560010161193e565b5090565b600060208284031215611967578081fd5b813561197281611d6e565b9392505050565b60006020828403121561198a578081fd5b815161197281611d6e565b600080604083850312156119a7578081fd5b82356119b281611d6e565b915060208301356119c281611d6e565b809150509250929050565b60008060408084860312156119e0578283fd5b83356119eb81611d6e565b925060208481013567ffffffffffffffff811115611a07578384fd5b8501601f81018713611a17578384fd5b8035611a2a611a2582611ceb565b611cba565b8082825284820191508484018a868560061b8701011115611a49578788fd5b8794505b83851015611a9d5786818c031215611a63578788fd5b611a6b611c91565b8135611a7681611d6e565b815281870135611a8581611d83565b81880152835260019490940193918501918601611a4d565b508096505050505050509250929050565b60008060408385031215611ac0578182fd5b8235611acb81611d6e565b946020939093013593505050565b60008060408385031215611aeb578182fd5b8251611af681611d6e565b6020939093015192949293505050565b60006020808385031215611b18578182fd5b825167ffffffffffffffff811115611b2e578283fd5b8301601f81018513611b3e578283fd5b8051611b4c611a2582611ceb565b80828252848201915084840188868560061b8701011115611b6b578687fd5b8694505b83851015611bc057604080828b031215611b87578788fd5b611b8f611c91565b8251611b9a81611d6e565b815282880151611ba981611d83565b818901528452600195909501949286019201611b6f565b50979650505050505050565b600060208284031215611bdd578081fd5b81518015158114611972578182fd5b600060208284031215611bfd578081fd5b5035919050565b6000815180845260208085019450808401835b83811015611c5057815180516001600160a01b031688528301516001600160601b03168388015260409096019590820190600101611c17565b509495945050505050565b6020815260006119726020830184611c04565b8215158152604060208201526000611c896040830184611c04565b949350505050565b6040805190810167ffffffffffffffff81118282101715611cb457611cb4611d58565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611ce357611ce3611d58565b604052919050565b600067ffffffffffffffff821115611d0557611d05611d58565b5060051b60200190565b60008219821115611d2257611d22611d42565b500190565b6000600019821415611d3b57611d3b611d42565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461034257600080fd5b6001600160601b038116811461034257600080fdfea26469706673582212205d062dbe8c34078a66b06f37517efb5c5c0cab154396e8afde95594a56dde34f64736f6c63430008040033
Deployed ByteCode
0x608060405234801561001057600080fd5b50600436106100cf5760003560e01c8063ab1deb921161008c578063d1da3cce11610066578063d1da3cce146101bd578063d836f013146101e0578063f2fde38b146101f3578063f39cc7061461020657600080fd5b8063ab1deb9214610184578063acf14efb14610197578063ad3e8e94146101aa57600080fd5b806305df952f146100d457806327fff8ab1461010c578063715018a6146101165780638da5cb5b1461011e57806390e88be5146101435780639ca7dc7a14610164575b600080fd5b6100f76100e2366004611956565b60666020526000908152604090205460ff1681565b60405190151581526020015b60405180910390f35b61011461022f565b005b610114610345565b6033546001600160a01b03165b6040516001600160a01b039091168152602001610103565b610156610151366004611aae565b610359565b604051610103929190611c6e565b610177610172366004611aae565b61041b565b6040516101039190611c5b565b610177610192366004611956565b61094a565b6101146101a53660046119cd565b6109df565b6101776101b8366004611aae565b610e2a565b6100f76101cb366004611bec565b60656020526000908152604090205460ff1681565b6101146101ee366004611995565b610ef0565b610114610201366004611956565b610f27565b61012b610214366004611956565b6067602052600090815260409020546001600160a01b031681565b600054610100900460ff161580801561024f5750600054600160ff909116105b806102695750303b158015610269575060005460ff166001145b6102d15760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156102f4576000805461ff0019166101001790555b6102fc610f9d565b8015610342576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b61034d611011565b610357600061106b565b565b6001600160a01b03808316600090815260676020526040812054909160609116801561041357604051634e53ee3d60e11b81526001600160a01b03868116600483015260248201869052829190821690639ca7dc7a90604401600060405180830381600087803b1580156103cc57600080fd5b505af192505050801561040157506040513d6000823e601f3d908101601f191682016040526103fe9190810190611b06565b60015b61040a57610411565b6001945092505b505b509250929050565b604080516001600160a01b038416602080830191909152818301849052825180830384018152606080840180865282519284019290922060009081526065845285812060a086018752805460ff16151584526001810180548851818802810188019099528089529397929694959194608001939091879084015b828210156104e457600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610495565b505050915250506001600160a01b038516600090815260666020908152604080832081518083018352815460ff161515815260018201805484518187028101870190955280855296975094959094919385810193929190879084015b8282101561058f57600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610540565b5050505081525050905060008160200151518360200151516105b19190611d0f565b90506060836000015180156105c4575082515b15610749578167ffffffffffffffff8111156105f057634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561063557816020015b604080518082019091526000808252602082015281526020019060019003908161060e5790505b50905060005b8360200151518110156106b2578360200151818151811061066c57634e487b7160e01b600052603260045260246000fd5b602002602001015182828151811061069457634e487b7160e01b600052603260045260246000fd5b602002602001018190525080806106aa90611d27565b91505061063b565b5060005b84602001515181101561073d57846020015181815181106106e757634e487b7160e01b600052603260045260246000fd5b602002602001015182828660200151516107019190611d0f565b8151811061071f57634e487b7160e01b600052603260045260246000fd5b6020026020010181905250808061073590611d27565b9150506106b6565b50935061094492505050565b83511561075e57505050602001519050610944565b60008061076b8989610359565b9092509050816107825761077f89896110bd565b90505b84602001515181516107949190611d0f565b93506107a189898361149e565b8367ffffffffffffffff8111156107c857634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561080d57816020015b60408051808201909152600080825260208201528152602001906001900390816107e65790505b508151909350156109245760005b856020015151811015610892578560200151818151811061084c57634e487b7160e01b600052603260045260246000fd5b602002602001015184828151811061087457634e487b7160e01b600052603260045260246000fd5b6020026020010181905250808061088a90611d27565b91505061081b565b5060005b8151811015610915578181815181106108bf57634e487b7160e01b600052603260045260246000fd5b602002602001015184828860200151516108d99190611d0f565b815181106108f757634e487b7160e01b600052603260045260246000fd5b6020026020010181905250808061090d90611d27565b915050610896565b50829650505050505050610944565b84511561093d5784602001519650505050505050610944565b5050505050505b92915050565b6001600160a01b0381166000908152606660209081526040808320600101805482518185028101850190935280835260609492939192909184015b828210156109d457600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610985565b505050509050919050565b6109e882611801565b6001600160a01b0382166000908152606660205260408120805460ff1916815581610a166001830182611924565b505060005b8251811015610d665760006001600160a01b0316838281518110610a4f57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b03161415610ac75760405162461bcd60e51b815260206004820152602c60248201527f526f79616c746965734279546f6b656e20726563697069656e742073686f756c60448201526b19081899481c1c995cd95b9d60a21b60648201526084016102c8565b828181518110610ae757634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b031660001415610b655760405162461bcd60e51b815260206004820152603060248201527f526f79616c74792076616c756520666f7220526f79616c746965734279546f6b60448201526f0656e2073686f756c64206265203e20360841b60648201526084016102c8565b60005b6001600160a01b038516600090815260666020526040902060010154811015610c85576001600160a01b0385166000908152606660205260409020600101805482908110610bc657634e487b7160e01b600052603260045260246000fd5b60009182526020909120015484516001600160a01b0390911690859084908110610c0057634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b03161415610c735760405162461bcd60e51b815260206004820152602760248201527f4475706c6963617465206163636f756e7420646574656374656420696e20726f60448201526679616c7469657360c81b60648201526084016102c8565b80610c7d81611d27565b915050610b68565b5060666000856001600160a01b03166001600160a01b03168152602001908152602001600020600101838281518110610cce57634e487b7160e01b600052603260045260246000fd5b6020908102919091018101518254600181018455600093845292829020815191909201516001600160601b0316600160a01b026001600160a01b03909116179101558251839082908110610d3257634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b031682610d529190611d0f565b915080610d5e81611d27565b915050610a1b565b50610bb8811115610dca5760405162461bcd60e51b815260206004820152602860248201527f53657420627920746f6b656e20726f79616c746965732073756d206d6f7265206044820152677468616e2033302560c01b60648201526084016102c8565b6001600160a01b03831660008181526066602052604090819020805460ff19166001179055517fc026171b9a7c9009d6a748a19a0a3cb877978a585e1647a87a786d724bbde12790610e1d908590611c5b565b60405180910390a2505050565b604080516001600160a01b03841660208201529081018290526060906065906000908301604051602081830303815290604052805190602001208152602001908152602001600020600101805480602002602001604051908101604052809291908181526020016000905b82821015610ee457600084815260209081902060408051808201909152908401546001600160a01b0381168252600160a01b90046001600160601b031681830152825260019092019101610e95565b50505050905092915050565b610ef982611801565b6001600160a01b03918216600090815260676020526040902080546001600160a01b03191691909216179055565b610f2f611011565b6001600160a01b038116610f945760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016102c8565b6103428161106b565b600054610100900460ff166110085760405162461bcd60e51b815260206004820152602b60248201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960448201526a6e697469616c697a696e6760a81b60648201526084016102c8565b6103573361106b565b6033546001600160a01b031633146103575760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016102c8565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6040516301ffc9a760e01b815263245ba3e360e21b60048201526060906001600160a01b038416906301ffc9a79060240160206040518083038186803b15801561110657600080fd5b505afa15801561111a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061113e9190611bcc565b156111d357604051635d9dd7eb60e11b81526004810183905283906001600160a01b0382169063bb3bafd6906024015b60006040518083038186803b15801561118657600080fd5b505afa9250505080156111bb57506040513d6000823e601f3d908101601f191682016040526111b89190810190611b06565b60015b6111c4576111cd565b91506109449050565b50611459565b6040516301ffc9a760e01b815263656cb66560e11b60048201526001600160a01b038416906301ffc9a79060240160206040518083038186803b15801561121957600080fd5b505afa15801561122d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906112519190611bcc565b156112855760405163656cb66560e11b81526004810183905283906001600160a01b0382169063cad96cca9060240161116e565b6040516301ffc9a760e01b815263152a902d60e11b60048201526001600160a01b038416906301ffc9a79060240160206040518083038186803b1580156112cb57600080fd5b505afa1580156112df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113039190611bcc565b156114595760405163152a902d60e11b815260048101839052612710602482015283906001600160a01b03821690632a55205a90604401604080518083038186803b15801561135157600080fd5b505afa925050508015611381575060408051601f3d908101601f1916820190925261137e91810190611ad9565b60015b61138a57611457565b604080516001808252818301909252600091816020015b60408051808201909152600080825260208201528152602001906001900390816113a157905050905082816000815181106113ec57634e487b7160e01b600052603260045260246000fd5b6020026020010151600001906001600160a01b031690816001600160a01b031681525050818160008151811061143257634e487b7160e01b600052603260045260246000fd5b6020908102919091018101516001600160601b03909216910152935061094492505050565b505b6040805160008082526020820190925290611496565b604080518082019091526000808252602082015281526020019060019003908161146f5790505b509392505050565b604080516001600160a01b038516602082015290810183905260009081906060016040516020818303038152906040528051906020012090506065600082815260200190815260200160002060010160006114f99190611924565b60005b835181101561172b5760006001600160a01b031684828151811061153057634e487b7160e01b600052603260045260246000fd5b6020026020010151600001516001600160a01b031614156115b25760405162461bcd60e51b815260206004820152603660248201527f526f79616c746965734279546f6b656e416e64546f6b656e49642072656369706044820152751a595b9d081cda1bdd5b19081899481c1c995cd95b9d60521b60648201526084016102c8565b8381815181106115d257634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b03166000141561165d5760405162461bcd60e51b815260206004820152603a60248201527f526f79616c74792076616c756520666f7220526f79616c746965734279546f6b60448201527f656e416e64546f6b656e49642073686f756c64206265203e203000000000000060648201526084016102c8565b6065600083815260200190815260200160002060010184828151811061169357634e487b7160e01b600052603260045260246000fd5b6020908102919091018101518254600181018455600093845292829020815191909201516001600160601b0316600160a01b026001600160a01b039091161791015583518490829081106116f757634e487b7160e01b600052603260045260246000fd5b6020026020010151602001516001600160601b0316836117179190611d0f565b92508061172381611d27565b9150506114fc565b50611a9082111561179c5760405162461bcd60e51b815260206004820152603560248201527f53657420627920746f6b656e20616e6420746f6b656e496420726f79616c746960448201527465732073756d206d6f72652c207468616e2036382560581b60648201526084016102c8565b60008181526065602052604090819020805460ff191660011790555184906001600160a01b038716907feb39ff9fa01427567623bcdf507c38c3661f0febd78123a35951895dc9ec7315906117f2908790611c5b565b60405180910390a35050505050565b6033546001600160a01b0316331461034257806001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b15801561184c57600080fd5b505afa92505050801561187c575060408051601f3d908101601f1916820190925261187991810190611979565b60015b6118c85760405162461bcd60e51b815260206004820152601860248201527f546f6b656e206f776e6572206e6f74206465746563746564000000000000000060448201526064016102c8565b6001600160a01b03811633146119205760405162461bcd60e51b815260206004820181905260248201527f53656e646572206973206e6f74206f776e6572206f662074686520746f6b656e60448201526064016102c8565b5050565b508054600082559060005260206000209081019061034291905b80821115611952576000815560010161193e565b5090565b600060208284031215611967578081fd5b813561197281611d6e565b9392505050565b60006020828403121561198a578081fd5b815161197281611d6e565b600080604083850312156119a7578081fd5b82356119b281611d6e565b915060208301356119c281611d6e565b809150509250929050565b60008060408084860312156119e0578283fd5b83356119eb81611d6e565b925060208481013567ffffffffffffffff811115611a07578384fd5b8501601f81018713611a17578384fd5b8035611a2a611a2582611ceb565b611cba565b8082825284820191508484018a868560061b8701011115611a49578788fd5b8794505b83851015611a9d5786818c031215611a63578788fd5b611a6b611c91565b8135611a7681611d6e565b815281870135611a8581611d83565b81880152835260019490940193918501918601611a4d565b508096505050505050509250929050565b60008060408385031215611ac0578182fd5b8235611acb81611d6e565b946020939093013593505050565b60008060408385031215611aeb578182fd5b8251611af681611d6e565b6020939093015192949293505050565b60006020808385031215611b18578182fd5b825167ffffffffffffffff811115611b2e578283fd5b8301601f81018513611b3e578283fd5b8051611b4c611a2582611ceb565b80828252848201915084840188868560061b8701011115611b6b578687fd5b8694505b83851015611bc057604080828b031215611b87578788fd5b611b8f611c91565b8251611b9a81611d6e565b815282880151611ba981611d83565b818901528452600195909501949286019201611b6f565b50979650505050505050565b600060208284031215611bdd578081fd5b81518015158114611972578182fd5b600060208284031215611bfd578081fd5b5035919050565b6000815180845260208085019450808401835b83811015611c5057815180516001600160a01b031688528301516001600160601b03168388015260409096019590820190600101611c17565b509495945050505050565b6020815260006119726020830184611c04565b8215158152604060208201526000611c896040830184611c04565b949350505050565b6040805190810167ffffffffffffffff81118282101715611cb457611cb4611d58565b60405290565b604051601f8201601f1916810167ffffffffffffffff81118282101715611ce357611ce3611d58565b604052919050565b600067ffffffffffffffff821115611d0557611d05611d58565b5060051b60200190565b60008219821115611d2257611d22611d42565b500190565b6000600019821415611d3b57611d3b611d42565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461034257600080fd5b6001600160601b038116811461034257600080fdfea26469706673582212205d062dbe8c34078a66b06f37517efb5c5c0cab154396e8afde95594a56dde34f64736f6c63430008040033