false
true
0

Contract Address Details

0x56e6d1f8D56C8232dc602E77E927D16136babcfa

Contract Name
CollectionFactory
Creator
0xd5248e–5625b7 at 0x4a6e11–3e2eea
Balance
0 KYMTC
Tokens
Fetching tokens...
Transactions
5 Transactions
Transfers
0 Transfers
Gas Used
827,837
Last Balance Update
2102796
Warning! Contract bytecode has been changed and doesn't match the verified one. Therefore, interaction with this smart contract may be risky.
Contract name:
CollectionFactory




Optimization enabled
true
Compiler version
v0.8.20+commit.a1b79de6




Optimization runs
200
EVM Version
paris




Verified at
2025-05-31T18:28:07.773269Z

Constructor Arguments

0x000000000000000000000000d5248ed905a803c74aa753fc36a5a936945625b7000000000000000000000000c4b5185b3873d16a1c9bd76fd361abf018a0da7c000000000000000000000000550765efdb1ed4fbb23051e084332334d18cbb360000000000000000000000009aff14b01b80d4a88a8754fd065892a7cd25aa67

Arg [0] (address) : 0xd5248ed905a803c74aa753fc36a5a936945625b7
Arg [1] (address) : 0xc4b5185b3873d16a1c9bd76fd361abf018a0da7c
Arg [2] (address) : 0x550765efdb1ed4fbb23051e084332334d18cbb36
Arg [3] (address) : 0x9aff14b01b80d4a88a8754fd065892a7cd25aa67

              

Contract source code

// File: @openzeppelin/contracts/utils/Context.sol


// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;

/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// File: @openzeppelin/contracts/access/Ownable.sol


// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;


/**
 * @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.
 *
 * The initial owner is set to the address provided by the deployer. 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;

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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 {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _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);
    }
}

// File: @openzeppelin/contracts/utils/Errors.sol


// OpenZeppelin Contracts (last updated v5.1.0) (utils/Errors.sol)

pragma solidity ^0.8.20;

/**
 * @dev Collection of common custom errors used in multiple contracts
 *
 * IMPORTANT: Backwards compatibility is not guaranteed in future versions of the library.
 * It is recommended to avoid relying on the error API for critical functionality.
 *
 * _Available since v5.1._
 */
library Errors {
    /**
     * @dev The ETH balance of the account is not enough to perform the operation.
     */
    error InsufficientBalance(uint256 balance, uint256 needed);

    /**
     * @dev A call to an address target failed. The target may have reverted.
     */
    error FailedCall();

    /**
     * @dev The deployment failed.
     */
    error FailedDeployment();

    /**
     * @dev A necessary precompile is missing.
     */
    error MissingPrecompile(address);
}

// File: @openzeppelin/contracts/utils/Create2.sol


// OpenZeppelin Contracts (last updated v5.1.0) (utils/Create2.sol)

pragma solidity ^0.8.20;


/**
 * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
 * `CREATE2` can be used to compute in advance the address where a smart
 * contract will be deployed, which allows for interesting new mechanisms known
 * as 'counterfactual interactions'.
 *
 * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
 * information.
 */
library Create2 {
    /**
     * @dev There's no code to deploy.
     */
    error Create2EmptyBytecode();

    /**
     * @dev Deploys a contract using `CREATE2`. The address where the contract
     * will be deployed can be known in advance via {computeAddress}.
     *
     * The bytecode for a contract can be obtained from Solidity with
     * `type(contractName).creationCode`.
     *
     * Requirements:
     *
     * - `bytecode` must not be empty.
     * - `salt` must have not been used for `bytecode` already.
     * - the factory must have a balance of at least `amount`.
     * - if `amount` is non-zero, `bytecode` must have a `payable` constructor.
     */
    function deploy(uint256 amount, bytes32 salt, bytes memory bytecode) internal returns (address addr) {
        if (address(this).balance < amount) {
            revert Errors.InsufficientBalance(address(this).balance, amount);
        }
        if (bytecode.length == 0) {
            revert Create2EmptyBytecode();
        }
        assembly ("memory-safe") {
            addr := create2(amount, add(bytecode, 0x20), mload(bytecode), salt)
            // if no address was created, and returndata is not empty, bubble revert
            if and(iszero(addr), not(iszero(returndatasize()))) {
                let p := mload(0x40)
                returndatacopy(p, 0, returndatasize())
                revert(p, returndatasize())
            }
        }
        if (addr == address(0)) {
            revert Errors.FailedDeployment();
        }
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the
     * `bytecodeHash` or `salt` will result in a new destination address.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash) internal view returns (address) {
        return computeAddress(salt, bytecodeHash, address(this));
    }

    /**
     * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
     * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
     */
    function computeAddress(bytes32 salt, bytes32 bytecodeHash, address deployer) internal pure returns (address addr) {
        assembly ("memory-safe") {
            let ptr := mload(0x40) // Get free memory pointer

            // |                   | ↓ ptr ...  ↓ ptr + 0x0B (start) ...  ↓ ptr + 0x20 ...  ↓ ptr + 0x40 ...   |
            // |-------------------|---------------------------------------------------------------------------|
            // | bytecodeHash      |                                                        CCCCCCCCCCCCC...CC |
            // | salt              |                                      BBBBBBBBBBBBB...BB                   |
            // | deployer          | 000000...0000AAAAAAAAAAAAAAAAAAA...AA                                     |
            // | 0xFF              |            FF                                                             |
            // |-------------------|---------------------------------------------------------------------------|
            // | memory            | 000000...00FFAAAAAAAAAAAAAAAAAAA...AABBBBBBBBBBBBB...BBCCCCCCCCCCCCC...CC |
            // | keccak(start, 85) |            ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑ |

            mstore(add(ptr, 0x40), bytecodeHash)
            mstore(add(ptr, 0x20), salt)
            mstore(ptr, deployer) // Right-aligned with 12 preceding garbage bytes
            let start := add(ptr, 0x0b) // The hashed data starts at the final garbage byte which we will set to 0xff
            mstore8(start, 0xff)
            addr := and(keccak256(start, 85), 0xffffffffffffffffffffffffffffffffffffffff)
        }
    }
}

// File: @openzeppelin/contracts/proxy/Clones.sol


// OpenZeppelin Contracts (last updated v5.3.0) (proxy/Clones.sol)

pragma solidity ^0.8.20;



/**
 * @dev https://eips.ethereum.org/EIPS/eip-1167[ERC-1167] is a standard for
 * deploying minimal proxy contracts, also known as "clones".
 *
 * > To simply and cheaply clone contract functionality in an immutable way, this standard specifies
 * > a minimal bytecode implementation that delegates all calls to a known, fixed address.
 *
 * The library includes functions to deploy a proxy using either `create` (traditional deployment) or `create2`
 * (salted deterministic deployment). It also includes functions to predict the addresses of clones deployed using the
 * deterministic method.
 */
library Clones {
    error CloneArgumentsTooLong();

    /**
     * @dev Deploys and returns the address of a clone that mimics the behavior of `implementation`.
     *
     * This function uses the create opcode, which should never revert.
     */
    function clone(address implementation) internal returns (address instance) {
        return clone(implementation, 0);
    }

    /**
     * @dev Same as {xref-Clones-clone-address-}[clone], but with a `value` parameter to send native currency
     * to the new contract.
     *
     * NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
     * to always have enough balance for new deployments. Consider exposing this function under a payable method.
     */
    function clone(address implementation, uint256 value) internal returns (address instance) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        assembly ("memory-safe") {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create(value, 0x09, 0x37)
        }
        if (instance == address(0)) {
            revert Errors.FailedDeployment();
        }
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behavior of `implementation`.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy
     * the clone. Using the same `implementation` and `salt` multiple times will revert, since
     * the clones cannot be deployed twice at the same address.
     */
    function cloneDeterministic(address implementation, bytes32 salt) internal returns (address instance) {
        return cloneDeterministic(implementation, salt, 0);
    }

    /**
     * @dev Same as {xref-Clones-cloneDeterministic-address-bytes32-}[cloneDeterministic], but with
     * a `value` parameter to send native currency to the new contract.
     *
     * NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
     * to always have enough balance for new deployments. Consider exposing this function under a payable method.
     */
    function cloneDeterministic(
        address implementation,
        bytes32 salt,
        uint256 value
    ) internal returns (address instance) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        assembly ("memory-safe") {
            // Cleans the upper 96 bits of the `implementation` word, then packs the first 3 bytes
            // of the `implementation` address with the bytecode before the address.
            mstore(0x00, or(shr(0xe8, shl(0x60, implementation)), 0x3d602d80600a3d3981f3363d3d373d3d3d363d73000000))
            // Packs the remaining 17 bytes of `implementation` with the bytecode after the address.
            mstore(0x20, or(shl(0x78, implementation), 0x5af43d82803e903d91602b57fd5bf3))
            instance := create2(value, 0x09, 0x37, salt)
        }
        if (instance == address(0)) {
            revert Errors.FailedDeployment();
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        assembly ("memory-safe") {
            let ptr := mload(0x40)
            mstore(add(ptr, 0x38), deployer)
            mstore(add(ptr, 0x24), 0x5af43d82803e903d91602b57fd5bf3ff)
            mstore(add(ptr, 0x14), implementation)
            mstore(ptr, 0x3d602d80600a3d3981f3363d3d373d3d3d363d73)
            mstore(add(ptr, 0x58), salt)
            mstore(add(ptr, 0x78), keccak256(add(ptr, 0x0c), 0x37))
            predicted := and(keccak256(add(ptr, 0x43), 0x55), 0xffffffffffffffffffffffffffffffffffffffff)
        }
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministic}.
     */
    function predictDeterministicAddress(
        address implementation,
        bytes32 salt
    ) internal view returns (address predicted) {
        return predictDeterministicAddress(implementation, salt, address(this));
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behavior of `implementation` with custom
     * immutable arguments. These are provided through `args` and cannot be changed after deployment. To
     * access the arguments within the implementation, use {fetchCloneArgs}.
     *
     * This function uses the create opcode, which should never revert.
     */
    function cloneWithImmutableArgs(address implementation, bytes memory args) internal returns (address instance) {
        return cloneWithImmutableArgs(implementation, args, 0);
    }

    /**
     * @dev Same as {xref-Clones-cloneWithImmutableArgs-address-bytes-}[cloneWithImmutableArgs], but with a `value`
     * parameter to send native currency to the new contract.
     *
     * NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
     * to always have enough balance for new deployments. Consider exposing this function under a payable method.
     */
    function cloneWithImmutableArgs(
        address implementation,
        bytes memory args,
        uint256 value
    ) internal returns (address instance) {
        if (address(this).balance < value) {
            revert Errors.InsufficientBalance(address(this).balance, value);
        }
        bytes memory bytecode = _cloneCodeWithImmutableArgs(implementation, args);
        assembly ("memory-safe") {
            instance := create(value, add(bytecode, 0x20), mload(bytecode))
        }
        if (instance == address(0)) {
            revert Errors.FailedDeployment();
        }
    }

    /**
     * @dev Deploys and returns the address of a clone that mimics the behavior of `implementation` with custom
     * immutable arguments. These are provided through `args` and cannot be changed after deployment. To
     * access the arguments within the implementation, use {fetchCloneArgs}.
     *
     * This function uses the create2 opcode and a `salt` to deterministically deploy the clone. Using the same
     * `implementation`, `args` and `salt` multiple times will revert, since the clones cannot be deployed twice
     * at the same address.
     */
    function cloneDeterministicWithImmutableArgs(
        address implementation,
        bytes memory args,
        bytes32 salt
    ) internal returns (address instance) {
        return cloneDeterministicWithImmutableArgs(implementation, args, salt, 0);
    }

    /**
     * @dev Same as {xref-Clones-cloneDeterministicWithImmutableArgs-address-bytes-bytes32-}[cloneDeterministicWithImmutableArgs],
     * but with a `value` parameter to send native currency to the new contract.
     *
     * NOTE: Using a non-zero value at creation will require the contract using this function (e.g. a factory)
     * to always have enough balance for new deployments. Consider exposing this function under a payable method.
     */
    function cloneDeterministicWithImmutableArgs(
        address implementation,
        bytes memory args,
        bytes32 salt,
        uint256 value
    ) internal returns (address instance) {
        bytes memory bytecode = _cloneCodeWithImmutableArgs(implementation, args);
        return Create2.deploy(value, salt, bytecode);
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministicWithImmutableArgs}.
     */
    function predictDeterministicAddressWithImmutableArgs(
        address implementation,
        bytes memory args,
        bytes32 salt,
        address deployer
    ) internal pure returns (address predicted) {
        bytes memory bytecode = _cloneCodeWithImmutableArgs(implementation, args);
        return Create2.computeAddress(salt, keccak256(bytecode), deployer);
    }

    /**
     * @dev Computes the address of a clone deployed using {Clones-cloneDeterministicWithImmutableArgs}.
     */
    function predictDeterministicAddressWithImmutableArgs(
        address implementation,
        bytes memory args,
        bytes32 salt
    ) internal view returns (address predicted) {
        return predictDeterministicAddressWithImmutableArgs(implementation, args, salt, address(this));
    }

    /**
     * @dev Get the immutable args attached to a clone.
     *
     * - If `instance` is a clone that was deployed using `clone` or `cloneDeterministic`, this
     *   function will return an empty array.
     * - If `instance` is a clone that was deployed using `cloneWithImmutableArgs` or
     *   `cloneDeterministicWithImmutableArgs`, this function will return the args array used at
     *   creation.
     * - If `instance` is NOT a clone deployed using this library, the behavior is undefined. This
     *   function should only be used to check addresses that are known to be clones.
     */
    function fetchCloneArgs(address instance) internal view returns (bytes memory) {
        bytes memory result = new bytes(instance.code.length - 45); // revert if length is too short
        assembly ("memory-safe") {
            extcodecopy(instance, add(result, 32), 45, mload(result))
        }
        return result;
    }

    /**
     * @dev Helper that prepares the initcode of the proxy with immutable args.
     *
     * An assembly variant of this function requires copying the `args` array, which can be efficiently done using
     * `mcopy`. Unfortunately, that opcode is not available before cancun. A pure solidity implementation using
     * abi.encodePacked is more expensive but also more portable and easier to review.
     *
     * NOTE: https://eips.ethereum.org/EIPS/eip-170[EIP-170] limits the length of the contract code to 24576 bytes.
     * With the proxy code taking 45 bytes, that limits the length of the immutable args to 24531 bytes.
     */
    function _cloneCodeWithImmutableArgs(
        address implementation,
        bytes memory args
    ) private pure returns (bytes memory) {
        if (args.length > 24531) revert CloneArgumentsTooLong();
        return
            abi.encodePacked(
                hex"61",
                uint16(args.length + 45),
                hex"3d81600a3d39f3363d3d373d3d3d363d73",
                implementation,
                hex"5af43d82803e903d91602b57fd5bf3",
                args
            );
    }
}

// File: contracts/interfaces/ICollection.sol


pragma solidity ^0.8.17;

interface ICollection {
    struct NFTDetails {
        string name;
        string description;
        string uri;
        uint256 maxSupply;
        address creator;
    }

    event NFTCreated(string name, string description,uint256 indexed tokenId, address indexed creator, uint256 maxSupply);

    function initialize(
        string memory name,
        string memory symbol,
        address owner,
        address marketplace,
        bool isDrop
    ) external;

    function createNFT(
        string memory name,
        string memory description,
        string memory _tokenURI,
        uint256 maxSupply
    ) external returns (uint256);

    function nftDetails(uint256 tokenId) external view returns (NFTDetails memory);

    function getRoyaltyPercentage() external view returns(uint16);
}
// File: contracts/interfaces/IDrop.sol


pragma solidity ^0.8.17;

interface IDrop {
    function initialize(
        string memory name,
        string memory symbol,
        address owner,
        address marketplace,
        uint256 startTime,
        bool isDrop
    ) external;

    function setStartTime(uint256 _startTime) external;
}
// File: @openzeppelin/contracts/security/ReentrancyGuard.sol


// OpenZeppelin Contracts (last updated v4.9.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

/**
 * @dev Contract module that helps prevent reentrant calls to a function.
 *
 * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
 * available, which can be applied to functions to make sure there are no nested
 * (reentrant) calls to them.
 *
 * Note that because there is a single `nonReentrant` guard, functions marked as
 * `nonReentrant` may not call one another. This can be worked around by making
 * those functions `private`, and then adding `external` `nonReentrant` entry
 * points to them.
 *
 * TIP: If you would like to learn more about reentrancy and alternative ways
 * to protect against it, check out our blog post
 * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
 */
abstract contract ReentrancyGuard {
    // Booleans are more expensive than uint256 or any type that takes up a full
    // word because each write operation emits an extra SLOAD to first read the
    // slot's contents, replace the bits taken up by the boolean, and then write
    // back. This is the compiler's defense against contract upgrades and
    // pointer aliasing, and it cannot be disabled.

    // The values being non-zero value makes deployment a bit more expensive,
    // but in exchange the refund on every call to nonReentrant will be lower in
    // amount. Since refunds are capped to a percentage of the total
    // transaction's gas, it is best to keep them low in cases like this one, to
    // increase the likelihood of the full refund coming into effect.
    uint256 private constant _NOT_ENTERED = 1;
    uint256 private constant _ENTERED = 2;

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        _nonReentrantBefore();
        _;
        _nonReentrantAfter();
    }

    function _nonReentrantBefore() private {
        // On the first call to nonReentrant, _status will be _NOT_ENTERED
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

        // Any calls to nonReentrant after this point will fail
        _status = _ENTERED;
    }

    function _nonReentrantAfter() private {
        // By storing the original value once again, a refund is triggered (see
        // https://eips.ethereum.org/EIPS/eip-2200)
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
     * `nonReentrant` function in the call stack.
     */
    function _reentrancyGuardEntered() internal view returns (bool) {
        return _status == _ENTERED;
    }
}

// File: @openzeppelin/contracts/token/ERC20/IERC20.sol


// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-20 standard as defined in the ERC.
 */
interface IERC20 {
    /**
     * @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 value of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns the value of tokens owned by `account`.
     */
    function balanceOf(address account) external view returns (uint256);

    /**
     * @dev Moves a `value` amount of 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 value) 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 a `value` amount of tokens 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 value) external returns (bool);

    /**
     * @dev Moves a `value` amount of tokens from `from` to `to` using the
     * allowance mechanism. `value` 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 value) external returns (bool);
}

// File: @openzeppelin/contracts/utils/introspection/IERC165.sol


// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)

pragma solidity ^0.8.20;

/**
 * @dev Interface of the ERC-165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[ERC].
 *
 * 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[ERC section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

// File: @openzeppelin/contracts/token/ERC1155/IERC1155.sol


// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.20;


/**
 * @dev Required interface of an ERC-1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[ERC].
 */
interface IERC1155 is IERC165 {
    /**
     * @dev Emitted when `value` amount of tokens of 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 value of tokens of token type `id` owned by `account`.
     */
    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 zero address.
     */
    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 a `value` amount of tokens of type `id` from `from` to `to`.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155Received} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * 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 `value` 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 value, bytes calldata data) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * WARNING: This function can potentially allow a reentrancy attack when transferring tokens
     * to an untrusted contract, when invoking {onERC1155BatchReceived} on the receiver.
     * Ensure to follow the checks-effects-interactions pattern and consider employing
     * reentrancy guards when interacting with untrusted contracts.
     *
     * Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
     *
     * Requirements:
     *
     * - `ids` and `values` 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 values,
        bytes calldata data
    ) external;
}

// File: @openzeppelin/contracts/utils/introspection/ERC165.sol


// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)

pragma solidity ^0.8.20;


/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC-165 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);
 * }
 * ```
 */
abstract contract ERC165 is IERC165 {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return interfaceId == type(IERC165).interfaceId;
    }
}

// File: @openzeppelin/contracts/token/ERC1155/IERC1155Receiver.sol


// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.20;


/**
 * @dev Interface that must be implemented by smart contracts in order to receive
 * ERC-1155 token transfers.
 */
interface IERC1155Receiver is IERC165 {
    /**
     * @dev Handles the receipt of a single ERC-1155 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 ERC-1155 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);
}

// File: @openzeppelin/contracts/token/ERC1155/utils/ERC1155Holder.sol


// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC1155/utils/ERC1155Holder.sol)

pragma solidity ^0.8.20;



/**
 * @dev Simple implementation of `IERC1155Receiver` that will allow a contract to hold ERC-1155 tokens.
 *
 * IMPORTANT: When inheriting this contract, you must include a way to use the received tokens, otherwise they will be
 * stuck.
 */
abstract contract ERC1155Holder is ERC165, IERC1155Receiver {
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
        return interfaceId == type(IERC1155Receiver).interfaceId || super.supportsInterface(interfaceId);
    }

    function onERC1155Received(
        address,
        address,
        uint256,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155Received.selector;
    }

    function onERC1155BatchReceived(
        address,
        address,
        uint256[] memory,
        uint256[] memory,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC1155BatchReceived.selector;
    }
}

// File: @openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol


// OpenZeppelin Contracts (last updated v5.3.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.20;

/**
 * @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]
 * ```solidity
 * 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 Storage of the initializable contract.
     *
     * It's implemented on a custom ERC-7201 namespace to reduce the risk of storage collisions
     * when using with upgradeable contracts.
     *
     * @custom:storage-location erc7201:openzeppelin.storage.Initializable
     */
    struct InitializableStorage {
        /**
         * @dev Indicates that the contract has been initialized.
         */
        uint64 _initialized;
        /**
         * @dev Indicates that the contract is in the process of being initialized.
         */
        bool _initializing;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Initializable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant INITIALIZABLE_STORAGE = 0xf0c57e16840df040f15088dc2f81fe391c3923bec73e23a9662efc9c229c6a00;

    /**
     * @dev The contract is already initialized.
     */
    error InvalidInitialization();

    /**
     * @dev The contract is not initializing.
     */
    error NotInitializing();

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint64 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 in the context of a constructor an `initializer` may be invoked any
     * number of times. This behavior in the constructor can be useful during testing and is not expected to be used in
     * production.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        // Cache values to avoid duplicated sloads
        bool isTopLevelCall = !$._initializing;
        uint64 initialized = $._initialized;

        // Allowed calls:
        // - initialSetup: the contract is not in the initializing state and no previous version was
        //                 initialized
        // - construction: the contract is initialized at version 1 (no reinitialization) and the
        //                 current contract is just being deployed
        bool initialSetup = initialized == 0 && isTopLevelCall;
        bool construction = initialized == 1 && address(this).code.length == 0;

        if (!initialSetup && !construction) {
            revert InvalidInitialization();
        }
        $._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 2**64 - 1 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint64 version) {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing || $._initialized >= version) {
            revert InvalidInitialization();
        }
        $._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() {
        _checkInitializing();
        _;
    }

    /**
     * @dev Reverts if the contract is not in an initializing state. See {onlyInitializing}.
     */
    function _checkInitializing() internal view virtual {
        if (!_isInitializing()) {
            revert NotInitializing();
        }
    }

    /**
     * @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 {
        // solhint-disable-next-line var-name-mixedcase
        InitializableStorage storage $ = _getInitializableStorage();

        if ($._initializing) {
            revert InvalidInitialization();
        }
        if ($._initialized != type(uint64).max) {
            $._initialized = type(uint64).max;
            emit Initialized(type(uint64).max);
        }
    }

    /**
     * @dev Returns the highest version that has been initialized. See {reinitializer}.
     */
    function _getInitializedVersion() internal view returns (uint64) {
        return _getInitializableStorage()._initialized;
    }

    /**
     * @dev Returns `true` if the contract is currently initializing. See {onlyInitializing}.
     */
    function _isInitializing() internal view returns (bool) {
        return _getInitializableStorage()._initializing;
    }

    /**
     * @dev Pointer to storage slot. Allows integrators to override it with a custom storage location.
     *
     * NOTE: Consider following the ERC-7201 formula to derive storage locations.
     */
    function _initializableStorageSlot() internal pure virtual returns (bytes32) {
        return INITIALIZABLE_STORAGE;
    }

    /**
     * @dev Returns a pointer to the storage namespace.
     */
    // solhint-disable-next-line var-name-mixedcase
    function _getInitializableStorage() private pure returns (InitializableStorage storage $) {
        bytes32 slot = _initializableStorageSlot();
        assembly {
            $.slot := slot
        }
    }
}

// File: @openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol


// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)

pragma solidity ^0.8.20;


/**
 * @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;
    }

    function _contextSuffixLength() internal view virtual returns (uint256) {
        return 0;
    }
}

// File: @openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol


// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)

pragma solidity ^0.8.20;



/**
 * @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.
 *
 * The initial owner is set to the address provided by the deployer. 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 {
    /// @custom:storage-location erc7201:openzeppelin.storage.Ownable
    struct OwnableStorage {
        address _owner;
    }

    // keccak256(abi.encode(uint256(keccak256("openzeppelin.storage.Ownable")) - 1)) & ~bytes32(uint256(0xff))
    bytes32 private constant OwnableStorageLocation = 0x9016d09d72d40fdae2fd8ceac6b6234c7706214fd39c1cd1e609a0528c199300;

    function _getOwnableStorage() private pure returns (OwnableStorage storage $) {
        assembly {
            $.slot := OwnableStorageLocation
        }
    }

    /**
     * @dev The caller account is not authorized to perform an operation.
     */
    error OwnableUnauthorizedAccount(address account);

    /**
     * @dev The owner is not a valid owner account. (eg. `address(0)`)
     */
    error OwnableInvalidOwner(address owner);

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    /**
     * @dev Initializes the contract setting the address provided by the deployer as the initial owner.
     */
    function __Ownable_init(address initialOwner) internal onlyInitializing {
        __Ownable_init_unchained(initialOwner);
    }

    function __Ownable_init_unchained(address initialOwner) internal onlyInitializing {
        if (initialOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(initialOwner);
    }

    /**
     * @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) {
        OwnableStorage storage $ = _getOwnableStorage();
        return $._owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        if (owner() != _msgSender()) {
            revert OwnableUnauthorizedAccount(_msgSender());
        }
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby disabling 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 {
        if (newOwner == address(0)) {
            revert OwnableInvalidOwner(address(0));
        }
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        OwnableStorage storage $ = _getOwnableStorage();
        address oldOwner = $._owner;
        $._owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

// File: contracts/marketplace/NFTMarketplace.sol


pragma solidity ^0.8.17;








contract NFTMarketplace is OwnableUpgradeable , ReentrancyGuard, ERC1155Holder {
    enum ListingType { FIXED_PRICE, AUCTION }
    enum AuctionStatus { ACTIVE, ENDED, CANCELLED }
    enum OfferStatus { PENDING, ACCEPTED, REJECTED, CANCELLED }
    struct Listing {
        address seller;
        uint256 price;
        uint256 quantity;
        ListingType listingType;
        uint256 auctionId;  // 0 for fixed price listings
    }

    struct AuctionDetails {
        address seller;
        uint256 startPrice;
        uint256 currentPrice;
        uint256 minBidIncrement;
        uint256 startTime;
        uint256 endTime;
        uint256 tokenId;
        uint256 quantity;
        address highestBidder;
        AuctionStatus status;
    }

    struct Offer {
        address buyer;
        address seller;
        uint256 price;
        uint256 quantity;
        uint256 createTime;
        OfferStatus status;
    }

    struct FilterParams {
        address collection;
        uint256 tokenId;
        address user;
        uint8 filterType;
    }

    struct BatchPurchaseParams {
        address collection;
        uint256 tokenId;
        address seller;
        uint256 quantity;
    }
    
    uint256 public primaryFee;
    uint256 public secondaryFee;
    address public collectionFactory;
    uint256 public totalCollections;
    IERC20 public immutable designatedToken;

    uint256 private _auctionIds;
    uint256 private _offerIds;
    uint256 public minAuctionDuration;
    uint256 public maxAuctionDuration;
    uint256 public auctionExtensionInterval;
    
    mapping(address => mapping(uint256 => mapping(address => Listing))) public listings;
    mapping(address => bool) public registeredCollections;
    mapping(uint256 => address) private collectionIndex;
    mapping(uint256 => AuctionDetails) public auctions;
    mapping(uint256 => mapping(address => uint256)) public bids;
    mapping(uint256 => address) public auctionCollections;

    // Offer mappings
    mapping(address => mapping(uint256 => mapping(uint256 => Offer))) public offers; // collection => tokenId => offerId => Offer
    mapping(address => uint256[]) private userOfferIds; // buyer => offerIds
    mapping(uint256 => address) private offerCollections; // offerId => collection
    mapping(uint256 => uint256) private offerTokenIds; // offerId => tokenId
    mapping(address => uint256[]) private sellerReceivedOffers; // seller => offerIds
    mapping(address => mapping(uint256 => uint256[])) private tokenOffers; // collection => tokenId => offerIds
    
    event NFTListed(
        address indexed collection, 
        uint256 indexed tokenId, 
        address seller, 
        uint256 price, 
        uint256 quantity,
        ListingType listingType,
        uint256 auctionId
    );
    event NFTSold(address indexed collection, uint256 indexed tokenId, address seller, address buyer, uint256 price, uint256 quantity);
    event ListingRemoved(address indexed collection, uint256 indexed tokenId, address seller, string reason);
    event ListingQuantityUpdated(
        address indexed collection,
        uint256 indexed tokenId,
        address seller,
        uint256 newQuantity
    );
    event AuctionCreated(
        uint256 indexed auctionId,
        address indexed collection,
        uint256 indexed tokenId,
        address seller,
        uint256 startPrice,
        uint256 minBidIncrement,
        uint256 startTime,
        uint256 endTime,
        uint256 quantity
    );

    event BidPlaced(
        uint256 indexed auctionId,
        address indexed bidder,
        uint256 amount
    );

    event AuctionSettled(
        uint256 indexed auctionId,
        address indexed winner,
        uint256 amount
    );

    event AuctionCancelled(uint256 indexed auctionId);
    event AuctionExtended(uint256 indexed auctionId, uint256 newEndTime);

    event FeeUpdated(bool isPrimary, uint256 newFee);
    event CollectionRegistered(address indexed collection);
    event AuctionExtensionIntervalUpdated(uint256 newInterval);

    event OfferCreated(
        uint256 indexed offerId,
        address indexed collection,
        uint256 indexed tokenId,
        address buyer,
        address seller,
        uint256 price,
        uint256 quantity
    );

    event OfferAccepted(uint256 indexed offerId, address indexed seller);
    event OfferRejected(uint256 indexed offerId, address indexed seller);
    event OfferCancelled(uint256 indexed offerId, address indexed buyer);
    
    constructor(
        address _designatedToken,
        uint256 _primaryFee,
        uint256 _secondaryFee
    ) {
        require(_designatedToken != address(0), "Invalid token address");
        require(_primaryFee <= 1000, "Primary fee too high");
        require(_secondaryFee <= 1000, "Secondary fee too high");
        
        designatedToken = IERC20(_designatedToken);
        primaryFee = _primaryFee;
        secondaryFee = _secondaryFee;
        minAuctionDuration = 1 hours;
        maxAuctionDuration = 30 days;
        auctionExtensionInterval = 10 minutes;
    }
    
    function setCollectionFactory(address _factory) external onlyOwner {
        require(_factory != address(0), "Invalid factory address");
        collectionFactory = _factory;
    }

    function registerCollection(address collection) external {
        require(msg.sender == collectionFactory, "Only factory can register");
        require(collection != address(0), "Invalid collection address");
        require(!registeredCollections[collection], "Already registered");
        
        registeredCollections[collection] = true;
        collectionIndex[totalCollections] = collection;
        totalCollections++;
        
        emit CollectionRegistered(collection);
    }
    
    function setPrimaryFee(uint256 _fee) external onlyOwner {
        require(_fee <= 1000, "Fee too high");
        primaryFee = _fee;
        emit FeeUpdated(true, _fee);
    }
    
    function setSecondaryFee(uint256 _fee) external onlyOwner {
        require(_fee <= 1000, "Fee too high");
        secondaryFee = _fee;
        emit FeeUpdated(false, _fee);
    }
    
    function listNFT(
        address collection,
        uint256 tokenId,
        uint256 price,
        uint256 quantity
    ) external nonReentrant {
        require(registeredCollections[collection], "Collection not registered");
        require(price > 0, "Invalid price");
        require(quantity > 0, "Invalid quantity");
        require(
            IERC1155(collection).balanceOf(msg.sender, tokenId) >= quantity,
            "Insufficient balance"
        );

        // Check if NFT is already listed by this seller
        Listing storage existingListing = listings[collection][tokenId][msg.sender];
        require(
            existingListing.quantity == 0 || 
            (existingListing.listingType == ListingType.AUCTION && 
             auctions[existingListing.auctionId].status != AuctionStatus.ACTIVE), 
            "Already listed"
        );

        listings[collection][tokenId][msg.sender] = Listing({
            seller: msg.sender,
            price: price,
            quantity: quantity,
            listingType: ListingType.FIXED_PRICE,
            auctionId: 0
        });

        emit NFTListed(
            collection, 
            tokenId, 
            msg.sender, 
            price, 
            quantity,
            ListingType.FIXED_PRICE,
            0
        );
    }
    
    function removeListing(
        address collection,
        uint256 tokenId
    ) external nonReentrant {
        Listing storage listing = listings[collection][tokenId][msg.sender];
        require(listing.seller == msg.sender && listing.quantity > 0, "No active listing");
        
        if (listing.listingType == ListingType.AUCTION) {
            AuctionDetails storage auction = auctions[listing.auctionId];
            require(auction.status == AuctionStatus.ACTIVE, "Auction not active");
            require(auction.highestBidder == address(0), "Bids already placed");
            
            auction.status = AuctionStatus.CANCELLED;
            IERC1155(collection).safeTransferFrom(
                address(this),
                msg.sender,
                tokenId,
                listing.quantity,
                ""
            );
            
            emit AuctionCancelled(listing.auctionId);
        }

        delete listings[collection][tokenId][msg.sender];
        emit ListingRemoved(collection, tokenId, msg.sender, "REMOVED_BY_SELLER");
    }
    
    function buyListedNFT(
        address collection,
        uint256 tokenId,
        address seller,
        uint256 quantity
    ) external nonReentrant {
        require(registeredCollections[collection], "Collection not registered");
        Listing storage listing = listings[collection][tokenId][seller];
        require(listing.seller == seller && listing.quantity > 0, "Invalid listing");
        require(listing.listingType == ListingType.FIXED_PRICE, "Not a fixed price listing");
        require(listing.quantity >= quantity, "Insufficient quantity");

        ICollection.NFTDetails memory nftDetails = ICollection(collection).nftDetails(tokenId);
        
        uint256 fee = secondaryFee;
        if(nftDetails.creator == seller) {
            fee = primaryFee;
        }
        uint16 royaltyPercentage = ICollection(collection).getRoyaltyPercentage();
        uint256 totalPrice = listing.price * quantity;
        uint256 platformFee = (totalPrice * fee) / 1000;
        uint256 royaltyFee  = (totalPrice * royaltyPercentage) / 1000;
        uint256 sellerAmount = totalPrice - platformFee - royaltyFee;
        
        designatedToken.transferFrom(msg.sender, address(this), platformFee);
        designatedToken.transferFrom(msg.sender, seller, sellerAmount);
        if(royaltyFee > 0) {
            designatedToken.transferFrom(msg.sender, nftDetails.creator, royaltyFee);
        }
        
        IERC1155(collection).safeTransferFrom(seller, msg.sender, tokenId, quantity, "");
        
        listing.quantity -= quantity;
        if (listing.quantity == 0) {
            delete listings[collection][tokenId][seller];
            emit ListingRemoved(collection, tokenId, seller, "SOLD_OUT");
        }
        
        emit NFTSold(collection, tokenId, seller, msg.sender, listing.price, quantity);
    }
    
    function getRegisteredCollections(uint256 offset, uint256 limit) 
        public 
        view 
        returns (address[] memory collections) 
    {
        require(offset <= totalCollections, "Invalid offset");
        
        uint256 size = totalCollections - offset;
        if (size > limit) {
            size = limit;
        }
        
        collections = new address[](size);
        
        for (uint256 i = 0; i < size; i++) {
            collections[i] = collectionIndex[offset + i];
        }
        
        return collections;
    }
    
    function getCollectionsByOwner(address _owner, uint256 offset, uint256 limit)
        external
        view
        returns (address[] memory _collections, uint256 total)
    {
        uint256 count = 0;
        
        for (uint256 i = 0; i < totalCollections; i++) {
            address collection = collectionIndex[i];
            if (OwnableUpgradeable(collection).owner() == _owner) {
                count++;
            }
        }
        
        require(offset <= count, "Invalid offset");
        
        uint256 size = count - offset;
        if (size > limit) {
            size = limit;
        }
        
        _collections = new address[](size);
        uint256 currentIndex = 0;
        uint256 skipped = 0;
        
        for (uint256 i = 0; i < totalCollections && currentIndex < size; i++) {
            address collection = collectionIndex[i];
            if (OwnableUpgradeable(collection).owner() == _owner) {
                if (skipped < offset) {
                    skipped++;
                    continue;
                }
                _collections[currentIndex] = collection;
                currentIndex++;
            }
        }
        
        return (_collections, count);
    }
    
    function withdrawFees() external onlyOwner {
        uint256 balance = designatedToken.balanceOf(address(this));
        if (balance > 0) {
            designatedToken.transfer(owner(), balance);
        }
    }
    
    function getListing(
        address collection,
        uint256 tokenId,
        address seller
    ) external view returns (Listing memory) {
        return listings[collection][tokenId][seller];
    }

    function createAuction(
        address collection,
        uint256 tokenId,
        uint256 quantity,
        uint256 startPrice,
        uint256 minBidIncrement,
        uint256 duration
    ) external nonReentrant returns (uint256) {
        _validateAuctionParams(
            collection,
            tokenId,
            quantity,
            startPrice,
            minBidIncrement,
            duration
        );

        _auctionIds++;
        uint256 auctionId = _auctionIds;
        
        _createAuctionListing(
            collection,
            tokenId,
            quantity,
            startPrice,
            auctionId
        );

        _setupAuction(
            auctionId,
            collection,
            tokenId,
            quantity,
            startPrice,
            minBidIncrement,
            duration
        );

        return auctionId;
    }

    function _validateAuctionParams(
        address collection,
        uint256 tokenId,
        uint256 quantity,
        uint256 startPrice,
        uint256 minBidIncrement,
        uint256 duration
    ) internal view {
        require(registeredCollections[collection], "Collection not registered");
        require(quantity > 0, "Invalid quantity");
        require(startPrice > 0, "Invalid start price");
        require(minBidIncrement > 0, "Invalid min bid increment");
        require(duration >= minAuctionDuration && duration <= maxAuctionDuration, "Invalid duration");
        require(
            IERC1155(collection).balanceOf(msg.sender, tokenId) >= quantity,
            "Insufficient balance"
        );
        require(
            IERC1155(collection).isApprovedForAll(msg.sender, address(this)),
            "Not approved"
        );

        Listing storage existingListing = listings[collection][tokenId][msg.sender];
        require(
            existingListing.quantity == 0 || 
            (existingListing.listingType == ListingType.AUCTION && 
             auctions[existingListing.auctionId].status != AuctionStatus.ACTIVE), 
            "Already listed"
        );
    }

    function _createAuctionListing(
        address collection,
        uint256 tokenId,
        uint256 quantity,
        uint256 startPrice,
        uint256 auctionId
    ) internal {
        listings[collection][tokenId][msg.sender] = Listing({
            seller: msg.sender,
            price: startPrice,
            quantity: quantity,
            listingType: ListingType.AUCTION,
            auctionId: auctionId
        });

        emit NFTListed(
            collection, 
            tokenId, 
            msg.sender, 
            startPrice, 
            quantity,
            ListingType.AUCTION,
            auctionId
        );
    }

    function _setupAuction(
        uint256 auctionId,
        address collection,
        uint256 tokenId,
        uint256 quantity,
        uint256 startPrice,
        uint256 minBidIncrement,
        uint256 duration
    ) internal {
        uint256 startTime = block.timestamp;
        uint256 endTime = startTime + duration;

        auctions[auctionId] = AuctionDetails({
            seller: msg.sender,
            startPrice: startPrice,
            currentPrice: startPrice,
            minBidIncrement: minBidIncrement,
            startTime: startTime,
            endTime: endTime,
            tokenId: tokenId,
            quantity: quantity,
            highestBidder: address(0),
            status: AuctionStatus.ACTIVE
        });

        auctionCollections[auctionId] = collection;

        IERC1155(collection).safeTransferFrom(
            msg.sender,
            address(this),
            tokenId,
            quantity,
            ""
        );

        emit AuctionCreated(
            auctionId,
            collection,
            tokenId,
            msg.sender,
            startPrice,
            minBidIncrement,
            startTime,
            endTime,
            quantity
        );
    }

    function placeBid(uint256 auctionId, uint256 bidAmount) external nonReentrant {
        AuctionDetails storage auction = auctions[auctionId];
        require(auction.status == AuctionStatus.ACTIVE, "Auction not active");
        require(block.timestamp <= auction.endTime, "Auction ended");
        require(bidAmount >= auction.currentPrice + auction.minBidIncrement, "Bid too low");

        // Check if bid is placed near the end
        if (auction.endTime - block.timestamp <= auctionExtensionInterval) {
            auction.endTime = block.timestamp + auctionExtensionInterval;
            emit AuctionExtended(auctionId, auction.endTime);
        }

        address previousBidder = auction.highestBidder;
        uint256 previousBid = bids[auctionId][previousBidder];

        if (previousBidder != address(0)) {
            designatedToken.transfer(previousBidder, previousBid);
        }

        require(
            designatedToken.transferFrom(msg.sender, address(this), bidAmount),
            "Transfer failed"
        );

        auction.highestBidder = msg.sender;
        auction.currentPrice = bidAmount;
        bids[auctionId][msg.sender] = bidAmount;

        emit BidPlaced(auctionId, msg.sender, bidAmount);
    }

    function settleAuction(uint256 auctionId) external nonReentrant {
        AuctionDetails storage auction = auctions[auctionId];
        require(auction.status == AuctionStatus.ACTIVE, "Auction not active");
        require(block.timestamp > auction.endTime, "Auction not ended");
        require(auction.highestBidder != address(0), "No bids placed");

        auction.status = AuctionStatus.ENDED;
        address collection = auctionCollections[auctionId];
        uint256 finalPrice = auction.currentPrice;
        ICollection.NFTDetails memory nftDetails = ICollection(collection).nftDetails(auction.tokenId);

        uint256 fee = secondaryFee;
        if(nftDetails.creator == auction.seller) {
            fee = primaryFee;
        }
        uint16 royaltyPercentage = ICollection(collection).getRoyaltyPercentage();
        // Calculate fees
        uint256 platformFee = (finalPrice * fee) / 1000;
        uint256 royaltyFee = (finalPrice * royaltyPercentage) / 1000;
        uint256 sellerAmount = finalPrice - platformFee - royaltyFee;

        // Distribute funds
        designatedToken.transfer(auction.seller, sellerAmount);
        if(royaltyFee>0) {
            designatedToken.transfer(nftDetails.creator, royaltyFee);
        }

        // Transfer NFT
        IERC1155(collection).safeTransferFrom(
            address(this),
            auction.highestBidder,
            auction.tokenId,
            auction.quantity,
            ""
        );

        // Remove listing
        address seller = auction.seller;
        delete listings[collection][auction.tokenId][seller];
        emit ListingRemoved(collection, auction.tokenId, seller, "AUCTION_SETTLED");

        emit AuctionSettled(auctionId, auction.highestBidder, finalPrice);
    }

    function cancelAuction(uint256 auctionId) external nonReentrant {
        AuctionDetails storage auction = auctions[auctionId];
        require(auction.status == AuctionStatus.ACTIVE, "Auction not active");
        require(msg.sender == auction.seller, "Not seller");
        require(auction.highestBidder == address(0), "Bids already placed");

        auction.status = AuctionStatus.CANCELLED;
        address collection = auctionCollections[auctionId];

        IERC1155(collection).safeTransferFrom(
            address(this),
            auction.seller,
            auction.tokenId,
            auction.quantity,
            ""
        );

        // Remove listing
        delete listings[collection][auction.tokenId][auction.seller];
        emit ListingRemoved(collection, auction.tokenId, auction.seller, "AUCTION_CANCELLED");

        emit AuctionCancelled(auctionId);
    }

    function setAuctionExtensionInterval(uint256 _interval) external onlyOwner {
        require(_interval > 0, "Invalid interval");
        auctionExtensionInterval = _interval;
        emit AuctionExtensionIntervalUpdated(_interval);
    }

    function makeOffer(
        address collection,
        uint256 tokenId,
        address seller,
        uint256 quantity,
        uint256 price
    ) external nonReentrant {
        require(registeredCollections[collection], "Collection not registered");
        require(quantity > 0, "Invalid quantity");
        require(price > 0, "Invalid price");
        require(seller != address(0), "Invalid seller");
        require(seller != msg.sender, "Cannot make offer to self");
        
        uint256 sellerBalance = IERC1155(collection).balanceOf(seller, tokenId);
        require(sellerBalance >= quantity, "Insufficient seller balance");

        _offerIds++;
        uint256 offerId = _offerIds;

        offers[collection][tokenId][offerId] = Offer({
            buyer: msg.sender,
            seller: seller,
            price: price,
            quantity: quantity,
            createTime: block.timestamp,
            status: OfferStatus.PENDING
        });

        userOfferIds[msg.sender].push(offerId);
        sellerReceivedOffers[seller].push(offerId);
        tokenOffers[collection][tokenId].push(offerId);
        offerCollections[offerId] = collection;
        offerTokenIds[offerId] = tokenId;

        // Pre-approve marketplace for token transfer
        designatedToken.transferFrom(msg.sender, address(this), price * quantity);

        emit OfferCreated(offerId, collection, tokenId, msg.sender, seller, price, quantity);
    }

    function acceptOffer(uint256 offerId) external nonReentrant {
        (address collection, uint256 tokenId, Offer storage offer) = _validateAndGetOffer(offerId);
        uint256 totalBalance = _validateSellerBalance(collection, tokenId, offer);
        _validateAndUpdateListing(collection, tokenId, offer.quantity, totalBalance);
        _processOfferAcceptance(collection, tokenId, offer, offerId);
    }

    function _validateAndGetOffer(uint256 offerId) private view returns (
        address collection,
        uint256 tokenId,
        Offer storage offer
    ) {
        collection = offerCollections[offerId];
        require(collection != address(0), "Offer does not exist");

        tokenId = offerTokenIds[offerId];
        offer = offers[collection][tokenId][offerId];
        
        require(offer.status == OfferStatus.PENDING, "Invalid offer status");
        require(msg.sender == offer.seller, "Not offer recipient");

        return (collection, tokenId, offer);
    }

    function _validateSellerBalance(
        address collection,
        uint256 tokenId,
        Offer memory offer
    ) private view returns (uint256) {
        uint256 totalBalance = IERC1155(collection).balanceOf(msg.sender, tokenId);
        require(totalBalance >= offer.quantity, "Insufficient balance");
        return totalBalance;
    }

    function _validateAndUpdateListing(
        address collection,
        uint256 tokenId,
        uint256 offerQuantity,
        uint256 totalBalance
    ) private {
        Listing storage listing = listings[collection][tokenId][msg.sender];
        
        // Check if NFT is not in active auction
        if(listing.listingType == ListingType.AUCTION) {
            require(
                auctions[listing.auctionId].status != AuctionStatus.ACTIVE,
                "Active auction exists"
            );
        }

        // Calculate available quantities
        uint256 listedQuantity = listing.quantity;
        uint256 unlistedQuantity = totalBalance - listedQuantity;
        
        // Calculate how many NFTs to take from unlisted and listed
        uint256 takeFromUnlisted = unlistedQuantity >= offerQuantity ? 
            offerQuantity : unlistedQuantity;
        uint256 takeFromListed = offerQuantity - takeFromUnlisted;

        // Update listing if needed
        if(takeFromListed > 0) {
            if(takeFromListed == listedQuantity) {
                delete listings[collection][tokenId][msg.sender];
                emit ListingRemoved(collection, tokenId, msg.sender, "ZERO_QUANTITY");
            } else {
                listing.quantity = listedQuantity - takeFromListed;
                emit ListingQuantityUpdated(
                    collection,
                    tokenId,
                    msg.sender,
                    listing.quantity
                );
            }
        }
    }

    function _processOfferAcceptance(
        address collection,
        uint256 tokenId,
        Offer storage offer,
        uint256 offerId
    ) private {
        require(
            IERC1155(collection).isApprovedForAll(msg.sender, address(this)),
            "Not approved"
        );
        ICollection.NFTDetails memory nftDetails = ICollection(collection).nftDetails(tokenId);

        uint256 fee = secondaryFee;
        if(nftDetails.creator == msg.sender) {
            fee = primaryFee;
        }
        uint16 royaltyPercentage = ICollection(collection).getRoyaltyPercentage();

        // Calculate fees
        uint256 totalPrice = offer.price * offer.quantity;
        uint256 platformFee = (totalPrice * fee) / 1000;
        uint256 royaltyFee = (totalPrice * royaltyPercentage) / 1000;
        uint256 sellerAmount = totalPrice - platformFee - royaltyFee;

        // Transfer NFT
        IERC1155(collection).safeTransferFrom(
            msg.sender,
            offer.buyer,
            tokenId,
            offer.quantity,
            ""
        );

        // Distribute payments
        designatedToken.transfer(msg.sender, sellerAmount);
        if(royaltyFee>0) {
            designatedToken.transfer(nftDetails.creator, royaltyFee);
        }
        

        offer.status = OfferStatus.ACCEPTED;
        emit OfferAccepted(offerId, msg.sender);
    }

    function rejectOffer(uint256 offerId) external nonReentrant {
        address collection = offerCollections[offerId];
        uint256 tokenId = offerTokenIds[offerId];
        require(collection != address(0), "Offer does not exist");

        Offer storage offer = offers[collection][tokenId][offerId];
        require(offer.status == OfferStatus.PENDING, "Invalid offer status");
        require(
            IERC1155(collection).balanceOf(msg.sender, tokenId) > 0,
            "Not token owner"
        );

        offer.status = OfferStatus.REJECTED;

        // Refund buyer
        designatedToken.transfer(offer.buyer, offer.price * offer.quantity);

        emit OfferRejected(offerId, msg.sender);
    }

    function cancelOffer(uint256 offerId) external nonReentrant {
        address collection = offerCollections[offerId];
        uint256 tokenId = offerTokenIds[offerId];
        require(collection != address(0), "Offer does not exist");

        Offer storage offer = offers[collection][tokenId][offerId];
        require(offer.buyer == msg.sender, "Not offer creator");
        require(offer.status == OfferStatus.PENDING, "Invalid offer status");

        offer.status = OfferStatus.CANCELLED;

        // Refund buyer
        designatedToken.transfer(msg.sender, offer.price * offer.quantity);

        emit OfferCancelled(offerId, msg.sender);
    }

    function getOffersByToken(
        address collection,
        uint256 tokenId,
        uint256 offset,
        uint256 limit
    ) external view returns (uint256[] memory offerIdList, uint256 total) {
        return _getOffersWithFilter(
            collection,
            tokenId,
            address(0), // no user filter
            offset,
            limit,
            0 // filter type: BY_TOKEN
        );
    }

    function getOffersToSeller(
        address seller,
        uint256 offset,
        uint256 limit
    ) external view returns (uint256[] memory offerIdList, uint256 total) {
        return _getOffersWithFilter(
            address(0), // no collection filter
            0, // no tokenId filter
            seller,
            offset,
            limit,
            1 // filter type: BY_SELLER
        );
    }

    function getOffersByBuyer(
        address buyer,
        uint256 offset,
        uint256 limit
    ) external view returns (uint256[] memory offerIdList, uint256 total) {
        return _getOffersWithFilter(
            address(0), // no collection filter
            0, // no tokenId filter
            buyer,
            offset,
            limit,
            2 // filter type: BY_BUYER
        );
    }

    function _getOffersWithFilter(
        address collection,
        uint256 tokenId,
        address user,
        uint256 offset,
        uint256 limit,
        uint8 filterType
    ) private view returns (uint256[] memory offerIdList, uint256 total) {
        FilterParams memory params = FilterParams(collection, tokenId, user, filterType);
        uint256[] storage sourceOffers = _getSourceOffers(user, filterType, params);
        
        // Get total count first
        uint256 count = _countValidOffers(sourceOffers, params);

        if(count == 0 || offset >= count) {
            return (new uint256[](0), count);
        }

        return _getFilteredOffers(sourceOffers, params, offset, limit, count);
    }

    function _getSourceOffers(address user, uint8 filterType, FilterParams memory params) private view returns (uint256[] storage) {
        if (filterType == 0) { // BY_TOKEN
            return tokenOffers[params.collection][params.tokenId];
        } else if (filterType == 1) { // BY_SELLER
            return sellerReceivedOffers[user];
        } else { // BY_BUYER
            return userOfferIds[user];
        }
    }

    function _countValidOffers(
        uint256[] storage sourceOffers, 
        FilterParams memory params
    ) private view returns (uint256) {
        uint256 count;
        for(uint256 i = 0; i < sourceOffers.length; i++) {
            if(_isValidOffer(sourceOffers[i], params)) {
                count++;
            }
        }
        return count;
    }

    function _getFilteredOffers(
        uint256[] storage sourceOffers,
        FilterParams memory params,
        uint256 offset,
        uint256 limit,
        uint256 count
    ) private view returns (uint256[] memory offerIdList, uint256) {
        uint256 size = count - offset;
        if(size > limit) {
            size = limit;
        }

        offerIdList = new uint256[](size);
        uint256 currentIndex;
        uint256 skipped;

        for(uint256 i = 0; i < sourceOffers.length && currentIndex < size; i++) {
            uint256 offerId = sourceOffers[i];
            if(_isValidOffer(offerId, params)) {
                if(skipped < offset) {
                    skipped++;
                    continue;
                }
                offerIdList[currentIndex++] = offerId;
            }
        }

        return (offerIdList, count);
    }

    function _isValidOffer(
        uint256 offerId,
        FilterParams memory params
    ) private view returns (bool) {
        address offerCollection = offerCollections[offerId];
        uint256 offerTokenId = offerTokenIds[offerId];
        Offer storage offer = offers[offerCollection][offerTokenId][offerId];

        if (params.filterType == 0) { // BY_TOKEN
            return offerCollection == params.collection && 
                   offerTokenId == params.tokenId &&
                   offer.status == OfferStatus.PENDING;
        } else if (params.filterType == 1) { // BY_SELLER
            return offer.seller == params.user &&
                   offer.status == OfferStatus.PENDING;
        } else { // BY_BUYER
            return offer.buyer == params.user &&
                   offer.status == OfferStatus.PENDING;
        }
    }

    function getOffer(uint256 offerId) external view returns (
        address collection,
        uint256 tokenId,
        Offer memory offer
    ) {
        collection = offerCollections[offerId];
        require(collection != address(0), "Offer does not exist");
        
        tokenId = offerTokenIds[offerId];
        offer = offers[collection][tokenId][offerId];
        
        return (collection, tokenId, offer);
    }

    function batchBuyListedNFTs(BatchPurchaseParams[] calldata params) external nonReentrant {
        require(params.length > 0, "Empty batch");
        
        for(uint256 i = 0; i < params.length; i++) {
            BatchPurchaseParams calldata purchase = params[i];
            require(registeredCollections[purchase.collection], "Collection not registered");
            
            Listing storage listing = listings[purchase.collection][purchase.tokenId][purchase.seller];
            require(listing.seller == purchase.seller && listing.quantity > 0, "Invalid listing");
            require(listing.listingType == ListingType.FIXED_PRICE, "Not a fixed price listing");
            require(listing.quantity >= purchase.quantity, "Insufficient quantity");

            ICollection.NFTDetails memory nftDetails = ICollection(purchase.collection).nftDetails(purchase.tokenId);
            
            uint256 fee = secondaryFee;
            if(nftDetails.creator == purchase.seller) {
                fee = primaryFee;
            }
            uint16 royaltyPercentage = ICollection(purchase.collection).getRoyaltyPercentage();
            uint256 totalPrice = listing.price * purchase.quantity;
            uint256 platformFee = (totalPrice * fee) / 1000;
            uint256 royaltyFee = (totalPrice * royaltyPercentage) / 1000;
            uint256 sellerAmount = totalPrice - platformFee - royaltyFee;

            designatedToken.transferFrom(msg.sender, address(this), platformFee);
            designatedToken.transferFrom(msg.sender, purchase.seller, sellerAmount);
            if(royaltyFee>0) {
                designatedToken.transferFrom(msg.sender, nftDetails.creator, royaltyFee);
            }

            IERC1155(purchase.collection).safeTransferFrom(
                purchase.seller, 
                msg.sender, 
                purchase.tokenId, 
                purchase.quantity, 
                ""
            );

            listing.quantity -= purchase.quantity;
            if (listing.quantity == 0) {
                delete listings[purchase.collection][purchase.tokenId][purchase.seller];
                emit ListingRemoved(purchase.collection, purchase.tokenId, purchase.seller, "SOLD_OUT");
            }

            emit NFTSold(
                purchase.collection, 
                purchase.tokenId, 
                purchase.seller, 
                msg.sender, 
                listing.price, 
                purchase.quantity
            );
        }
    }
}
// File: contracts/collection/CollectionFactory.sol


pragma solidity ^0.8.17;






contract CollectionFactory is Ownable {
    using Clones for address;

    address public immutable collectionImplementation;
    address public immutable dropImplementation;
    address public marketplace;
    
    mapping(address => address[]) public userCollections;
    mapping(address => bool) public isCollectionCreatedByUs;
    
    event CollectionCreated(address indexed collection, address indexed owner, bool isDrop);
    event MarketplaceUpdated(address indexed newMarketplace);
    
    constructor(
        address _owner,
        address _collectionImpl,
        address _dropImpl,
        address _marketplace
    ) Ownable(_owner) {
        require(_collectionImpl != address(0), "Invalid collection implementation");
        require(_dropImpl != address(0), "Invalid drop implementation");
        require(_marketplace != address(0), "Invalid marketplace");
        
        collectionImplementation = _collectionImpl;
        dropImplementation = _dropImpl;
        marketplace = _marketplace;
    }

    function setMarketplace(address _marketplace) external onlyOwner {
        require(_marketplace != address(0), "Invalid marketplace address");
        marketplace = _marketplace;
        emit MarketplaceUpdated(_marketplace);
    }
    
    function createCollection(
        string memory name,
        string memory symbol,
        bool isDrop,
        uint256 startTime
    ) external returns (address) {
        require(bytes(name).length > 0, "Invalid name");
        require(bytes(symbol).length > 0, "Invalid description");
        address implementation = isDrop ? dropImplementation : collectionImplementation;
        address clone = Clones.clone(implementation);
        
        if (isDrop) {
            IDrop(clone).initialize(
                name,
                symbol,
                msg.sender,
                marketplace,
                startTime,
                isDrop
            );
        } else {
            ICollection(clone).initialize(
                name,
                symbol,
                msg.sender,
                marketplace,
                isDrop
            );
        }
        
        userCollections[msg.sender].push(clone);
        isCollectionCreatedByUs[clone] = true;
        
        NFTMarketplace(marketplace).registerCollection(clone);
        
        emit CollectionCreated(clone, msg.sender, isDrop);
        return clone;
    }

    function verifyCollection(address collection) external view returns (bool) {
        return isCollectionCreatedByUs[collection];
    }
    
    function getUserCollections(address user) external view returns (address[] memory) {
        return userCollections[user];
    }
}
        

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_owner","internalType":"address"},{"type":"address","name":"_collectionImpl","internalType":"address"},{"type":"address","name":"_dropImpl","internalType":"address"},{"type":"address","name":"_marketplace","internalType":"address"}]},{"type":"error","name":"FailedDeployment","inputs":[]},{"type":"error","name":"InsufficientBalance","inputs":[{"type":"uint256","name":"balance","internalType":"uint256"},{"type":"uint256","name":"needed","internalType":"uint256"}]},{"type":"error","name":"OwnableInvalidOwner","inputs":[{"type":"address","name":"owner","internalType":"address"}]},{"type":"error","name":"OwnableUnauthorizedAccount","inputs":[{"type":"address","name":"account","internalType":"address"}]},{"type":"event","name":"CollectionCreated","inputs":[{"type":"address","name":"collection","internalType":"address","indexed":true},{"type":"address","name":"owner","internalType":"address","indexed":true},{"type":"bool","name":"isDrop","internalType":"bool","indexed":false}],"anonymous":false},{"type":"event","name":"MarketplaceUpdated","inputs":[{"type":"address","name":"newMarketplace","internalType":"address","indexed":true}],"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":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"collectionImplementation","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"createCollection","inputs":[{"type":"string","name":"name","internalType":"string"},{"type":"string","name":"symbol","internalType":"string"},{"type":"bool","name":"isDrop","internalType":"bool"},{"type":"uint256","name":"startTime","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"dropImplementation","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address[]","name":"","internalType":"address[]"}],"name":"getUserCollections","inputs":[{"type":"address","name":"user","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"isCollectionCreatedByUs","inputs":[{"type":"address","name":"","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"marketplace","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"owner","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"renounceOwnership","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"setMarketplace","inputs":[{"type":"address","name":"_marketplace","internalType":"address"}]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"transferOwnership","inputs":[{"type":"address","name":"newOwner","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"address"}],"name":"userCollections","inputs":[{"type":"address","name":"","internalType":"address"},{"type":"uint256","name":"","internalType":"uint256"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bool","name":"","internalType":"bool"}],"name":"verifyCollection","inputs":[{"type":"address","name":"collection","internalType":"address"}]}]
              

Contract Creation Code

Verify & Publish
0x60c060405234801561001057600080fd5b5060405162000d4738038062000d4783398101604081905261003191610212565b836001600160a01b03811661006157604051631e4fbdf760e01b8152600060048201526024015b60405180910390fd5b61006a816101a6565b506001600160a01b0383166100cb5760405162461bcd60e51b815260206004820152602160248201527f496e76616c696420636f6c6c656374696f6e20696d706c656d656e746174696f6044820152603760f91b6064820152608401610058565b6001600160a01b0382166101215760405162461bcd60e51b815260206004820152601b60248201527f496e76616c69642064726f7020696d706c656d656e746174696f6e00000000006044820152606401610058565b6001600160a01b0381166101775760405162461bcd60e51b815260206004820152601360248201527f496e76616c6964206d61726b6574706c616365000000000000000000000000006044820152606401610058565b6001600160a01b0392831660805290821660a052600180546001600160a01b0319169190921617905550610266565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b80516001600160a01b038116811461020d57600080fd5b919050565b6000806000806080858703121561022857600080fd5b610231856101f6565b935061023f602086016101f6565b925061024d604086016101f6565b915061025b606086016101f6565b905092959194509250565b60805160a051610aad6200029a600039600081816101fb01526102d901526000818161012101526102b30152610aad6000f3fe608060405234801561001057600080fd5b50600436106100b45760003560e01c806373ad6c2d1161007157806373ad6c2d1461018c5780638da5cb5b1461019f5780639aa5ad8c146101b0578063abc8c7af146101d0578063f2fde38b146101e3578063ffb54877146101f657600080fd5b80630339e7b6146100b95780630bd11491146100e95780630f3b901f1461011c5780633908cc9314610143578063428a61711461016f578063715018a614610182575b600080fd5b6100cc6100c7366004610854565b61021d565b6040516001600160a01b0390911681526020015b60405180910390f35b61010c6100f73660046108f3565b60036020526000908152604090205460ff1681565b60405190151581526020016100e0565b6100cc7f000000000000000000000000000000000000000000000000000000000000000081565b61010c6101513660046108f3565b6001600160a01b031660009081526003602052604090205460ff1690565b6100cc61017d366004610915565b6104e3565b61018a61051b565b005b61018a61019a3660046108f3565b61052f565b6000546001600160a01b03166100cc565b6101c36101be3660046108f3565b6105d7565b6040516100e0919061093f565b6001546100cc906001600160a01b031681565b61018a6101f13660046108f3565b61064d565b6100cc7f000000000000000000000000000000000000000000000000000000000000000081565b6000808551116102635760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206e616d6560a01b60448201526064015b60405180910390fd5b60008451116102aa5760405162461bcd60e51b815260206004820152601360248201527224b73b30b634b2103232b9b1b934b83a34b7b760691b604482015260640161025a565b6000836102d7577f00000000000000000000000000000000000000000000000000000000000000006102f9565b7f00000000000000000000000000000000000000000000000000000000000000005b905060006103068261068b565b9050841561038157600154604051638a8d349360e01b81526001600160a01b0383811692638a8d34939261034a928c928c923392909116908b908d906004016109d2565b600060405180830381600087803b15801561036457600080fd5b505af1158015610378573d6000803e3d6000fd5b505050506103ee565b600154604051633edd55b160e11b81526001600160a01b0383811692637dbaab62926103bb928c928c923392909116908c90600401610a28565b600060405180830381600087803b1580156103d557600080fd5b505af11580156103e9573d6000803e3d6000fd5b505050505b3360009081526002602090815260408083208054600180820183559185528385200180546001600160a01b0319166001600160a01b03878116918217909255808652600390945293829020805460ff1916821790555490516320e202bb60e11b81526004810192909252909116906341c4057690602401600060405180830381600087803b15801561047f57600080fd5b505af1158015610493573d6000803e3d6000fd5b505060405187151581523392506001600160a01b03841691507f1e5508feeacc96584a6f6c8e88ed33491daa038f32b137029058cd046bf24ed59060200160405180910390a39695505050505050565b600260205281600052604060002081815481106104ff57600080fd5b6000918252602090912001546001600160a01b03169150829050565b61052361069e565b61052d60006106cb565b565b61053761069e565b6001600160a01b03811661058d5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964206d61726b6574706c61636520616464726573730000000000604482015260640161025a565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f210690abd7fd6cdbb8f2beb202b2a253d58d7a0813b2175c4172c14c0c1af6dc90600090a250565b6001600160a01b03811660009081526002602090815260409182902080548351818402810184019094528084526060939283018282801561064157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610623575b50505050509050919050565b61065561069e565b6001600160a01b03811661067f57604051631e4fbdf760e01b81526000600482015260240161025a565b610688816106cb565b50565b600061069882600061071b565b92915050565b6000546001600160a01b0316331461052d5760405163118cdaa760e01b815233600482015260240161025a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000814710156107475760405163cf47918160e01b81524760048201526024810183905260440161025a565b763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b176020526037600983f090506001600160a01b0381166106985760405163b06ebf3d60e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b600082601f8301126107d857600080fd5b813567ffffffffffffffff808211156107f3576107f36107b1565b604051601f8301601f19908116603f0116810190828211818310171561081b5761081b6107b1565b8160405283815286602085880101111561083457600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561086a57600080fd5b843567ffffffffffffffff8082111561088257600080fd5b61088e888389016107c7565b955060208701359150808211156108a457600080fd5b506108b1878288016107c7565b935050604085013580151581146108c757600080fd5b9396929550929360600135925050565b80356001600160a01b03811681146108ee57600080fd5b919050565b60006020828403121561090557600080fd5b61090e826108d7565b9392505050565b6000806040838503121561092857600080fd5b610931836108d7565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156109805783516001600160a01b03168352928401929184019160010161095b565b50909695505050505050565b6000815180845260005b818110156109b257602081850181015186830182015201610996565b506000602082860101526020601f19601f83011685010191505092915050565b60c0815260006109e560c083018961098c565b82810360208401526109f7818961098c565b6001600160a01b039788166040850152959096166060830152506080810192909252151560a0909101529392505050565b60a081526000610a3b60a083018861098c565b8281036020840152610a4d818861098c565b6001600160a01b03968716604085015294909516606083015250901515608090910152939250505056fea26469706673582212203ea0ad8e3c9e3540987ae9afc82cbfbea89fe0ecc1cc5b2e0bc07c85abd50c9c64736f6c63430008140033000000000000000000000000d5248ed905a803c74aa753fc36a5a936945625b7000000000000000000000000c4b5185b3873d16a1c9bd76fd361abf018a0da7c000000000000000000000000550765efdb1ed4fbb23051e084332334d18cbb360000000000000000000000009aff14b01b80d4a88a8754fd065892a7cd25aa67

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100b45760003560e01c806373ad6c2d1161007157806373ad6c2d1461018c5780638da5cb5b1461019f5780639aa5ad8c146101b0578063abc8c7af146101d0578063f2fde38b146101e3578063ffb54877146101f657600080fd5b80630339e7b6146100b95780630bd11491146100e95780630f3b901f1461011c5780633908cc9314610143578063428a61711461016f578063715018a614610182575b600080fd5b6100cc6100c7366004610854565b61021d565b6040516001600160a01b0390911681526020015b60405180910390f35b61010c6100f73660046108f3565b60036020526000908152604090205460ff1681565b60405190151581526020016100e0565b6100cc7f000000000000000000000000c4b5185b3873d16a1c9bd76fd361abf018a0da7c81565b61010c6101513660046108f3565b6001600160a01b031660009081526003602052604090205460ff1690565b6100cc61017d366004610915565b6104e3565b61018a61051b565b005b61018a61019a3660046108f3565b61052f565b6000546001600160a01b03166100cc565b6101c36101be3660046108f3565b6105d7565b6040516100e0919061093f565b6001546100cc906001600160a01b031681565b61018a6101f13660046108f3565b61064d565b6100cc7f000000000000000000000000550765efdb1ed4fbb23051e084332334d18cbb3681565b6000808551116102635760405162461bcd60e51b815260206004820152600c60248201526b496e76616c6964206e616d6560a01b60448201526064015b60405180910390fd5b60008451116102aa5760405162461bcd60e51b815260206004820152601360248201527224b73b30b634b2103232b9b1b934b83a34b7b760691b604482015260640161025a565b6000836102d7577f000000000000000000000000c4b5185b3873d16a1c9bd76fd361abf018a0da7c6102f9565b7f000000000000000000000000550765efdb1ed4fbb23051e084332334d18cbb365b905060006103068261068b565b9050841561038157600154604051638a8d349360e01b81526001600160a01b0383811692638a8d34939261034a928c928c923392909116908b908d906004016109d2565b600060405180830381600087803b15801561036457600080fd5b505af1158015610378573d6000803e3d6000fd5b505050506103ee565b600154604051633edd55b160e11b81526001600160a01b0383811692637dbaab62926103bb928c928c923392909116908c90600401610a28565b600060405180830381600087803b1580156103d557600080fd5b505af11580156103e9573d6000803e3d6000fd5b505050505b3360009081526002602090815260408083208054600180820183559185528385200180546001600160a01b0319166001600160a01b03878116918217909255808652600390945293829020805460ff1916821790555490516320e202bb60e11b81526004810192909252909116906341c4057690602401600060405180830381600087803b15801561047f57600080fd5b505af1158015610493573d6000803e3d6000fd5b505060405187151581523392506001600160a01b03841691507f1e5508feeacc96584a6f6c8e88ed33491daa038f32b137029058cd046bf24ed59060200160405180910390a39695505050505050565b600260205281600052604060002081815481106104ff57600080fd5b6000918252602090912001546001600160a01b03169150829050565b61052361069e565b61052d60006106cb565b565b61053761069e565b6001600160a01b03811661058d5760405162461bcd60e51b815260206004820152601b60248201527f496e76616c6964206d61726b6574706c61636520616464726573730000000000604482015260640161025a565b600180546001600160a01b0319166001600160a01b0383169081179091556040517f210690abd7fd6cdbb8f2beb202b2a253d58d7a0813b2175c4172c14c0c1af6dc90600090a250565b6001600160a01b03811660009081526002602090815260409182902080548351818402810184019094528084526060939283018282801561064157602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311610623575b50505050509050919050565b61065561069e565b6001600160a01b03811661067f57604051631e4fbdf760e01b81526000600482015260240161025a565b610688816106cb565b50565b600061069882600061071b565b92915050565b6000546001600160a01b0316331461052d5760405163118cdaa760e01b815233600482015260240161025a565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6000814710156107475760405163cf47918160e01b81524760048201526024810183905260440161025a565b763d602d80600a3d3981f3363d3d373d3d3d363d730000008360601b60e81c176000526e5af43d82803e903d91602b57fd5bf38360781b176020526037600983f090506001600160a01b0381166106985760405163b06ebf3d60e01b815260040160405180910390fd5b634e487b7160e01b600052604160045260246000fd5b600082601f8301126107d857600080fd5b813567ffffffffffffffff808211156107f3576107f36107b1565b604051601f8301601f19908116603f0116810190828211818310171561081b5761081b6107b1565b8160405283815286602085880101111561083457600080fd5b836020870160208301376000602085830101528094505050505092915050565b6000806000806080858703121561086a57600080fd5b843567ffffffffffffffff8082111561088257600080fd5b61088e888389016107c7565b955060208701359150808211156108a457600080fd5b506108b1878288016107c7565b935050604085013580151581146108c757600080fd5b9396929550929360600135925050565b80356001600160a01b03811681146108ee57600080fd5b919050565b60006020828403121561090557600080fd5b61090e826108d7565b9392505050565b6000806040838503121561092857600080fd5b610931836108d7565b946020939093013593505050565b6020808252825182820181905260009190848201906040850190845b818110156109805783516001600160a01b03168352928401929184019160010161095b565b50909695505050505050565b6000815180845260005b818110156109b257602081850181015186830182015201610996565b506000602082860101526020601f19601f83011685010191505092915050565b60c0815260006109e560c083018961098c565b82810360208401526109f7818961098c565b6001600160a01b039788166040850152959096166060830152506080810192909252151560a0909101529392505050565b60a081526000610a3b60a083018861098c565b8281036020840152610a4d818861098c565b6001600160a01b03968716604085015294909516606083015250901515608090910152939250505056fea26469706673582212203ea0ad8e3c9e3540987ae9afc82cbfbea89fe0ecc1cc5b2e0bc07c85abd50c9c64736f6c63430008140033