{"sources":{"GloopMarket.sol":{"content":"// SPDX-License-Identifier: MIT\npragma solidity ^0.8.24;\n\nimport \"@openzeppelin/contracts/token/ERC721/IERC721.sol\";\nimport \"@openzeppelin/contracts/interfaces/IERC2981.sol\";\nimport \"@openzeppelin/contracts/access/Ownable.sol\";\nimport \"@openzeppelin/contracts/utils/ReentrancyGuard.sol\";\n\ninterface IGloop {\n    function totalMinted() external view returns (uint256);\n}\n\n/// @title GLOOP Marketplace — official secondary market for GLOOP NFTs.\n///\n/// Mechanics (owner's final spec, 2026-11-06):\n/// - LISTING FEE: fixed constant 0.0000857 BNB (85700000000000 wei, about\n///   $0.06 at build-time prices), charged EXACTLY on every list() and\n///   forwarded IMMEDIATELY to FEE_RECIPIENT (the market owner, ghoffar26).\n///   The fee is non-refundable: cancel does not return it and re-listing\n///   after a cancel charges it again. setPrice() and cancel() are free.\n///   The fee recipient lists for free.\n/// - MINIMUM PRICE: `minPrice` is a FIXED constant 0.0001 BNB\n///   (100000000000000 wei), enforced in list() AND setPrice() for every\n///   seller INCLUDING the fee recipient / owner. It never changes: there\n///   is no ratchet and no owner override — the floor rule is the same for\n///   everyone, forever, in the code itself.\n/// - BUY GATE: listing is open from launch, but buy() stays LOCKED until\n///   500 Gloops are minted: buy() reverts unless the NFT contract reports\n///   totalMinted >= 500. No manual override, no time fallback — the gate\n///   is the mint count itself. Listings never expire.\n/// - ROYALTY: the collection's EIP-2981 royalty (5%) is paid on every\n///   sale out of the sale price; the listing fee is never deducted from\n///   the sale price.\ncontract GloopMarket is Ownable, ReentrancyGuard {\n    uint256 public constant LISTING_FEE = 85700000000000; // 0.0000857 BNB ~ $0.06\n    uint256 public constant MIN_PRICE = 100000000000000; // 0.0001 BNB, fixed\n    uint256 public constant BUY_UNLOCK_MINTED = 500; // buy opens at 500 minted\n\n    IERC721 public immutable NFT;\n    address public immutable FEE_RECIPIENT;\n\n    struct ListingData {\n        address seller;\n        uint256 price;\n    }\n\n    mapping(uint256 => ListingData) private _listings;\n    uint256[] private _listedIds;\n    mapping(uint256 => uint256) private _listedPos; // tokenId -> index + 1\n\n    event Listing(uint256 indexed tokenId, address indexed seller, uint256 price);\n    event ListingFeePaid(address indexed seller, uint256 fee);\n    event PriceUpdate(uint256 indexed tokenId, uint256 price);\n    event Cancel(uint256 indexed tokenId);\n    event Sale(\n        uint256 indexed tokenId,\n        address indexed buyer,\n        address indexed seller,\n        uint256 price,\n        uint256 royalty\n    );\n\n    constructor(address nft_, address owner_, address feeRecipient_)\n        Ownable(owner_)\n    {\n        NFT = IERC721(nft_);\n        FEE_RECIPIENT = feeRecipient_;\n    }\n\n    /// @notice The fixed minimum listing price (0.0001 BNB). Constant —\n    /// there is deliberately no setter.\n    function minPrice() external pure returns (uint256) {\n        return MIN_PRICE;\n    }\n\n    /// @notice Buying opens once 500 Gloops have been minted.\n    function tradingOpen() public view returns (bool) {\n        return IGloop(address(NFT)).totalMinted() >= BUY_UNLOCK_MINTED;\n    }\n\n    function list(uint256 tokenId, uint256 price) external payable nonReentrant {\n        require(price >= MIN_PRICE, \"price below minimum\");\n        require(_listings[tokenId].seller == address(0), \"already listed\");\n        require(NFT.ownerOf(tokenId) == msg.sender, \"not the owner\");\n        require(\n            NFT.getApproved(tokenId) == address(this) ||\n                NFT.isApprovedForAll(msg.sender, address(this)),\n            \"market not approved\"\n        );\n        if (msg.sender == FEE_RECIPIENT) {\n            require(msg.value == 0, \"fee recipient lists free\");\n        } else {\n            require(msg.value == LISTING_FEE, \"exact listing fee required\");\n            (bool okF, ) = FEE_RECIPIENT.call{value: LISTING_FEE}(\"\");\n            require(okF, \"listing fee forward failed\");\n            emit ListingFeePaid(msg.sender, LISTING_FEE);\n        }\n        _listings[tokenId] = ListingData(msg.sender, price);\n        _listedPos[tokenId] = _listedIds.length + 1;\n        _listedIds.push(tokenId);\n        emit Listing(tokenId, msg.sender, price);\n    }\n\n    function setPrice(uint256 tokenId, uint256 price) external {\n        ListingData storage l = _listings[tokenId];\n        require(l.seller == msg.sender, \"not the seller\");\n        require(price >= MIN_PRICE, \"price below minimum\");\n        l.price = price;\n        emit PriceUpdate(tokenId, price);\n    }\n\n    function cancel(uint256 tokenId) external {\n        require(_listings[tokenId].seller == msg.sender, \"not the seller\");\n        _remove(tokenId);\n        emit Cancel(tokenId);\n    }\n\n    /// @notice Remove a stale listing whose NFT has left the seller.\n    function cleanListing(uint256 tokenId) external {\n        address seller = _listings[tokenId].seller;\n        require(seller != address(0), \"not listed\");\n        require(NFT.ownerOf(tokenId) != seller, \"listing still valid\");\n        _remove(tokenId);\n        emit Cancel(tokenId);\n    }\n\n    function buy(uint256 tokenId) external payable nonReentrant {\n        require(tradingOpen(), \"trading opens at 500 minted\");\n        ListingData memory l = _listings[tokenId];\n        require(l.seller != address(0), \"not listed\");\n        require(msg.value == l.price, \"wrong value\");\n        require(NFT.ownerOf(tokenId) == l.seller, \"stale listing\");\n\n        uint256 royalty = 0;\n        address royaltyReceiver = address(0);\n        try IERC2981(address(NFT)).royaltyInfo(tokenId, l.price) returns (\n            address receiver,\n            uint256 amount\n        ) {\n            if (receiver != address(0) && amount <= l.price) {\n                royaltyReceiver = receiver;\n                royalty = amount;\n            }\n        } catch {}\n\n        _remove(tokenId);\n        NFT.transferFrom(l.seller, msg.sender, tokenId);\n        if (royalty > 0) {\n            (bool okR, ) = royaltyReceiver.call{value: royalty}(\"\");\n            require(okR, \"royalty payment failed\");\n        }\n        (bool okS, ) = l.seller.call{value: l.price - royalty}(\"\");\n        require(okS, \"seller payment failed\");\n        emit Sale(tokenId, msg.sender, l.seller, l.price, royalty);\n    }\n\n    function getListing(uint256 tokenId)\n        external\n        view\n        returns (address seller, uint256 price)\n    {\n        ListingData memory l = _listings[tokenId];\n        return (l.seller, l.price);\n    }\n\n    function listedCount() external view returns (uint256) {\n        return _listedIds.length;\n    }\n\n    function listedIdAt(uint256 index) external view returns (uint256) {\n        return _listedIds[index];\n    }\n\n    function _remove(uint256 tokenId) internal {\n        uint256 pos = _listedPos[tokenId];\n        if (pos == 0) return;\n        uint256 idx = pos - 1;\n        uint256 last = _listedIds[_listedIds.length - 1];\n        _listedIds[idx] = last;\n        _listedPos[last] = pos;\n        _listedIds.pop();\n        delete _listedPos[tokenId];\n        delete _listings[tokenId];\n    }\n}\n"},"@openzeppelin/contracts/utils/ReentrancyGuard.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If EIP-1153 (transient storage) is available on the chain you're deploying at,\n * consider using {ReentrancyGuardTransient} instead.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant NOT_ENTERED = 1;\n    uint256 private constant ENTERED = 2;\n\n    uint256 private _status;\n\n    /**\n     * @dev Unauthorized reentrant call.\n     */\n    error ReentrancyGuardReentrantCall();\n\n    constructor() {\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        _nonReentrantBefore();\n        _;\n        _nonReentrantAfter();\n    }\n\n    function _nonReentrantBefore() private {\n        // On the first call to nonReentrant, _status will be NOT_ENTERED\n        if (_status == ENTERED) {\n            revert ReentrancyGuardReentrantCall();\n        }\n\n        // Any calls to nonReentrant after this point will fail\n        _status = ENTERED;\n    }\n\n    function _nonReentrantAfter() private {\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = NOT_ENTERED;\n    }\n\n    /**\n     * @dev Returns true if the reentrancy guard is currently set to \"entered\", which indicates there is a\n     * `nonReentrant` function in the call stack.\n     */\n    function _reentrancyGuardEntered() internal view returns (bool) {\n        return _status == ENTERED;\n    }\n}\n"},"@openzeppelin/contracts/access/Ownable.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)\n\npragma solidity ^0.8.20;\n\nimport {Context} from \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * The initial owner is set to the address provided by the deployer. This can\n * later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    /**\n     * @dev The caller account is not authorized to perform an operation.\n     */\n    error OwnableUnauthorizedAccount(address account);\n\n    /**\n     * @dev The owner is not a valid owner account. (eg. `address(0)`)\n     */\n    error OwnableInvalidOwner(address owner);\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.\n     */\n    constructor(address initialOwner) {\n        if (initialOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(initialOwner);\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        _checkOwner();\n        _;\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if the sender is not the owner.\n     */\n    function _checkOwner() internal view virtual {\n        if (owner() != _msgSender()) {\n            revert OwnableUnauthorizedAccount(_msgSender());\n        }\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby disabling any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        if (newOwner == address(0)) {\n            revert OwnableInvalidOwner(address(0));\n        }\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"},"@openzeppelin/contracts/utils/Context.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n\n    function _contextSuffixLength() internal view virtual returns (uint256) {\n        return 0;\n    }\n}\n"},"@openzeppelin/contracts/interfaces/IERC2981.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC2981.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Interface for the NFT Royalty Standard.\n *\n * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal\n * support for royalty payments across all NFT marketplaces and ecosystem participants.\n */\ninterface IERC2981 is IERC165 {\n    /**\n     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of\n     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.\n     *\n     * NOTE: ERC-2981 allows setting the royalty to 100% of the price. In that case all the price would be sent to the\n     * royalty receiver and 0 tokens to the seller. Contracts dealing with royalty should consider empty transfers.\n     */\n    function royaltyInfo(\n        uint256 tokenId,\n        uint256 salePrice\n    ) external view returns (address receiver, uint256 royaltyAmount);\n}\n"},"@openzeppelin/contracts/utils/introspection/IERC165.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)\n\npragma solidity ^0.8.20;\n\n/**\n * @dev Interface of the ERC-165 standard, as defined in the\n * https://eips.ethereum.org/EIPS/eip-165[ERC].\n *\n * Implementers can declare support of contract interfaces, which can then be\n * queried by others ({ERC165Checker}).\n *\n * For an implementation, see {ERC165}.\n */\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by\n     * `interfaceId`. See the corresponding\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"},"@openzeppelin/contracts/token/ERC721/IERC721.sol":{"content":"// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC721/IERC721.sol)\n\npragma solidity ^0.8.20;\n\nimport {IERC165} from \"../../utils/introspection/IERC165.sol\";\n\n/**\n * @dev Required interface of an ERC-721 compliant contract.\n */\ninterface IERC721 is IERC165 {\n    /**\n     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.\n     */\n    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);\n\n    /**\n     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.\n     */\n    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);\n\n    /**\n     * @dev Returns the number of tokens in ``owner``'s account.\n     */\n    function balanceOf(address owner) external view returns (uint256 balance);\n\n    /**\n     * @dev Returns the owner of the `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function ownerOf(uint256 tokenId) external view returns (address owner);\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;\n\n    /**\n     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients\n     * are aware of the ERC-721 protocol to prevent tokens from being forever locked.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must exist and be owned by `from`.\n     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or\n     *   {setApprovalForAll}.\n     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon\n     *   a safe transfer.\n     *\n     * Emits a {Transfer} event.\n     */\n    function safeTransferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Transfers `tokenId` token from `from` to `to`.\n     *\n     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721\n     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must\n     * understand this adds an external call which potentially creates a reentrancy vulnerability.\n     *\n     * Requirements:\n     *\n     * - `from` cannot be the zero address.\n     * - `to` cannot be the zero address.\n     * - `tokenId` token must be owned by `from`.\n     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(address from, address to, uint256 tokenId) external;\n\n    /**\n     * @dev Gives permission to `to` to transfer `tokenId` token to another account.\n     * The approval is cleared when the token is transferred.\n     *\n     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.\n     *\n     * Requirements:\n     *\n     * - The caller must own the token or be an approved operator.\n     * - `tokenId` must exist.\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address to, uint256 tokenId) external;\n\n    /**\n     * @dev Approve or remove `operator` as an operator for the caller.\n     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.\n     *\n     * Requirements:\n     *\n     * - The `operator` cannot be the address zero.\n     *\n     * Emits an {ApprovalForAll} event.\n     */\n    function setApprovalForAll(address operator, bool approved) external;\n\n    /**\n     * @dev Returns the account approved for `tokenId` token.\n     *\n     * Requirements:\n     *\n     * - `tokenId` must exist.\n     */\n    function getApproved(uint256 tokenId) external view returns (address operator);\n\n    /**\n     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.\n     *\n     * See {setApprovalForAll}\n     */\n    function isApprovedForAll(address owner, address operator) external view returns (bool);\n}\n"}},"matchId":"58760050","creationMatch":"exact_match","runtimeMatch":"exact_match","verifiedAt":"2026-11-07T15:24:01Z","match":"exact_match","chainId":"56","address":"0x923e0125eBbc846a9EBe50640628664846D67854"}