ETH Price: $3,344.18 (-8.06%)

Contract

0x04FcED0518Cee030bfd0cE842834805719E8b52E
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Market

Compiler Version
v0.8.16+commit.07a7930e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 16 : Market.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "@openzeppelin/contracts-upgradeable/utils/cryptography/EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/IERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC1155/IERC1155Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol";
import "contracts/lib/Struct.sol";
import "contracts/lib/Enum.sol";

contract Market is
    OwnableUpgradeable,
    EIP712Upgradeable,
    OrderParameterBase,
    ReentrancyGuardUpgradeable
{
    struct OrderStatus {
        bool isValidated;
        bool isCancelled;
    }

    // 100 / 10000
    struct CollectionFee {
        uint64 marketFee;
        uint64 projectFee;
        uint64 ipFee;
    }

    address public marketVault;
    address public projectVault;
    address public ipVault;
    // collection address => fees
    mapping(address => CollectionFee) public fees;

    mapping(address => bool) public whitelist; // Users in the whitelist can enjoy free transaction fee

    // offerer => counter
    mapping(address => uint256) public counters;
    // order hash => status
    mapping(bytes32 => OrderStatus) public orderStatus;

    // collection permission
    mapping(address => bool) public collections;

    event OrderCancelled(address indexed canceller, uint256 indexed salt);
    event Sold(
        bytes32 indexed orderHash,
        uint256 indexed salt,
        uint256 indexed time,
        address from,
        address to
    );
    event SetVaults(address marketVault, address projectVault, address ipVault);
    event SetWhiteList(address[] users, bool[] permissions);
    event SetCollection(address collection, bool permission);
    event SetCollectionFee(
        address collection,
        uint64 marketFee,
        uint64 projectFee,
        uint64 ipFee
    );
    event CounterIncremented(uint256 indexed counter, address indexed user);

    error OrderTypeError(ItemType offerType, ItemType considerationType);
    error InvalidCanceller();

    function initialize(
        string memory name,
        string memory version
    ) public initializer {
        __Ownable_init();
        __EIP712_init(name, version);
    }

    function _verify(
        bytes32 orderHash,
        bytes calldata signature
    ) internal view returns (address) {
        bytes32 digest = _hashTypedDataV4(orderHash);
        address signer = ECDSAUpgradeable.recover(digest, signature);
        return (signer);
    }

    function fulfillOrder(
        OrderParameters calldata order
    ) external payable nonReentrant {
        address from;
        address to;
        // calculate order hash
        bytes32 orderHash = _deriveOrderHash(order, counters[order.offerer]);

        require(
            block.timestamp >= order.startTime &&
                block.timestamp <= order.endTime,
            "Time error"
        );

        OrderStatus storage _orderStatus = orderStatus[orderHash];
        require(
            !_orderStatus.isCancelled && !_orderStatus.isValidated,
            "Status error"
        );

        // verify signature
        require(
            _verify(orderHash, order.signature) == order.offerer,
            "Sign error"
        );

        require(
            order.consideration.length == 1 && order.offer.length == 1,
            "Param length error"
        );

        // transfer fee
        uint256 _marketFee;
        uint256 _projectFee;
        uint256 _ipFee;
        uint256 _totalFee;
        ConsiderationItem memory consideration = order.consideration[0];
        OfferItem memory offerItem = order.offer[0];
        if (offerItem.itemType == ItemType.NATIVE) {
            // ETH can't approve, offer's type cann't be NATIVE
            revert OrderTypeError(offerItem.itemType, consideration.itemType);
        }
        if (!whitelist[msg.sender]) {
            // consideration
            if (
                consideration.itemType == ItemType.NATIVE ||
                consideration.itemType == ItemType.ERC20
            ) {
                _marketFee =
                    (consideration.startAmount *
                        fees[offerItem.token].marketFee) /
                    10000;
                _projectFee =
                    (consideration.startAmount *
                        fees[offerItem.token].projectFee) /
                    10000;
                _ipFee =
                    (consideration.startAmount * fees[offerItem.token].ipFee) /
                    10000;
                _totalFee = _marketFee + _projectFee + _ipFee;

                if (consideration.itemType == ItemType.NATIVE) {
                    payable(marketVault).transfer(_marketFee);
                    payable(projectVault).transfer(_projectFee);
                    payable(ipVault).transfer(_ipFee);
                } else {
                    require(
                        IERC20Upgradeable(consideration.token).transferFrom(
                            msg.sender,
                            marketVault,
                            _marketFee
                        ),
                        "ERC20 market fee error"
                    );
                    require(
                        IERC20Upgradeable(consideration.token).transferFrom(
                            msg.sender,
                            projectVault,
                            _projectFee
                        ),
                        "ERC20 project fee error"
                    );
                    require(
                        IERC20Upgradeable(consideration.token).transferFrom(
                            msg.sender,
                            ipVault,
                            _ipFee
                        ),
                        "ERC20 ip fee error"
                    );
                }
            } else if (
                // offer
                offerItem.itemType == ItemType.ERC20
            ) {
                _marketFee =
                    (offerItem.startAmount *
                        fees[consideration.token].marketFee) /
                    10000;
                _projectFee =
                    (offerItem.startAmount *
                        fees[consideration.token].projectFee) /
                    10000;
                _ipFee =
                    (offerItem.startAmount * fees[consideration.token].ipFee) /
                    10000;
                _totalFee = _marketFee + _projectFee + _ipFee;

                require(
                    IERC20Upgradeable(offerItem.token).transferFrom(
                        order.offerer,
                        marketVault,
                        _marketFee
                    ),
                    "ERC20 market fee error"
                );
                require(
                    IERC20Upgradeable(offerItem.token).transferFrom(
                        order.offerer,
                        projectVault,
                        _projectFee
                    ),
                    "ERC20 project fee error"
                );
                require(
                    IERC20Upgradeable(offerItem.token).transferFrom(
                        order.offerer,
                        ipVault,
                        _ipFee
                    ),
                    "ERC20 ip fee error"
                );
            }
        }

        // Consideration
        if (
            consideration.itemType == ItemType.NATIVE ||
            consideration.itemType == ItemType.ERC20
        ) {
            // check offer type, NATIVE/ERC20 <-> ERC721/ERC1155
            if (
                offerItem.itemType != ItemType.ERC721 &&
                offerItem.itemType != ItemType.ERC1155
            ) {
                revert OrderTypeError(
                    offerItem.itemType,
                    consideration.itemType
                );
            }

            if (consideration.itemType == ItemType.NATIVE) {
                require(
                    msg.value >= consideration.startAmount,
                    "TX value error"
                );
                payable(consideration.recipient).transfer(
                    consideration.startAmount - _totalFee
                );
            } else if (consideration.itemType == ItemType.ERC20) {
                require(
                    IERC20Upgradeable(consideration.token).transferFrom(
                        msg.sender,
                        consideration.recipient,
                        consideration.startAmount - _totalFee
                    ),
                    "Transfer erc20 consideration error"
                );
            }
        } else if (
            consideration.itemType == ItemType.ERC721 ||
            consideration.itemType == ItemType.ERC1155
        ) {
            require(
                collections[consideration.token],
                "ERROR: This collection has no permission"
            );
            if (consideration.itemType == ItemType.ERC721) {
                IERC721Upgradeable(consideration.token).safeTransferFrom(
                    msg.sender,
                    consideration.recipient,
                    consideration.identifierOrCriteria
                );
            } else if (consideration.itemType == ItemType.ERC1155) {
                IERC1155Upgradeable(consideration.token).safeTransferFrom(
                    msg.sender,
                    consideration.recipient,
                    consideration.identifierOrCriteria,
                    consideration.startAmount,
                    "0x0"
                );
            }

            from = msg.sender;
            to = consideration.recipient;
        } else {
            // other consideration type is not support
            revert OrderTypeError(offerItem.itemType, consideration.itemType);
        }

        // Offer
        if (offerItem.itemType == ItemType.NATIVE) {
            // offer's type cann't be NATIVE
            revert OrderTypeError(offerItem.itemType, consideration.itemType);
        } else if (offerItem.itemType == ItemType.ERC20) {
            // check consideration type
            if (
                consideration.itemType != ItemType.ERC721 &&
                consideration.itemType != ItemType.ERC1155
            ) {
                revert OrderTypeError(
                    offerItem.itemType,
                    consideration.itemType
                );
            }
            require(
                IERC20Upgradeable(offerItem.token).transferFrom(
                    order.offerer,
                    msg.sender,
                    offerItem.startAmount - _totalFee
                ),
                "Transfer erc20 offer error"
            );
        } else if (
            offerItem.itemType == ItemType.ERC721 ||
            offerItem.itemType == ItemType.ERC1155
        ) {
            require(
                collections[offerItem.token],
                "ERROR: This collection has no permission"
            );

            if (offerItem.itemType == ItemType.ERC721) {
                IERC721Upgradeable(offerItem.token).safeTransferFrom(
                    order.offerer,
                    msg.sender,
                    offerItem.identifierOrCriteria
                );
            } else if (offerItem.itemType == ItemType.ERC1155) {
                IERC1155Upgradeable(offerItem.token).safeTransferFrom(
                    order.offerer,
                    msg.sender,
                    offerItem.identifierOrCriteria,
                    offerItem.startAmount,
                    "0x0"
                );
            }

            from = order.offerer;
            to = msg.sender;
        } else {
            // other offer type is not support
            revert OrderTypeError(offerItem.itemType, consideration.itemType);
        }

        _orderStatus.isValidated = true;

        emit Sold(orderHash, order.salt, block.timestamp, from, to);
    }

    function cancel(OrderComponents[] calldata orders) external nonReentrant {
        OrderStatus storage _orderStatus;
        address offerer;

        for (uint256 i = 0; i < orders.length; ) {
            // Retrieve the order.
            OrderComponents calldata order = orders[i];

            offerer = order.offerer;

            // Ensure caller is either offerer or zone of the order.
            if (msg.sender != offerer) {
                revert InvalidCanceller();
            }

            // Derive order hash using the order parameters and the counter.
            bytes32 orderHash = _deriveOrderHash(
                OrderParameters(
                    offerer,
                    order.offer,
                    order.consideration,
                    order.startTime,
                    order.endTime,
                    order.salt,
                    order.signature
                ),
                order.counter
            );

            // Retrieve the order status using the derived order hash.
            _orderStatus = orderStatus[orderHash];

            // Update the order status as not valid and cancelled.
            _orderStatus.isValidated = false;
            _orderStatus.isCancelled = true;

            // Emit an event signifying that the order has been cancelled.
            emit OrderCancelled(offerer, order.salt);

            // Increment counter inside body of loop for gas efficiency.
            ++i;
        }
    }

    function setCollection(
        address collection,
        bool permission
    ) public onlyOwner {
        require(
            marketVault != address(0) &&
                projectVault != address(0) &&
                ipVault != address(0),
            "ERROR: vault is empty"
        );
        collections[collection] = permission;
        emit SetCollection(collection, permission);
    }

    function setWhiteList(
        address[] calldata users,
        bool[] calldata permissions
    ) public onlyOwner {
        for (uint256 i; i < users.length; i++) {
            whitelist[users[i]] = permissions[i];
        }
        emit SetWhiteList(users, permissions);
    }

    function setFees(
        address collectionAddress,
        CollectionFee calldata fees_
    ) public onlyOwner {
        require(
            marketVault != address(0) &&
                projectVault != address(0) &&
                ipVault != address(0),
            "ERROR: vault is empty"
        );
        require(
            fees_.marketFee + fees_.projectFee + fees_.ipFee < 10000,
            "exceed max fee"
        );
        fees[collectionAddress] = fees_;
        emit SetCollectionFee(
            collectionAddress,
            fees_.marketFee,
            fees_.projectFee,
            fees_.ipFee
        );
        if (!collections[collectionAddress]) {
            collections[collectionAddress] = true;
        }
    }

    function setVaults(
        address marketVault_,
        address projectVault_,
        address ipVault_
    ) public onlyOwner {
        marketVault = marketVault_;
        projectVault = projectVault_;
        ipVault = ipVault_;
        emit SetVaults(marketVault_, projectVault_, ipVault_);
    }
}

File 2 of 16 : OwnableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/ContextUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract OwnableUpgradeable is Initializable, ContextUpgradeable {
    address private _owner;

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

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

    function __Ownable_init_unchained() internal onlyInitializing {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

    /**
     * @dev Returns the address of the current owner.
     */
    function owner() public view virtual returns (address) {
        return _owner;
    }

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

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

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 3 of 16 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.1) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

import "../../utils/AddressUpgradeable.sol";

/**
 * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
 * behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
 * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
 * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
 *
 * The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
 * reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
 * case an upgrade adds a module that needs to be initialized.
 *
 * For example:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * contract MyToken is ERC20Upgradeable {
 *     function initialize() initializer public {
 *         __ERC20_init("MyToken", "MTK");
 *     }
 * }
 * contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
 *     function initializeV2() reinitializer(2) public {
 *         __ERC20Permit_init("MyToken");
 *     }
 * }
 * ```
 *
 * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
 * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
 *
 * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
 * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
 *
 * [CAUTION]
 * ====
 * Avoid leaving a contract uninitialized.
 *
 * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
 * contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
 * the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
 *
 * [.hljs-theme-light.nopadding]
 * ```
 * /// @custom:oz-upgrades-unsafe-allow constructor
 * constructor() {
 *     _disableInitializers();
 * }
 * ```
 * ====
 */
abstract contract Initializable {
    /**
     * @dev Indicates that the contract has been initialized.
     * @custom:oz-retyped-from bool
     */
    uint8 private _initialized;

    /**
     * @dev Indicates that the contract is in the process of being initialized.
     */
    bool private _initializing;

    /**
     * @dev Triggered when the contract has been initialized or reinitialized.
     */
    event Initialized(uint8 version);

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts.
     *
     * Similar to `reinitializer(1)`, except that functions marked with `initializer` can be nested in the context of a
     * constructor.
     *
     * Emits an {Initialized} event.
     */
    modifier initializer() {
        bool isTopLevelCall = !_initializing;
        require(
            (isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
            "Initializable: contract is already initialized"
        );
        _initialized = 1;
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * A reinitializer may be used after the original initialization step. This is essential to configure modules that
     * are added through upgrades and that require initialization.
     *
     * When `version` is 1, this modifier is similar to `initializer`, except that functions marked with `reinitializer`
     * cannot be nested. If one is invoked in the context of another, execution will revert.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     *
     * WARNING: setting the version to 255 will prevent any future reinitialization.
     *
     * Emits an {Initialized} event.
     */
    modifier reinitializer(uint8 version) {
        require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
        _initialized = version;
        _initializing = true;
        _;
        _initializing = false;
        emit Initialized(version);
    }

    /**
     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
     * {initializer} and {reinitializer} modifiers, directly or indirectly.
     */
    modifier onlyInitializing() {
        require(_initializing, "Initializable: contract is not initializing");
        _;
    }

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     *
     * Emits an {Initialized} event the first time it is successfully executed.
     */
    function _disableInitializers() internal virtual {
        require(!_initializing, "Initializable: contract is initializing");
        if (_initialized < type(uint8).max) {
            _initialized = type(uint8).max;
            emit Initialized(type(uint8).max);
        }
    }

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

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

File 4 of 16 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @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 ReentrancyGuardUpgradeable is Initializable {
    // 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;

    function __ReentrancyGuard_init() internal onlyInitializing {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal onlyInitializing {
        _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 This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[49] private __gap;
}

File 5 of 16 : IERC1155Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC1155/IERC1155.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC1155 compliant contract, as defined in the
 * https://eips.ethereum.org/EIPS/eip-1155[EIP].
 *
 * _Available since v3.1._
 */
interface IERC1155Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `value` tokens of token type `id` are transferred from `from` to `to` by `operator`.
     */
    event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);

    /**
     * @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
     * transfers.
     */
    event TransferBatch(
        address indexed operator,
        address indexed from,
        address indexed to,
        uint256[] ids,
        uint256[] values
    );

    /**
     * @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
     * `approved`.
     */
    event ApprovalForAll(address indexed account, address indexed operator, bool approved);

    /**
     * @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
     *
     * If an {URI} event was emitted for `id`, the standard
     * https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
     * returned by {IERC1155MetadataURI-uri}.
     */
    event URI(string value, uint256 indexed id);

    /**
     * @dev Returns the amount of tokens of token type `id` owned by `account`.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function balanceOf(address account, uint256 id) external view returns (uint256);

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
     *
     * Requirements:
     *
     * - `accounts` and `ids` must have the same length.
     */
    function balanceOfBatch(address[] calldata accounts, uint256[] calldata ids)
        external
        view
        returns (uint256[] memory);

    /**
     * @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
     *
     * Emits an {ApprovalForAll} event.
     *
     * Requirements:
     *
     * - `operator` cannot be the caller.
     */
    function setApprovalForAll(address operator, bool approved) external;

    /**
     * @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
     *
     * See {setApprovalForAll}.
     */
    function isApprovedForAll(address account, address operator) external view returns (bool);

    /**
     * @dev Transfers `amount` tokens of token type `id` from `from` to `to`.
     *
     * Emits a {TransferSingle} event.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
     * - `from` must have a balance of tokens of type `id` of at least `amount`.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
     * acceptance magic value.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        uint256 amount,
        bytes calldata data
    ) external;

    /**
     * @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
     *
     * Emits a {TransferBatch} event.
     *
     * Requirements:
     *
     * - `ids` and `amounts` must have the same length.
     * - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
     * acceptance magic value.
     */
    function safeBatchTransferFrom(
        address from,
        address to,
        uint256[] calldata ids,
        uint256[] calldata amounts,
        bytes calldata data
    ) external;
}

File 6 of 16 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

    /**
     * @dev Emitted when the allowance of a `spender` for an `owner` is set by
     * a call to {approve}. `value` is the new allowance.
     */
    event Approval(address indexed owner, address indexed spender, uint256 value);

    /**
     * @dev Returns the amount of tokens in existence.
     */
    function totalSupply() external view returns (uint256);

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

    /**
     * @dev Moves `amount` tokens from the caller's account to `to`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address to, uint256 amount) external returns (bool);

    /**
     * @dev Returns the remaining number of tokens that `spender` will be
     * allowed to spend on behalf of `owner` through {transferFrom}. This is
     * zero by default.
     *
     * This value changes when {approve} or {transferFrom} are called.
     */
    function allowance(address owner, address spender) external view returns (uint256);

    /**
     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * IMPORTANT: Beware that changing an allowance with this method brings the risk
     * that someone may use both the old and the new allowance by unfortunate
     * transaction ordering. One possible solution to mitigate this race
     * condition is to first reduce the spender's allowance to 0 and set the
     * desired value afterwards:
     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
     *
     * Emits an {Approval} event.
     */
    function approve(address spender, uint256 amount) external returns (bool);

    /**
     * @dev Moves `amount` tokens from `from` to `to` using the
     * allowance mechanism. `amount` is then deducted from the caller's
     * allowance.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) external returns (bool);
}

File 7 of 16 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165Upgradeable.sol";

/**
 * @dev Required interface of an ERC721 compliant contract.
 */
interface IERC721Upgradeable is IERC165Upgradeable {
    /**
     * @dev Emitted when `tokenId` token is transferred from `from` to `to`.
     */
    event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
     */
    event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);

    /**
     * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
     */
    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /**
     * @dev Returns the number of tokens in ``owner``'s account.
     */
    function balanceOf(address owner) external view returns (uint256 balance);

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) external view returns (address owner);

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId,
        bytes calldata data
    ) external;

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If the caller is not `from`, it must have been allowed to move this token by either {approve} or {setApprovalForAll}.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC721
     * or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
     * understand this adds an external call which potentially creates a reentrancy vulnerability.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account.
     * The approval is cleared when the token is transferred.
     *
     * Only a single account can be approved at a time, so approving the zero address clears previous approvals.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function approve(address to, uint256 tokenId) external;

    /**
     * @dev Approve or remove `operator` as an operator for the caller.
     * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
     *
     * Requirements:
     *
     * - The `operator` cannot be the caller.
     *
     * Emits an {ApprovalForAll} event.
     */
    function setApprovalForAll(address operator, bool _approved) external;

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

    /**
     * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
     *
     * See {setApprovalForAll}
     */
    function isApprovedForAll(address owner, address operator) external view returns (bool);
}

File 8 of 16 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Address.sol)

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library AddressUpgradeable {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        (bool success, ) = recipient.call{value: amount}("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, "Address: low-level call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
     * `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, 0, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but also transferring `value` wei to `target`.
     *
     * Requirements:
     *
     * - the calling contract must have an ETH balance of at least `value`.
     * - the called Solidity function must be `payable`.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value
    ) internal returns (bytes memory) {
        return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
    }

    /**
     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
     * with `errorMessage` as a fallback revert reason when `target` reverts.
     *
     * _Available since v3.1._
     */
    function functionCallWithValue(
        address target,
        bytes memory data,
        uint256 value,
        string memory errorMessage
    ) internal returns (bytes memory) {
        require(address(this).balance >= value, "Address: insufficient balance for call");
        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
        return functionStaticCall(target, data, "Address: low-level static call failed");
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResultFromTarget(target, success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling
     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.
     *
     * _Available since v4.8._
     */
    function verifyCallResultFromTarget(
        address target,
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        if (success) {
            if (returndata.length == 0) {
                // only check isContract if the call was successful and the return data is empty
                // otherwise we already know that it was a contract
                require(isContract(target), "Address: call to non-contract");
            }
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    /**
     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason or using the provided one.
     *
     * _Available since v4.3._
     */
    function verifyCallResult(
        bool success,
        bytes memory returndata,
        string memory errorMessage
    ) internal pure returns (bytes memory) {
        if (success) {
            return returndata;
        } else {
            _revert(returndata, errorMessage);
        }
    }

    function _revert(bytes memory returndata, string memory errorMessage) private pure {
        // Look for revert reason and bubble it up if present
        if (returndata.length > 0) {
            // The easiest way to bubble the revert reason is using memory via assembly
            /// @solidity memory-safe-assembly
            assembly {
                let returndata_size := mload(returndata)
                revert(add(32, returndata), returndata_size)
            }
        } else {
            revert(errorMessage);
        }
    }
}

File 9 of 16 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract ContextUpgradeable is Initializable {
    function __Context_init() internal onlyInitializing {
    }

    function __Context_init_unchained() internal onlyInitializing {
    }
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 10 of 16 : ECDSAUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../StringsUpgradeable.sol";

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSAUpgradeable {
    enum RecoverError {
        NoError,
        InvalidSignature,
        InvalidSignatureLength,
        InvalidSignatureS,
        InvalidSignatureV // Deprecated in v4.8
    }

    function _throwError(RecoverError error) private pure {
        if (error == RecoverError.NoError) {
            return; // no error: do nothing
        } else if (error == RecoverError.InvalidSignature) {
            revert("ECDSA: invalid signature");
        } else if (error == RecoverError.InvalidSignatureLength) {
            revert("ECDSA: invalid signature length");
        } else if (error == RecoverError.InvalidSignatureS) {
            revert("ECDSA: invalid signature 's' value");
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature` or error string. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     *
     * Documentation for signature generation:
     * - with https://web3js.readthedocs.io/en/v1.3.4/web3-eth-accounts.html#sign[Web3.js]
     * - with https://docs.ethers.io/v5/api/signer/#Signer-signMessage[ethers]
     *
     * _Available since v4.3._
     */
    function tryRecover(bytes32 hash, bytes memory signature) internal pure returns (address, RecoverError) {
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            /// @solidity memory-safe-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
            return tryRecover(hash, v, r, s);
        } else {
            return (address(0), RecoverError.InvalidSignatureLength);
        }
    }

    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, signature);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `r` and `vs` short-signature fields separately.
     *
     * See https://eips.ethereum.org/EIPS/eip-2098[EIP-2098 short signatures]
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address, RecoverError) {
        bytes32 s = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `r and `vs` short-signature fields separately.
     *
     * _Available since v4.2._
     */
    function recover(
        bytes32 hash,
        bytes32 r,
        bytes32 vs
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, r, vs);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Overload of {ECDSA-tryRecover} that receives the `v`,
     * `r` and `s` signature fields separately.
     *
     * _Available since v4.3._
     */
    function tryRecover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address, RecoverError) {
        // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
        // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
        // the valid range for s in (301): 0 < s < secp256k1n ÷ 2 + 1, and for v in (302): v ∈ {27, 28}. Most
        // signatures from current libraries generate a unique signature with an s-value in the lower half order.
        //
        // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
        // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
        // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
        // these malleable signatures as well.
        if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
            return (address(0), RecoverError.InvalidSignatureS);
        }

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        if (signer == address(0)) {
            return (address(0), RecoverError.InvalidSignature);
        }

        return (signer, RecoverError.NoError);
    }

    /**
     * @dev Overload of {ECDSA-recover} that receives the `v`,
     * `r` and `s` signature fields separately.
     */
    function recover(
        bytes32 hash,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        (address recovered, RecoverError error) = tryRecover(hash, v, r, s);
        _throwError(error);
        return recovered;
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from a `hash`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
        // 32 is the length in bytes of hash,
        // enforced by the type signature above
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
    }

    /**
     * @dev Returns an Ethereum Signed Message, created from `s`. This
     * produces hash corresponding to the one signed with the
     * https://eth.wiki/json-rpc/API#eth_sign[`eth_sign`]
     * JSON-RPC method as part of EIP-191.
     *
     * See {recover}.
     */
    function toEthSignedMessageHash(bytes memory s) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n", StringsUpgradeable.toString(s.length), s));
    }

    /**
     * @dev Returns an Ethereum Signed Typed Data, created from a
     * `domainSeparator` and a `structHash`. This produces hash corresponding
     * to the one signed with the
     * https://eips.ethereum.org/EIPS/eip-712[`eth_signTypedData`]
     * JSON-RPC method as part of EIP-712.
     *
     * See {recover}.
     */
    function toTypedDataHash(bytes32 domainSeparator, bytes32 structHash) internal pure returns (bytes32) {
        return keccak256(abi.encodePacked("\x19\x01", domainSeparator, structHash));
    }
}

File 11 of 16 : EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/cryptography/EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSAUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev https://eips.ethereum.org/EIPS/eip-712[EIP 712] is a standard for hashing and signing of typed structured data.
 *
 * The encoding specified in the EIP is very generic, and such a generic implementation in Solidity is not feasible,
 * thus this contract does not implement the encoding itself. Protocols need to implement the type-specific encoding
 * they need in their contracts using a combination of `abi.encode` and `keccak256`.
 *
 * This contract implements the EIP 712 domain separator ({_domainSeparatorV4}) that is used as part of the encoding
 * scheme, and the final step of the encoding to obtain the message digest that is then signed via ECDSA
 * ({_hashTypedDataV4}).
 *
 * The implementation of the domain separator was designed to be as efficient as possible while still properly updating
 * the chain id to protect against replay attacks on an eventual fork of the chain.
 *
 * NOTE: This contract implements the version of the encoding known as "v4", as implemented by the JSON RPC method
 * https://docs.metamask.io/guide/signing-data.html[`eth_signTypedDataV4` in MetaMask].
 *
 * _Available since v3.4._
 *
 * @custom:storage-size 52
 */
abstract contract EIP712Upgradeable is Initializable {
    /* solhint-disable var-name-mixedcase */
    bytes32 private _HASHED_NAME;
    bytes32 private _HASHED_VERSION;
    bytes32 private constant _TYPE_HASH = keccak256("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)");

    /* solhint-enable var-name-mixedcase */

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    function __EIP712_init(string memory name, string memory version) internal onlyInitializing {
        __EIP712_init_unchained(name, version);
    }

    function __EIP712_init_unchained(string memory name, string memory version) internal onlyInitializing {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        return _buildDomainSeparator(_TYPE_HASH, _EIP712NameHash(), _EIP712VersionHash());
    }

    function _buildDomainSeparator(
        bytes32 typeHash,
        bytes32 nameHash,
        bytes32 versionHash
    ) private view returns (bytes32) {
        return keccak256(abi.encode(typeHash, nameHash, versionHash, block.chainid, address(this)));
    }

    /**
     * @dev Given an already https://eips.ethereum.org/EIPS/eip-712#definition-of-hashstruct[hashed struct], this
     * function returns the hash of the fully encoded EIP712 message for this domain.
     *
     * This hash can be used together with {ECDSA-recover} to obtain the signer of a message. For example:
     *
     * ```solidity
     * bytes32 digest = _hashTypedDataV4(keccak256(abi.encode(
     *     keccak256("Mail(address to,string contents)"),
     *     mailTo,
     *     keccak256(bytes(mailContents))
     * )));
     * address signer = ECDSA.recover(digest, signature);
     * ```
     */
    function _hashTypedDataV4(bytes32 structHash) internal view virtual returns (bytes32) {
        return ECDSAUpgradeable.toTypedDataHash(_domainSeparatorV4(), structHash);
    }

    /**
     * @dev The hash of the name parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712NameHash() internal virtual view returns (bytes32) {
        return _HASHED_NAME;
    }

    /**
     * @dev The hash of the version parameter for the EIP712 domain.
     *
     * NOTE: This function reads from storage by default, but can be redefined to return a constant value if gas costs
     * are a concern.
     */
    function _EIP712VersionHash() internal virtual view returns (bytes32) {
        return _HASHED_VERSION;
    }

    /**
     * @dev This empty reserved space is put in place to allow future versions to add new
     * variables without shifting down storage in the inheritance chain.
     * See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
     */
    uint256[50] private __gap;
}

File 12 of 16 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC165 standard, as defined in the
 * https://eips.ethereum.org/EIPS/eip-165[EIP].
 *
 * Implementers can declare support of contract interfaces, which can then be
 * queried by others ({ERC165Checker}).
 *
 * For an implementation, see {ERC165}.
 */
interface IERC165Upgradeable {
    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30 000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);
}

File 13 of 16 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    enum Rounding {
        Down, // Toward negative infinity
        Up, // Toward infinity
        Zero // Toward zero
    }

    /**
     * @dev Returns the largest of two numbers.
     */
    function max(uint256 a, uint256 b) internal pure returns (uint256) {
        return a > b ? a : b;
    }

    /**
     * @dev Returns the smallest of two numbers.
     */
    function min(uint256 a, uint256 b) internal pure returns (uint256) {
        return a < b ? a : b;
    }

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        return (a & b) + (a ^ b) / 2;
    }

    /**
     * @dev Returns the ceiling of the division of two numbers.
     *
     * This differs from standard division with `/` in that it rounds up instead
     * of rounding down.
     */
    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b - 1) / b can overflow on addition, so we distribute.
        return a == 0 ? 0 : (a - 1) / b + 1;
    }

    /**
     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0
     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)
     * with further edits by Uniswap Labs also under MIT license.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator
    ) internal pure returns (uint256 result) {
        unchecked {
            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use
            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256
            // variables such that product = prod1 * 2^256 + prod0.
            uint256 prod0; // Least significant 256 bits of the product
            uint256 prod1; // Most significant 256 bits of the product
            assembly {
                let mm := mulmod(x, y, not(0))
                prod0 := mul(x, y)
                prod1 := sub(sub(mm, prod0), lt(mm, prod0))
            }

            // Handle non-overflow cases, 256 by 256 division.
            if (prod1 == 0) {
                return prod0 / denominator;
            }

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1);

            ///////////////////////////////////////////////
            // 512 by 256 division.
            ///////////////////////////////////////////////

            // Make division exact by subtracting the remainder from [prod1 prod0].
            uint256 remainder;
            assembly {
                // Compute remainder using mulmod.
                remainder := mulmod(x, y, denominator)

                // Subtract 256 bit number from 512 bit number.
                prod1 := sub(prod1, gt(remainder, prod0))
                prod0 := sub(prod0, remainder)
            }

            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.
            // See https://cs.stackexchange.com/q/138556/92363.

            // Does not overflow because the denominator cannot be zero at this stage in the function.
            uint256 twos = denominator & (~denominator + 1);
            assembly {
                // Divide denominator by twos.
                denominator := div(denominator, twos)

                // Divide [prod1 prod0] by twos.
                prod0 := div(prod0, twos)

                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.
                twos := add(div(sub(0, twos), twos), 1)
            }

            // Shift in bits from prod1 into prod0.
            prod0 |= prod1 * twos;

            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such
            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for
            // four bits. That is, denominator * inv = 1 mod 2^4.
            uint256 inverse = (3 * denominator) ^ 2;

            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works
            // in modular arithmetic, doubling the correct bits in each step.
            inverse *= 2 - denominator * inverse; // inverse mod 2^8
            inverse *= 2 - denominator * inverse; // inverse mod 2^16
            inverse *= 2 - denominator * inverse; // inverse mod 2^32
            inverse *= 2 - denominator * inverse; // inverse mod 2^64
            inverse *= 2 - denominator * inverse; // inverse mod 2^128
            inverse *= 2 - denominator * inverse; // inverse mod 2^256

            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.
            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is
            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1
            // is no longer required.
            result = prod0 * inverse;
            return result;
        }
    }

    /**
     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.
     */
    function mulDiv(
        uint256 x,
        uint256 y,
        uint256 denominator,
        Rounding rounding
    ) internal pure returns (uint256) {
        uint256 result = mulDiv(x, y, denominator);
        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {
            result += 1;
        }
        return result;
    }

    /**
     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.
     *
     * Inspired by Henry S. Warren, Jr.'s "Hacker's Delight" (Chapter 11).
     */
    function sqrt(uint256 a) internal pure returns (uint256) {
        if (a == 0) {
            return 0;
        }

        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.
        //
        // We know that the "msb" (most significant bit) of our target number `a` is a power of 2 such that we have
        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.
        //
        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`
        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`
        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`
        //
        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.
        uint256 result = 1 << (log2(a) >> 1);

        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,
        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at
        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision
        // into the expected uint128 result.
        unchecked {
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            result = (result + a / result) >> 1;
            return min(result, a / result);
        }
    }

    /**
     * @notice Calculates sqrt(a), following the selected rounding direction.
     */
    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = sqrt(a);
            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 2, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 128;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 64;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 32;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 16;
            }
            if (value >> 8 > 0) {
                value >>= 8;
                result += 8;
            }
            if (value >> 4 > 0) {
                value >>= 4;
                result += 4;
            }
            if (value >> 2 > 0) {
                value >>= 2;
                result += 2;
            }
            if (value >> 1 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log2(value);
            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 10, rounded down, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >= 10**64) {
                value /= 10**64;
                result += 64;
            }
            if (value >= 10**32) {
                value /= 10**32;
                result += 32;
            }
            if (value >= 10**16) {
                value /= 10**16;
                result += 16;
            }
            if (value >= 10**8) {
                value /= 10**8;
                result += 8;
            }
            if (value >= 10**4) {
                value /= 10**4;
                result += 4;
            }
            if (value >= 10**2) {
                value /= 10**2;
                result += 2;
            }
            if (value >= 10**1) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log10(value);
            return result + (rounding == Rounding.Up && 10**result < value ? 1 : 0);
        }
    }

    /**
     * @dev Return the log in base 256, rounded down, of a positive value.
     * Returns 0 if given 0.
     *
     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.
     */
    function log256(uint256 value) internal pure returns (uint256) {
        uint256 result = 0;
        unchecked {
            if (value >> 128 > 0) {
                value >>= 128;
                result += 16;
            }
            if (value >> 64 > 0) {
                value >>= 64;
                result += 8;
            }
            if (value >> 32 > 0) {
                value >>= 32;
                result += 4;
            }
            if (value >> 16 > 0) {
                value >>= 16;
                result += 2;
            }
            if (value >> 8 > 0) {
                result += 1;
            }
        }
        return result;
    }

    /**
     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.
     * Returns 0 if given 0.
     */
    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {
        unchecked {
            uint256 result = log256(value);
            return result + (rounding == Rounding.Up && 1 << (result * 8) < value ? 1 : 0);
        }
    }
}

File 14 of 16 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant _SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        unchecked {
            uint256 length = MathUpgradeable.log10(value) + 1;
            string memory buffer = new string(length);
            uint256 ptr;
            /// @solidity memory-safe-assembly
            assembly {
                ptr := add(buffer, add(32, length))
            }
            while (true) {
                ptr--;
                /// @solidity memory-safe-assembly
                assembly {
                    mstore8(ptr, byte(mod(value, 10), _SYMBOLS))
                }
                value /= 10;
                if (value == 0) break;
            }
            return buffer;
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        unchecked {
            return toHexString(value, MathUpgradeable.log256(value) + 1);
        }
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

File 15 of 16 : Enum.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

enum ItemType {
    // 0: ETH on mainnet, MATIC on polygon, etc.
    NATIVE,
    // 1: ERC20 items (ERC777 and ERC20 analogues could also technically work)
    ERC20,
    // 2: ERC721 items
    ERC721,
    // 3: ERC1155 items
    ERC1155
}

File 16 of 16 : Struct.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.9;

import "contracts/lib/Enum.sol";

struct OfferItem {
    ItemType itemType;
    address token;
    uint256 identifierOrCriteria;
    uint256 startAmount;
    uint256 endAmount;
}

struct ConsiderationItem {
    ItemType itemType;
    address token;
    uint256 identifierOrCriteria;
    uint256 startAmount;
    uint256 endAmount;
    address payable recipient;
}

struct OrderParameters {
    address offerer;
    OfferItem[] offer;
    ConsiderationItem[] consideration;
    uint256 startTime;
    uint256 endTime;
    uint256 salt;
    bytes signature;
}

struct OrderComponents {
    address offerer;
    OfferItem[] offer;
    ConsiderationItem[] consideration;
    uint256 startTime;
    uint256 endTime;
    uint256 salt;
    bytes signature;
    uint256 counter;
}

contract OrderParameterBase {
    bytes internal constant _OFFER_ITEM = abi.encodePacked(
        "OfferItem(",
            "uint8 itemType,",
            "address token,",
            "uint256 identifierOrCriteria,",
            "uint256 startAmount,",
            "uint256 endAmount",
        ")"
    );
    bytes32 internal constant _OFFER_ITEM_TYPEHASH = 
        keccak256(
            _OFFER_ITEM
        );

    bytes internal constant _CONSIDERATION_ITEM = abi.encodePacked(
        "ConsiderationItem(",
            "uint8 itemType,",
            "address token,",
            "uint256 identifierOrCriteria,",
            "uint256 startAmount,",
            "uint256 endAmount,",
            "address recipient",
        ")"
    );
    bytes32 internal constant _CONSIDERATION_ITEM_TYPEHASH = 
        keccak256(
            _CONSIDERATION_ITEM
        );

    bytes32 internal constant _ORDER_TYPEHASH = 
        keccak256(
            abi.encodePacked(
                "OrderComponents(",
                    "address offerer,",
                    "OfferItem[] offer,",
                    "ConsiderationItem[] consideration,",
                    "uint256 startTime,",
                    "uint256 endTime,",
                    "uint256 salt,",
                    "uint256 counter",
                ")",
                _CONSIDERATION_ITEM,
                _OFFER_ITEM
            )
        );
    bytes32 internal constant _ORDER_TYPEHASH_NOT_ARRAY = 
        keccak256(
            abi.encodePacked(
                "OrderComponents(",
                    "address offerer,",
                    "OfferItem offer,",
                    "ConsiderationItem consideration,",
                    "uint256 startTime,",
                    "uint256 endTime,",
                    "uint256 salt,",
                    "uint256 counter",
                ")",
                _CONSIDERATION_ITEM,
                _OFFER_ITEM
            )
        );

    

    function _deriveOrderHash(
        OrderParameters memory orderParameters,
        uint256 counter
    ) internal pure returns (bytes32 orderHash) {
        // Designate new memory regions for offer and consideration item hashes.
        bytes32[] memory offerHashes = new bytes32[](
            orderParameters.offer.length
        );
        bytes32[] memory considerationHashes = new bytes32[](
            orderParameters.consideration.length
        );

        // Iterate over each offer on the order.
        for (uint256 i = 0; i < orderParameters.offer.length; ++i) {
            // Hash the offer and place the result into memory.
            offerHashes[i] = _hashOfferItem(orderParameters.offer[i]);
        }

        // Iterate over each consideration on the order.
        for (uint256 i = 0; i < orderParameters.consideration.length; ++i) {
            // Hash the consideration and place the result into memory.
            considerationHashes[i] = _hashConsiderationItem(
                orderParameters.consideration[i]
            );
        }

        // Derive and return the order hash as specified by EIP-712.
        return
            keccak256(
                abi.encode(
                    _ORDER_TYPEHASH,
                    orderParameters.offerer,
                    keccak256(abi.encodePacked(offerHashes)),
                    keccak256(abi.encodePacked(considerationHashes)),
                    orderParameters.startTime,
                    orderParameters.endTime,
                    orderParameters.salt,
                    counter
                )
            );
    }

    function _deriveOrderHash_NotArray(
        OrderParameters memory orderParameters,
        uint256 counter
    ) internal pure returns (bytes32 orderHash) {
        bytes32 offerHash = _hashOfferItem(orderParameters.offer[0]);

        bytes32 considerationHash = _hashConsiderationItem(
            orderParameters.consideration[0]
        );

        // Derive and return the order hash as specified by EIP-712.
        return
            keccak256(
                abi.encode(
                    _ORDER_TYPEHASH_NOT_ARRAY,
                    orderParameters.offerer,
                    offerHash,
                    considerationHash,
                    orderParameters.startTime,
                    orderParameters.endTime,
                    orderParameters.salt,
                    counter
                )
            );
    }

    function _hashOfferItem(
        OfferItem memory offerItem
    ) internal pure returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    _OFFER_ITEM_TYPEHASH,
                    offerItem.itemType,
                    offerItem.token,
                    offerItem.identifierOrCriteria,
                    offerItem.startAmount,
                    offerItem.endAmount
                )
            );
    }

    function _hashConsiderationItem(ConsiderationItem memory considerationItem)
        internal
        pure
        returns (bytes32)
    {
        return
            keccak256(
                abi.encode(
                    _CONSIDERATION_ITEM_TYPEHASH,
                    considerationItem.itemType,
                    considerationItem.token,
                    considerationItem.identifierOrCriteria,
                    considerationItem.startAmount,
                    considerationItem.endAmount,
                    considerationItem.recipient
                )
            );
    }
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[],"name":"InvalidCanceller","type":"error"},{"inputs":[{"internalType":"enum ItemType","name":"offerType","type":"uint8"},{"internalType":"enum ItemType","name":"considerationType","type":"uint8"}],"name":"OrderTypeError","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"counter","type":"uint256"},{"indexed":true,"internalType":"address","name":"user","type":"address"}],"name":"CounterIncremented","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"canceller","type":"address"},{"indexed":true,"internalType":"uint256","name":"salt","type":"uint256"}],"name":"OrderCancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"bool","name":"permission","type":"bool"}],"name":"SetCollection","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"uint64","name":"marketFee","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"projectFee","type":"uint64"},{"indexed":false,"internalType":"uint64","name":"ipFee","type":"uint64"}],"name":"SetCollectionFee","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"marketVault","type":"address"},{"indexed":false,"internalType":"address","name":"projectVault","type":"address"},{"indexed":false,"internalType":"address","name":"ipVault","type":"address"}],"name":"SetVaults","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address[]","name":"users","type":"address[]"},{"indexed":false,"internalType":"bool[]","name":"permissions","type":"bool[]"}],"name":"SetWhiteList","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"orderHash","type":"bytes32"},{"indexed":true,"internalType":"uint256","name":"salt","type":"uint256"},{"indexed":true,"internalType":"uint256","name":"time","type":"uint256"},{"indexed":false,"internalType":"address","name":"from","type":"address"},{"indexed":false,"internalType":"address","name":"to","type":"address"}],"name":"Sold","type":"event"},{"inputs":[{"components":[{"internalType":"address","name":"offerer","type":"address"},{"components":[{"internalType":"enum ItemType","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifierOrCriteria","type":"uint256"},{"internalType":"uint256","name":"startAmount","type":"uint256"},{"internalType":"uint256","name":"endAmount","type":"uint256"}],"internalType":"struct OfferItem[]","name":"offer","type":"tuple[]"},{"components":[{"internalType":"enum ItemType","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifierOrCriteria","type":"uint256"},{"internalType":"uint256","name":"startAmount","type":"uint256"},{"internalType":"uint256","name":"endAmount","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"}],"internalType":"struct ConsiderationItem[]","name":"consideration","type":"tuple[]"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"},{"internalType":"uint256","name":"counter","type":"uint256"}],"internalType":"struct OrderComponents[]","name":"orders","type":"tuple[]"}],"name":"cancel","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"collections","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"counters","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"fees","outputs":[{"internalType":"uint64","name":"marketFee","type":"uint64"},{"internalType":"uint64","name":"projectFee","type":"uint64"},{"internalType":"uint64","name":"ipFee","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"offerer","type":"address"},{"components":[{"internalType":"enum ItemType","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifierOrCriteria","type":"uint256"},{"internalType":"uint256","name":"startAmount","type":"uint256"},{"internalType":"uint256","name":"endAmount","type":"uint256"}],"internalType":"struct OfferItem[]","name":"offer","type":"tuple[]"},{"components":[{"internalType":"enum ItemType","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"uint256","name":"identifierOrCriteria","type":"uint256"},{"internalType":"uint256","name":"startAmount","type":"uint256"},{"internalType":"uint256","name":"endAmount","type":"uint256"},{"internalType":"address payable","name":"recipient","type":"address"}],"internalType":"struct ConsiderationItem[]","name":"consideration","type":"tuple[]"},{"internalType":"uint256","name":"startTime","type":"uint256"},{"internalType":"uint256","name":"endTime","type":"uint256"},{"internalType":"uint256","name":"salt","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct OrderParameters","name":"order","type":"tuple"}],"name":"fulfillOrder","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"version","type":"string"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"ipVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"marketVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"name":"orderStatus","outputs":[{"internalType":"bool","name":"isValidated","type":"bool"},{"internalType":"bool","name":"isCancelled","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"projectVault","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collection","type":"address"},{"internalType":"bool","name":"permission","type":"bool"}],"name":"setCollection","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"collectionAddress","type":"address"},{"components":[{"internalType":"uint64","name":"marketFee","type":"uint64"},{"internalType":"uint64","name":"projectFee","type":"uint64"},{"internalType":"uint64","name":"ipFee","type":"uint64"}],"internalType":"struct Market.CollectionFee","name":"fees_","type":"tuple"}],"name":"setFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"marketVault_","type":"address"},{"internalType":"address","name":"projectVault_","type":"address"},{"internalType":"address","name":"ipVault_","type":"address"}],"name":"setVaults","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"users","type":"address[]"},{"internalType":"bool[]","name":"permissions","type":"bool[]"}],"name":"setWhiteList","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"whitelist","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506136a7806100206000396000f3fe6080604052600436106101095760003560e01c80638da5cb5b11610095578063be65ab8c11610064578063be65ab8c14610313578063cc5fe3ab1461034e578063f2fde38b1461036e578063f9e1e1611461038e578063faaebd21146103ae57600080fd5b80638da5cb5b146102855780639b19251a146102a3578063a414a372146102d3578063b0e7fbae146102f357600080fd5b80633c4e03bd116100dc5780633c4e03bd146101c557806343add2e6146101fd5780634cd88b761461023d578063679f431c1461025d578063715018a61461027057600080fd5b80631b4cb8811461010e57806321b837c21461013057806323ab75ed146101505780632dff692d14610170575b600080fd5b34801561011a57600080fd5b5061012e6101293660046127cd565b610424565b005b34801561013c57600080fd5b5061012e61014b366004612806565b610512565b34801561015c57600080fd5b5061012e61016b366004612847565b61071d565b34801561017c57600080fd5b506101a961018b366004612892565b60d16020526000908152604090205460ff8082169161010090041682565b6040805192151583529015156020830152015b60405180910390f35b3480156101d157600080fd5b5060cb546101e5906001600160a01b031681565b6040516001600160a01b0390911681526020016101bc565b34801561020957600080fd5b5061022d6102183660046128ab565b60d26020526000908152604090205460ff1681565b60405190151581526020016101bc565b34801561024957600080fd5b5061012e6102583660046129a5565b6107aa565b61012e61026b366004612a08565b6108c3565b34801561027c57600080fd5b5061012e611b11565b34801561029157600080fd5b506033546001600160a01b03166101e5565b3480156102af57600080fd5b5061022d6102be3660046128ab565b60cf6020526000908152604090205460ff1681565b3480156102df57600080fd5b5060cd546101e5906001600160a01b031681565b3480156102ff57600080fd5b5061012e61030e366004612a86565b611b25565b34801561031f57600080fd5b5061034061032e3660046128ab565b60d06020526000908152604090205481565b6040519081526020016101bc565b34801561035a57600080fd5b5061012e610369366004612ac7565b611d68565b34801561037a57600080fd5b5061012e6103893660046128ab565b611e4b565b34801561039a57600080fd5b5060cc546101e5906001600160a01b031681565b3480156103ba57600080fd5b506103fa6103c93660046128ab565b60ce602052600090815260409020546001600160401b0380821691600160401b8104821691600160801b9091041683565b604080516001600160401b03948516815292841660208401529216918101919091526060016101bc565b61042c611ec1565b60cb546001600160a01b031615801590610450575060cc546001600160a01b031615155b8015610466575060cd546001600160a01b031615155b6104af5760405162461bcd60e51b81526020600482015260156024820152744552524f523a207661756c7420697320656d70747960581b60448201526064015b60405180910390fd5b6001600160a01b038216600081815260d26020908152604091829020805460ff19168515159081179091558251938452908301527f9066181c8b39b4173bb6a1bc5ca89fa82ec1bc553324feb7e0e22c8d04b49c43910160405180910390a15050565b61051a611ec1565b60cb546001600160a01b03161580159061053e575060cc546001600160a01b031615155b8015610554575060cd546001600160a01b031615155b6105985760405162461bcd60e51b81526020600482015260156024820152744552524f523a207661756c7420697320656d70747960581b60448201526064016104a6565b6127106105ab6060830160408401612b47565b6105bb6040840160208501612b47565b6105c86020850185612b47565b6105d29190612b7a565b6105dc9190612b7a565b6001600160401b0316106106235760405162461bcd60e51b815260206004820152600e60248201526d657863656564206d61782066656560901b60448201526064016104a6565b6001600160a01b038216600090815260ce6020526040902081906106478282612ba1565b507f620434de919a4aaa4a1186a466349cba49fc74d79fe8349fc22f5c0dc33ab9d59050826106796020840184612b47565b6106896040850160208601612b47565b6106996060860160408701612b47565b604080516001600160a01b0390951685526001600160401b0393841660208601529183169184019190915216606082015260800160405180910390a16001600160a01b038216600090815260d2602052604090205460ff16610719576001600160a01b038216600090815260d260205260409020805460ff191660011790555b5050565b610725611ec1565b60cb80546001600160a01b038581166001600160a01b0319928316811790935560cc8054868316908416811790915560cd8054928616929093168217909255604080519384526020840192909252908201527fe6b0a25e8c73b8a80f4f81456a90d2c735cc8ccafef6f339b977a0401277ab82906060015b60405180910390a1505050565b600054610100900460ff16158080156107ca5750600054600160ff909116105b806107e45750303b1580156107e4575060005460ff166001145b6108475760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104a6565b6000805460ff19166001179055801561086a576000805461ff0019166101001790555b610872611f1b565b61087c8383611f4a565b80156108be576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161079d565b505050565b6108cb611f7b565b600080806109126108db85612e5e565b60d060006108ec60208901896128ab565b6001600160a01b03166001600160a01b0316815260200190815260200160002054611fd4565b90508360600135421015801561092c575083608001354211155b6109655760405162461bcd60e51b815260206004820152600a6024820152692a34b6b29032b93937b960b11b60448201526064016104a6565b600081815260d1602052604090208054610100900460ff1615801561098c5750805460ff16155b6109c75760405162461bcd60e51b815260206004820152600c60248201526b29ba30ba3ab99032b93937b960a11b60448201526064016104a6565b6109d460208601866128ab565b6001600160a01b03166109f3836109ee60c0890189612f1e565b612269565b6001600160a01b031614610a365760405162461bcd60e51b815260206004820152600a60248201526929b4b3b71032b93937b960b11b60448201526064016104a6565b610a436040860186612f64565b90506001148015610a625750610a5c6020860186612fac565b90506001145b610aa35760405162461bcd60e51b81526020600482015260126024820152712830b930b6903632b733ba341032b93937b960711b60448201526064016104a6565b600080808080610ab660408b018b612f64565b6000818110610ac757610ac7612ff4565b905060c00201803603810190610add919061300a565b90506000610aee60208c018c612fac565b6000818110610aff57610aff612ff4565b905060a00201803603810190610b159190613026565b9050600081516003811115610b2c57610b2c613042565b03610b50578051825160405163c0eba3a160e01b81526104a692919060040161307a565b33600090815260cf602052604090205460ff1661135957600082516003811115610b7c57610b7c613042565b1480610b9a5750600182516003811115610b9857610b98613042565b145b15610fb5576020808201516001600160a01b0316600090815260ce9091526040902054606083015161271091610bdb916001600160401b0390911690613095565b610be591906130b4565b6020828101516001600160a01b0316600090815260ce9091526040902054606084015191975061271091610c2991600160401b90046001600160401b031690613095565b610c3391906130b4565b6020828101516001600160a01b0316600090815260ce9091526040902054606084015191965061271091610c7791600160801b90046001600160401b031690613095565b610c8191906130b4565b935083610c8e86886130d6565b610c9891906130d6565b9250600082516003811115610caf57610caf613042565b03610d6a5760cb546040516001600160a01b039091169087156108fc029088906000818181858888f19350505050158015610cee573d6000803e3d6000fd5b5060cc546040516001600160a01b039091169086156108fc029087906000818181858888f19350505050158015610d29573d6000803e3d6000fd5b5060cd546040516001600160a01b039091169085156108fc029086906000818181858888f19350505050158015610d64573d6000803e3d6000fd5b50611359565b602082015160cb546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610da5923392909116908b906004016130e9565b6020604051808303816000875af1158015610dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de8919061310d565b610e2d5760405162461bcd60e51b815260206004820152601660248201527522a92199181036b0b935b2ba103332b29032b93937b960511b60448201526064016104a6565b602082015160cc546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610e68923392909116908a906004016130e9565b6020604051808303816000875af1158015610e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eab919061310d565b610ef15760405162461bcd60e51b815260206004820152601760248201527622a921991810383937b532b1ba103332b29032b93937b960491b60448201526064016104a6565b602082015160cd546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610f2c9233929091169089906004016130e9565b6020604051808303816000875af1158015610f4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6f919061310d565b610fb05760405162461bcd60e51b815260206004820152601260248201527122a92199181034b8103332b29032b93937b960711b60448201526064016104a6565b611359565b600181516003811115610fca57610fca613042565b03611359576020808301516001600160a01b0316600090815260ce909152604090205460608201516127109161100b916001600160401b0390911690613095565b61101591906130b4565b6020838101516001600160a01b0316600090815260ce909152604090205460608301519197506127109161105991600160401b90046001600160401b031690613095565b61106391906130b4565b6020838101516001600160a01b0316600090815260ce90915260409020546060830151919650612710916110a791600160801b90046001600160401b031690613095565b6110b191906130b4565b9350836110be86886130d6565b6110c891906130d6565b925080602001516001600160a01b03166323b872dd8c60000160208101906110f091906128ab565b60cb546040516001600160e01b031960e085901b16815261112092916001600160a01b0316908b906004016130e9565b6020604051808303816000875af115801561113f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611163919061310d565b6111a85760405162461bcd60e51b815260206004820152601660248201527522a92199181036b0b935b2ba103332b29032b93937b960511b60448201526064016104a6565b6020808201516001600160a01b0316906323b872dd906111ca908e018e6128ab565b60cc546040516001600160e01b031960e085901b1681526111fa92916001600160a01b0316908a906004016130e9565b6020604051808303816000875af1158015611219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123d919061310d565b6112835760405162461bcd60e51b815260206004820152601760248201527622a921991810383937b532b1ba103332b29032b93937b960491b60448201526064016104a6565b6020808201516001600160a01b0316906323b872dd906112a5908e018e6128ab565b60cd546040516001600160e01b031960e085901b1681526112d592916001600160a01b03169089906004016130e9565b6020604051808303816000875af11580156112f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611318919061310d565b6113595760405162461bcd60e51b815260206004820152601260248201527122a92199181034b8103332b29032b93937b960711b60448201526064016104a6565b60008251600381111561136e5761136e613042565b148061138c575060018251600381111561138a5761138a613042565b145b15611599576002815160038111156113a6576113a6613042565b141580156113c757506003815160038111156113c4576113c4613042565b14155b156113eb578051825160405163c0eba3a160e01b81526104a692919060040161307a565b60008251600381111561140057611400613042565b0361149957816060015134101561144a5760405162461bcd60e51b815260206004820152600e60248201526d2a2c103b30b63ab29032b93937b960911b60448201526064016104a6565b8160a001516001600160a01b03166108fc84846060015161146b919061312a565b6040518115909202916000818181858888f19350505050158015611493573d6000803e3d6000fd5b50611758565b6001825160038111156114ae576114ae613042565b036115945781602001516001600160a01b03166323b872dd338460a001518686606001516114dc919061312a565b6040518463ffffffff1660e01b81526004016114fa939291906130e9565b6020604051808303816000875af1158015611519573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153d919061310d565b6115945760405162461bcd60e51b815260206004820152602260248201527f5472616e7366657220657263323020636f6e73696465726174696f6e2065727260448201526137b960f11b60648201526084016104a6565b611758565b6002825160038111156115ae576115ae613042565b14806115cc57506003825160038111156115ca576115ca613042565b145b15611739576020808301516001600160a01b0316600090815260d2909152604090205460ff1661160e5760405162461bcd60e51b81526004016104a69061313d565b60028251600381111561162357611623613042565b0361169b57602082015160a08301516040808501519051632142170760e11b81526001600160a01b03909316926342842e0e926116649233926004016130e9565b600060405180830381600087803b15801561167e57600080fd5b505af1158015611692573d6000803e3d6000fd5b5050505061172a565b6003825160038111156116b0576116b0613042565b0361172a5781602001516001600160a01b031663f242432a338460a00151856040015186606001516040518563ffffffff1660e01b81526004016116f79493929190613185565b600060405180830381600087803b15801561171157600080fd5b505af1158015611725573d6000803e3d6000fd5b505050505b3399508160a001519850611758565b8051825160405163c0eba3a160e01b81526104a692919060040161307a565b60008151600381111561176d5761176d613042565b03611791578051825160405163c0eba3a160e01b81526104a692919060040161307a565b6001815160038111156117a6576117a6613042565b036118ea576002825160038111156117c0576117c0613042565b141580156117e157506003825160038111156117de576117de613042565b14155b15611805578051825160405163c0eba3a160e01b81526104a692919060040161307a565b6020808201516001600160a01b0316906323b872dd90611827908e018e6128ab565b33868560600151611838919061312a565b6040518463ffffffff1660e01b8152600401611856939291906130e9565b6020604051808303816000875af1158015611875573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611899919061310d565b6118e55760405162461bcd60e51b815260206004820152601a60248201527f5472616e73666572206572633230206f66666572206572726f7200000000000060448201526064016104a6565b611aa2565b6002815160038111156118ff576118ff613042565b148061191d575060038151600381111561191b5761191b613042565b145b15611739576020808201516001600160a01b0316600090815260d2909152604090205460ff1661195f5760405162461bcd60e51b81526004016104a69061313d565b60028151600381111561197457611974613042565b036119f6576020808201516001600160a01b0316906342842e0e9061199b908e018e6128ab565b3384604001516040518463ffffffff1660e01b81526004016119bf939291906130e9565b600060405180830381600087803b1580156119d957600080fd5b505af11580156119ed573d6000803e3d6000fd5b50505050611a8f565b600381516003811115611a0b57611a0b613042565b03611a8f576020808201516001600160a01b03169063f242432a90611a32908e018e6128ab565b33846040015185606001516040518563ffffffff1660e01b8152600401611a5c9493929190613185565b600060405180830381600087803b158015611a7657600080fd5b505af1158015611a8a573d6000803e3d6000fd5b505050505b611a9c60208c018c6128ab565b99503398505b865460ff19166001178755604080516001600160a01b038c811682528b166020820152429160a08e0135918b917fd83bf72c88d7355a2de3c89ca42e86a646abb6fc1bc91613e4e816021bf091c0910160405180910390a450505050505050505050611b0e6001609955565b50565b611b19611ec1565b611b2360006122c5565b565b611b2d611f7b565b60008060005b83811015611d5b5736858583818110611b4e57611b4e612ff4565b9050602002810190611b6091906131c9565b9050611b6f60208201826128ab565b9250336001600160a01b03841614611b9a5760405163203b1cdd60e21b815260040160405180910390fd5b6000611cf16040518060e00160405280866001600160a01b03168152602001848060200190611bc99190612fac565b808060200260200160405190810160405280939291908181526020016000905b82821015611c1557611c0660a08302860136819003810190613026565b81526020019060010190611be9565b5050509183525050602001611c2d6040860186612f64565b808060200260200160405190810160405280939291908181526020016000905b82821015611c7957611c6a60c0830286013681900381019061300a565b81526020019060010190611c4d565b5050505050815260200184606001358152602001846080013581526020018460a001358152602001848060c00190611cb19190612f1e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505091525060e0840135611fd4565b600081815260d16020526040808220805461ffff1916610100178155905190975091925060a0840135916001600160a01b038716917fdd003742fb214507783ce004fe55f5ac14f89c6de4a7cd7487e47eb091c6226591a3611d52836131e9565b92505050611b33565b5050506107196001609955565b611d70611ec1565b60005b83811015611e0757828282818110611d8d57611d8d612ff4565b9050602002016020810190611da29190613202565b60cf6000878785818110611db857611db8612ff4565b9050602002016020810190611dcd91906128ab565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580611dff816131e9565b915050611d73565b507f849bc039c6dbcf9934f2e6d667158c8c6bdd9487a4154c25d0662a293bdd91eb84848484604051611e3d949392919061321f565b60405180910390a150505050565b611e53611ec1565b6001600160a01b038116611eb85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104a6565b611b0e816122c5565b6033546001600160a01b03163314611b235760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104a6565b600054610100900460ff16611f425760405162461bcd60e51b81526004016104a6906132af565b611b23612317565b600054610100900460ff16611f715760405162461bcd60e51b81526004016104a6906132af565b6107198282612347565b600260995403611fcd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104a6565b6002609955565b6000808360200151516001600160401b03811115611ff457611ff46128c8565b60405190808252806020026020018201604052801561201d578160200160208202803683370190505b50905060008460400151516001600160401b0381111561203f5761203f6128c8565b604051908082528060200260200182016040528015612068578160200160208202803683370190505b50905060005b8560200151518110156120ce576120a18660200151828151811061209457612094612ff4565b6020026020010151612388565b8382815181106120b3576120b3612ff4565b60209081029190910101526120c7816131e9565b905061206e565b5060005b85604001515181101561213257612105866040015182815181106120f8576120f8612ff4565b60200260200101516123fa565b82828151811061211757612117612ff4565b602090810291909101015261212b816131e9565b90506120d2565b50604051602001612142906132fa565b604051602081830303815290604052604051602001612160906133c9565b60408051601f198184030181529082905261217e92916020016134a5565b604051602081830303815290604052805190602001208560000151836040516020016121aa91906135ac565b60405160208183030381529060405280519060200120836040516020016121d191906135ac565b60405160208183030381529060405280519060200120886060015189608001518a60a001518a6040516020016122489897969594939291909788526001600160a01b0396909616602088015260408701949094526060860192909252608085015260a084015260c083015260e08201526101000190565b60405160208183030381529060405280519060200120925050505b92915050565b60008061227585612455565b905060006122b98286868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124a392505050565b925050505b9392505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661233e5760405162461bcd60e51b81526004016104a6906132af565b611b23336122c5565b600054610100900460ff1661236e5760405162461bcd60e51b81526004016104a6906132af565b815160209283012081519190920120606591909155606655565b6000604051602001612399906133c9565b60405160208183030381529060405280519060200120826000015183602001518460400151856060015186608001516040516020016123dd969594939291906135e2565b604051602081830303815290604052805190602001209050919050565b600060405160200161240b906132fa565b60405160208183030381529060405280519060200120826000015183602001518460400151856060015186608001518760a001516040516020016123dd9796959493929190613623565b60006122636124626124c7565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006124b28585612547565b915091506124bf8161258c565b509392505050565b60006125427f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6124f660655490565b6066546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b600080825160410361257d5760208301516040840151606085015160001a612571878285856126d6565b94509450505050612585565b506000905060025b9250929050565b60008160048111156125a0576125a0613042565b036125a85750565b60018160048111156125bc576125bc613042565b036126095760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016104a6565b600281600481111561261d5761261d613042565b0361266a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016104a6565b600381600481111561267e5761267e613042565b03611b0e5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016104a6565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561270d5750600090506003612791565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612761573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661278a57600060019250925050612791565b9150600090505b94509492505050565b6001600160a01b0381168114611b0e57600080fd5b80356127ba8161279a565b919050565b8015158114611b0e57600080fd5b600080604083850312156127e057600080fd5b82356127eb8161279a565b915060208301356127fb816127bf565b809150509250929050565b600080828403608081121561281a57600080fd5b83356128258161279a565b92506060601f198201121561283957600080fd5b506020830190509250929050565b60008060006060848603121561285c57600080fd5b83356128678161279a565b925060208401356128778161279a565b915060408401356128878161279a565b809150509250925092565b6000602082840312156128a457600080fd5b5035919050565b6000602082840312156128bd57600080fd5b81356122be8161279a565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b0381118282101715612900576129006128c8565b60405290565b604051601f8201601f191681016001600160401b038111828210171561292e5761292e6128c8565b604052919050565b600082601f83011261294757600080fd5b81356001600160401b03811115612960576129606128c8565b612973601f8201601f1916602001612906565b81815284602083860101111561298857600080fd5b816020850160208301376000918101602001919091529392505050565b600080604083850312156129b857600080fd5b82356001600160401b03808211156129cf57600080fd5b6129db86838701612936565b935060208501359150808211156129f157600080fd5b506129fe85828601612936565b9150509250929050565b600060208284031215612a1a57600080fd5b81356001600160401b03811115612a3057600080fd5b820160e081850312156122be57600080fd5b60008083601f840112612a5457600080fd5b5081356001600160401b03811115612a6b57600080fd5b6020830191508360208260051b850101111561258557600080fd5b60008060208385031215612a9957600080fd5b82356001600160401b03811115612aaf57600080fd5b612abb85828601612a42565b90969095509350505050565b60008060008060408587031215612add57600080fd5b84356001600160401b0380821115612af457600080fd5b612b0088838901612a42565b90965094506020870135915080821115612b1957600080fd5b50612b2687828801612a42565b95989497509550505050565b6001600160401b0381168114611b0e57600080fd5b600060208284031215612b5957600080fd5b81356122be81612b32565b634e487b7160e01b600052601160045260246000fd5b6001600160401b03818116838216019080821115612b9a57612b9a612b64565b5092915050565b8135612bac81612b32565b6001600160401b03811690508154816001600160401b031982161783556020840135612bd781612b32565b6fffffffffffffffff0000000000000000604091821b166fffffffffffffffffffffffffffffffff19831684178117855590850135612c1581612b32565b6001600160c01b0319929092169092179190911760809190911b67ffffffffffffffff60801b1617905550565b60006001600160401b03821115612c5b57612c5b6128c8565b5060051b60200190565b8035600481106127ba57600080fd5b600060a08284031215612c8657600080fd5b60405160a081018181106001600160401b0382111715612ca857612ca86128c8565b604052905080612cb783612c65565b81526020830135612cc78161279a565b806020830152506040830135604082015260608301356060820152608083013560808201525092915050565b600082601f830112612d0457600080fd5b81356020612d19612d1483612c42565b612906565b82815260a09283028501820192828201919087851115612d3857600080fd5b8387015b85811015612d5b57612d4e8982612c74565b8452928401928101612d3c565b5090979650505050505050565b600060c08284031215612d7a57600080fd5b60405160c081018181106001600160401b0382111715612d9c57612d9c6128c8565b604052905080612dab83612c65565b81526020830135612dbb8161279a565b8060208301525060408301356040820152606083013560608201526080830135608082015260a0830135612dee8161279a565b60a0919091015292915050565b600082601f830112612e0c57600080fd5b81356020612e1c612d1483612c42565b82815260c09283028501820192828201919087851115612e3b57600080fd5b8387015b85811015612d5b57612e518982612d68565b8452928401928101612e3f565b600060e08236031215612e7057600080fd5b612e786128de565b612e81836127af565b815260208301356001600160401b0380821115612e9d57600080fd5b612ea936838701612cf3565b60208401526040850135915080821115612ec257600080fd5b612ece36838701612dfb565b6040840152606085013560608401526080850135608084015260a085013560a084015260c0850135915080821115612f0557600080fd5b50612f1236828601612936565b60c08301525092915050565b6000808335601e19843603018112612f3557600080fd5b8301803591506001600160401b03821115612f4f57600080fd5b60200191503681900382131561258557600080fd5b6000808335601e19843603018112612f7b57600080fd5b8301803591506001600160401b03821115612f9557600080fd5b602001915060c08102360382131561258557600080fd5b6000808335601e19843603018112612fc357600080fd5b8301803591506001600160401b03821115612fdd57600080fd5b602001915060a08102360382131561258557600080fd5b634e487b7160e01b600052603260045260246000fd5b600060c0828403121561301c57600080fd5b6122be8383612d68565b600060a0828403121561303857600080fd5b6122be8383612c74565b634e487b7160e01b600052602160045260246000fd5b6004811061307657634e487b7160e01b600052602160045260246000fd5b9052565b604081016130888285613058565b6122be6020830184613058565b60008160001904831182151516156130af576130af612b64565b500290565b6000826130d157634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561226357612263612b64565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006020828403121561311f57600080fd5b81516122be816127bf565b8181038181111561226357612263612b64565b60208082526028908201527f4552524f523a205468697320636f6c6c656374696f6e20686173206e6f2070656040820152673936b4b9b9b4b7b760c11b606082015260800190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a0608082018190526003908201526203078360ec1b60c082015260e00190565b6000823560fe198336030181126131df57600080fd5b9190910192915050565b6000600182016131fb576131fb612b64565b5060010190565b60006020828403121561321457600080fd5b81356122be816127bf565b6040808252810184905260008560608301825b878110156132625782356132458161279a565b6001600160a01b0316825260209283019290910190600101613232565b5083810360208581019190915285825291508590820160005b868110156132a257823561328e816127bf565b15158252918301919083019060010161327b565b5098975050505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b71086dedce6d2c8cae4c2e8d2dedc92e8cada560731b81526e1d5a5b9d0e081a5d195b551e5c194b608a1b60128201526d1859191c995cdcc81d1bdad95b8b60921b60218201527f75696e74323536206964656e7469666965724f7243726974657269612c000000602f820152731d5a5b9d0c8d4d881cdd185c9d105b5bdd5b9d0b60621b604c820152711d5a5b9d0c8d4d88195b99105b5bdd5b9d0b60721b6060820152701859191c995cdcc81c9958da5c1a595b9d607a1b6072820152602960f81b608382015260840190565b6909ecccccae492e8cada560b31b81526e1d5a5b9d0e081a5d195b551e5c194b608a1b600a8201526d1859191c995cdcc81d1bdad95b8b60921b60198201527f75696e74323536206964656e7469666965724f7243726974657269612c0000006027820152731d5a5b9d0c8d4d881cdd185c9d105b5bdd5b9d0b60621b6044820152701d5a5b9d0c8d4d88195b99105b5bdd5b9d607a1b6058820152602960f81b6069820152606a0190565b6000815160005b81811015613496576020818501810151868301520161347c565b50600093019283525090919050565b6f09ee4c8cae486dedae0dedccadce8e6560831b81526f1859191c995cdcc81bd999995c995c8b60821b60108201527113d999995c925d195b56d7481bd999995c8b60721b60208201527f436f6e73696465726174696f6e4974656d5b5d20636f6e73696465726174696f6032820152611b8b60f21b6052820152711d5a5b9d0c8d4d881cdd185c9d151a5b594b60721b60548201526f1d5a5b9d0c8d4d88195b99151a5b594b60821b60668201526c1d5a5b9d0c8d4d881cd85b1d0b609a1b60768201526e3ab4b73a191a9b1031b7bab73a32b960891b6083820152602960f81b609282015260006135a461359e6093840186613475565b84613475565b949350505050565b815160009082906020808601845b838110156135d6578151855293820193908201906001016135ba565b50929695505050505050565b86815260c081016135f66020830188613058565b6001600160a01b039590951660408201526060810193909352608083019190915260a09091015292915050565b87815260e081016136376020830189613058565b6001600160a01b0396871660408301526060820195909552608081019390935260a083019190915290921660c0909201919091529291505056fea26469706673582212208bc24d7f7527598eb591e0405d04f002de12ef8dace2a3f9fc2e7b812ff90b7064736f6c63430008100033

Deployed Bytecode

0x6080604052600436106101095760003560e01c80638da5cb5b11610095578063be65ab8c11610064578063be65ab8c14610313578063cc5fe3ab1461034e578063f2fde38b1461036e578063f9e1e1611461038e578063faaebd21146103ae57600080fd5b80638da5cb5b146102855780639b19251a146102a3578063a414a372146102d3578063b0e7fbae146102f357600080fd5b80633c4e03bd116100dc5780633c4e03bd146101c557806343add2e6146101fd5780634cd88b761461023d578063679f431c1461025d578063715018a61461027057600080fd5b80631b4cb8811461010e57806321b837c21461013057806323ab75ed146101505780632dff692d14610170575b600080fd5b34801561011a57600080fd5b5061012e6101293660046127cd565b610424565b005b34801561013c57600080fd5b5061012e61014b366004612806565b610512565b34801561015c57600080fd5b5061012e61016b366004612847565b61071d565b34801561017c57600080fd5b506101a961018b366004612892565b60d16020526000908152604090205460ff8082169161010090041682565b6040805192151583529015156020830152015b60405180910390f35b3480156101d157600080fd5b5060cb546101e5906001600160a01b031681565b6040516001600160a01b0390911681526020016101bc565b34801561020957600080fd5b5061022d6102183660046128ab565b60d26020526000908152604090205460ff1681565b60405190151581526020016101bc565b34801561024957600080fd5b5061012e6102583660046129a5565b6107aa565b61012e61026b366004612a08565b6108c3565b34801561027c57600080fd5b5061012e611b11565b34801561029157600080fd5b506033546001600160a01b03166101e5565b3480156102af57600080fd5b5061022d6102be3660046128ab565b60cf6020526000908152604090205460ff1681565b3480156102df57600080fd5b5060cd546101e5906001600160a01b031681565b3480156102ff57600080fd5b5061012e61030e366004612a86565b611b25565b34801561031f57600080fd5b5061034061032e3660046128ab565b60d06020526000908152604090205481565b6040519081526020016101bc565b34801561035a57600080fd5b5061012e610369366004612ac7565b611d68565b34801561037a57600080fd5b5061012e6103893660046128ab565b611e4b565b34801561039a57600080fd5b5060cc546101e5906001600160a01b031681565b3480156103ba57600080fd5b506103fa6103c93660046128ab565b60ce602052600090815260409020546001600160401b0380821691600160401b8104821691600160801b9091041683565b604080516001600160401b03948516815292841660208401529216918101919091526060016101bc565b61042c611ec1565b60cb546001600160a01b031615801590610450575060cc546001600160a01b031615155b8015610466575060cd546001600160a01b031615155b6104af5760405162461bcd60e51b81526020600482015260156024820152744552524f523a207661756c7420697320656d70747960581b60448201526064015b60405180910390fd5b6001600160a01b038216600081815260d26020908152604091829020805460ff19168515159081179091558251938452908301527f9066181c8b39b4173bb6a1bc5ca89fa82ec1bc553324feb7e0e22c8d04b49c43910160405180910390a15050565b61051a611ec1565b60cb546001600160a01b03161580159061053e575060cc546001600160a01b031615155b8015610554575060cd546001600160a01b031615155b6105985760405162461bcd60e51b81526020600482015260156024820152744552524f523a207661756c7420697320656d70747960581b60448201526064016104a6565b6127106105ab6060830160408401612b47565b6105bb6040840160208501612b47565b6105c86020850185612b47565b6105d29190612b7a565b6105dc9190612b7a565b6001600160401b0316106106235760405162461bcd60e51b815260206004820152600e60248201526d657863656564206d61782066656560901b60448201526064016104a6565b6001600160a01b038216600090815260ce6020526040902081906106478282612ba1565b507f620434de919a4aaa4a1186a466349cba49fc74d79fe8349fc22f5c0dc33ab9d59050826106796020840184612b47565b6106896040850160208601612b47565b6106996060860160408701612b47565b604080516001600160a01b0390951685526001600160401b0393841660208601529183169184019190915216606082015260800160405180910390a16001600160a01b038216600090815260d2602052604090205460ff16610719576001600160a01b038216600090815260d260205260409020805460ff191660011790555b5050565b610725611ec1565b60cb80546001600160a01b038581166001600160a01b0319928316811790935560cc8054868316908416811790915560cd8054928616929093168217909255604080519384526020840192909252908201527fe6b0a25e8c73b8a80f4f81456a90d2c735cc8ccafef6f339b977a0401277ab82906060015b60405180910390a1505050565b600054610100900460ff16158080156107ca5750600054600160ff909116105b806107e45750303b1580156107e4575060005460ff166001145b6108475760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084016104a6565b6000805460ff19166001179055801561086a576000805461ff0019166101001790555b610872611f1b565b61087c8383611f4a565b80156108be576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200161079d565b505050565b6108cb611f7b565b600080806109126108db85612e5e565b60d060006108ec60208901896128ab565b6001600160a01b03166001600160a01b0316815260200190815260200160002054611fd4565b90508360600135421015801561092c575083608001354211155b6109655760405162461bcd60e51b815260206004820152600a6024820152692a34b6b29032b93937b960b11b60448201526064016104a6565b600081815260d1602052604090208054610100900460ff1615801561098c5750805460ff16155b6109c75760405162461bcd60e51b815260206004820152600c60248201526b29ba30ba3ab99032b93937b960a11b60448201526064016104a6565b6109d460208601866128ab565b6001600160a01b03166109f3836109ee60c0890189612f1e565b612269565b6001600160a01b031614610a365760405162461bcd60e51b815260206004820152600a60248201526929b4b3b71032b93937b960b11b60448201526064016104a6565b610a436040860186612f64565b90506001148015610a625750610a5c6020860186612fac565b90506001145b610aa35760405162461bcd60e51b81526020600482015260126024820152712830b930b6903632b733ba341032b93937b960711b60448201526064016104a6565b600080808080610ab660408b018b612f64565b6000818110610ac757610ac7612ff4565b905060c00201803603810190610add919061300a565b90506000610aee60208c018c612fac565b6000818110610aff57610aff612ff4565b905060a00201803603810190610b159190613026565b9050600081516003811115610b2c57610b2c613042565b03610b50578051825160405163c0eba3a160e01b81526104a692919060040161307a565b33600090815260cf602052604090205460ff1661135957600082516003811115610b7c57610b7c613042565b1480610b9a5750600182516003811115610b9857610b98613042565b145b15610fb5576020808201516001600160a01b0316600090815260ce9091526040902054606083015161271091610bdb916001600160401b0390911690613095565b610be591906130b4565b6020828101516001600160a01b0316600090815260ce9091526040902054606084015191975061271091610c2991600160401b90046001600160401b031690613095565b610c3391906130b4565b6020828101516001600160a01b0316600090815260ce9091526040902054606084015191965061271091610c7791600160801b90046001600160401b031690613095565b610c8191906130b4565b935083610c8e86886130d6565b610c9891906130d6565b9250600082516003811115610caf57610caf613042565b03610d6a5760cb546040516001600160a01b039091169087156108fc029088906000818181858888f19350505050158015610cee573d6000803e3d6000fd5b5060cc546040516001600160a01b039091169086156108fc029087906000818181858888f19350505050158015610d29573d6000803e3d6000fd5b5060cd546040516001600160a01b039091169085156108fc029086906000818181858888f19350505050158015610d64573d6000803e3d6000fd5b50611359565b602082015160cb546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610da5923392909116908b906004016130e9565b6020604051808303816000875af1158015610dc4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610de8919061310d565b610e2d5760405162461bcd60e51b815260206004820152601660248201527522a92199181036b0b935b2ba103332b29032b93937b960511b60448201526064016104a6565b602082015160cc546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610e68923392909116908a906004016130e9565b6020604051808303816000875af1158015610e87573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610eab919061310d565b610ef15760405162461bcd60e51b815260206004820152601760248201527622a921991810383937b532b1ba103332b29032b93937b960491b60448201526064016104a6565b602082015160cd546040516323b872dd60e01b81526001600160a01b03928316926323b872dd92610f2c9233929091169089906004016130e9565b6020604051808303816000875af1158015610f4b573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f6f919061310d565b610fb05760405162461bcd60e51b815260206004820152601260248201527122a92199181034b8103332b29032b93937b960711b60448201526064016104a6565b611359565b600181516003811115610fca57610fca613042565b03611359576020808301516001600160a01b0316600090815260ce909152604090205460608201516127109161100b916001600160401b0390911690613095565b61101591906130b4565b6020838101516001600160a01b0316600090815260ce909152604090205460608301519197506127109161105991600160401b90046001600160401b031690613095565b61106391906130b4565b6020838101516001600160a01b0316600090815260ce90915260409020546060830151919650612710916110a791600160801b90046001600160401b031690613095565b6110b191906130b4565b9350836110be86886130d6565b6110c891906130d6565b925080602001516001600160a01b03166323b872dd8c60000160208101906110f091906128ab565b60cb546040516001600160e01b031960e085901b16815261112092916001600160a01b0316908b906004016130e9565b6020604051808303816000875af115801561113f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611163919061310d565b6111a85760405162461bcd60e51b815260206004820152601660248201527522a92199181036b0b935b2ba103332b29032b93937b960511b60448201526064016104a6565b6020808201516001600160a01b0316906323b872dd906111ca908e018e6128ab565b60cc546040516001600160e01b031960e085901b1681526111fa92916001600160a01b0316908a906004016130e9565b6020604051808303816000875af1158015611219573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061123d919061310d565b6112835760405162461bcd60e51b815260206004820152601760248201527622a921991810383937b532b1ba103332b29032b93937b960491b60448201526064016104a6565b6020808201516001600160a01b0316906323b872dd906112a5908e018e6128ab565b60cd546040516001600160e01b031960e085901b1681526112d592916001600160a01b03169089906004016130e9565b6020604051808303816000875af11580156112f4573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611318919061310d565b6113595760405162461bcd60e51b815260206004820152601260248201527122a92199181034b8103332b29032b93937b960711b60448201526064016104a6565b60008251600381111561136e5761136e613042565b148061138c575060018251600381111561138a5761138a613042565b145b15611599576002815160038111156113a6576113a6613042565b141580156113c757506003815160038111156113c4576113c4613042565b14155b156113eb578051825160405163c0eba3a160e01b81526104a692919060040161307a565b60008251600381111561140057611400613042565b0361149957816060015134101561144a5760405162461bcd60e51b815260206004820152600e60248201526d2a2c103b30b63ab29032b93937b960911b60448201526064016104a6565b8160a001516001600160a01b03166108fc84846060015161146b919061312a565b6040518115909202916000818181858888f19350505050158015611493573d6000803e3d6000fd5b50611758565b6001825160038111156114ae576114ae613042565b036115945781602001516001600160a01b03166323b872dd338460a001518686606001516114dc919061312a565b6040518463ffffffff1660e01b81526004016114fa939291906130e9565b6020604051808303816000875af1158015611519573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061153d919061310d565b6115945760405162461bcd60e51b815260206004820152602260248201527f5472616e7366657220657263323020636f6e73696465726174696f6e2065727260448201526137b960f11b60648201526084016104a6565b611758565b6002825160038111156115ae576115ae613042565b14806115cc57506003825160038111156115ca576115ca613042565b145b15611739576020808301516001600160a01b0316600090815260d2909152604090205460ff1661160e5760405162461bcd60e51b81526004016104a69061313d565b60028251600381111561162357611623613042565b0361169b57602082015160a08301516040808501519051632142170760e11b81526001600160a01b03909316926342842e0e926116649233926004016130e9565b600060405180830381600087803b15801561167e57600080fd5b505af1158015611692573d6000803e3d6000fd5b5050505061172a565b6003825160038111156116b0576116b0613042565b0361172a5781602001516001600160a01b031663f242432a338460a00151856040015186606001516040518563ffffffff1660e01b81526004016116f79493929190613185565b600060405180830381600087803b15801561171157600080fd5b505af1158015611725573d6000803e3d6000fd5b505050505b3399508160a001519850611758565b8051825160405163c0eba3a160e01b81526104a692919060040161307a565b60008151600381111561176d5761176d613042565b03611791578051825160405163c0eba3a160e01b81526104a692919060040161307a565b6001815160038111156117a6576117a6613042565b036118ea576002825160038111156117c0576117c0613042565b141580156117e157506003825160038111156117de576117de613042565b14155b15611805578051825160405163c0eba3a160e01b81526104a692919060040161307a565b6020808201516001600160a01b0316906323b872dd90611827908e018e6128ab565b33868560600151611838919061312a565b6040518463ffffffff1660e01b8152600401611856939291906130e9565b6020604051808303816000875af1158015611875573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611899919061310d565b6118e55760405162461bcd60e51b815260206004820152601a60248201527f5472616e73666572206572633230206f66666572206572726f7200000000000060448201526064016104a6565b611aa2565b6002815160038111156118ff576118ff613042565b148061191d575060038151600381111561191b5761191b613042565b145b15611739576020808201516001600160a01b0316600090815260d2909152604090205460ff1661195f5760405162461bcd60e51b81526004016104a69061313d565b60028151600381111561197457611974613042565b036119f6576020808201516001600160a01b0316906342842e0e9061199b908e018e6128ab565b3384604001516040518463ffffffff1660e01b81526004016119bf939291906130e9565b600060405180830381600087803b1580156119d957600080fd5b505af11580156119ed573d6000803e3d6000fd5b50505050611a8f565b600381516003811115611a0b57611a0b613042565b03611a8f576020808201516001600160a01b03169063f242432a90611a32908e018e6128ab565b33846040015185606001516040518563ffffffff1660e01b8152600401611a5c9493929190613185565b600060405180830381600087803b158015611a7657600080fd5b505af1158015611a8a573d6000803e3d6000fd5b505050505b611a9c60208c018c6128ab565b99503398505b865460ff19166001178755604080516001600160a01b038c811682528b166020820152429160a08e0135918b917fd83bf72c88d7355a2de3c89ca42e86a646abb6fc1bc91613e4e816021bf091c0910160405180910390a450505050505050505050611b0e6001609955565b50565b611b19611ec1565b611b2360006122c5565b565b611b2d611f7b565b60008060005b83811015611d5b5736858583818110611b4e57611b4e612ff4565b9050602002810190611b6091906131c9565b9050611b6f60208201826128ab565b9250336001600160a01b03841614611b9a5760405163203b1cdd60e21b815260040160405180910390fd5b6000611cf16040518060e00160405280866001600160a01b03168152602001848060200190611bc99190612fac565b808060200260200160405190810160405280939291908181526020016000905b82821015611c1557611c0660a08302860136819003810190613026565b81526020019060010190611be9565b5050509183525050602001611c2d6040860186612f64565b808060200260200160405190810160405280939291908181526020016000905b82821015611c7957611c6a60c0830286013681900381019061300a565b81526020019060010190611c4d565b5050505050815260200184606001358152602001846080013581526020018460a001358152602001848060c00190611cb19190612f1e565b8080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250505091525060e0840135611fd4565b600081815260d16020526040808220805461ffff1916610100178155905190975091925060a0840135916001600160a01b038716917fdd003742fb214507783ce004fe55f5ac14f89c6de4a7cd7487e47eb091c6226591a3611d52836131e9565b92505050611b33565b5050506107196001609955565b611d70611ec1565b60005b83811015611e0757828282818110611d8d57611d8d612ff4565b9050602002016020810190611da29190613202565b60cf6000878785818110611db857611db8612ff4565b9050602002016020810190611dcd91906128ab565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905580611dff816131e9565b915050611d73565b507f849bc039c6dbcf9934f2e6d667158c8c6bdd9487a4154c25d0662a293bdd91eb84848484604051611e3d949392919061321f565b60405180910390a150505050565b611e53611ec1565b6001600160a01b038116611eb85760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b60648201526084016104a6565b611b0e816122c5565b6033546001600160a01b03163314611b235760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657260448201526064016104a6565b600054610100900460ff16611f425760405162461bcd60e51b81526004016104a6906132af565b611b23612317565b600054610100900460ff16611f715760405162461bcd60e51b81526004016104a6906132af565b6107198282612347565b600260995403611fcd5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c0060448201526064016104a6565b6002609955565b6000808360200151516001600160401b03811115611ff457611ff46128c8565b60405190808252806020026020018201604052801561201d578160200160208202803683370190505b50905060008460400151516001600160401b0381111561203f5761203f6128c8565b604051908082528060200260200182016040528015612068578160200160208202803683370190505b50905060005b8560200151518110156120ce576120a18660200151828151811061209457612094612ff4565b6020026020010151612388565b8382815181106120b3576120b3612ff4565b60209081029190910101526120c7816131e9565b905061206e565b5060005b85604001515181101561213257612105866040015182815181106120f8576120f8612ff4565b60200260200101516123fa565b82828151811061211757612117612ff4565b602090810291909101015261212b816131e9565b90506120d2565b50604051602001612142906132fa565b604051602081830303815290604052604051602001612160906133c9565b60408051601f198184030181529082905261217e92916020016134a5565b604051602081830303815290604052805190602001208560000151836040516020016121aa91906135ac565b60405160208183030381529060405280519060200120836040516020016121d191906135ac565b60405160208183030381529060405280519060200120886060015189608001518a60a001518a6040516020016122489897969594939291909788526001600160a01b0396909616602088015260408701949094526060860192909252608085015260a084015260c083015260e08201526101000190565b60405160208183030381529060405280519060200120925050505b92915050565b60008061227585612455565b905060006122b98286868080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506124a392505050565b925050505b9392505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff1661233e5760405162461bcd60e51b81526004016104a6906132af565b611b23336122c5565b600054610100900460ff1661236e5760405162461bcd60e51b81526004016104a6906132af565b815160209283012081519190920120606591909155606655565b6000604051602001612399906133c9565b60405160208183030381529060405280519060200120826000015183602001518460400151856060015186608001516040516020016123dd969594939291906135e2565b604051602081830303815290604052805190602001209050919050565b600060405160200161240b906132fa565b60405160208183030381529060405280519060200120826000015183602001518460400151856060015186608001518760a001516040516020016123dd9796959493929190613623565b60006122636124626124c7565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b60008060006124b28585612547565b915091506124bf8161258c565b509392505050565b60006125427f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6124f660655490565b6066546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b600080825160410361257d5760208301516040840151606085015160001a612571878285856126d6565b94509450505050612585565b506000905060025b9250929050565b60008160048111156125a0576125a0613042565b036125a85750565b60018160048111156125bc576125bc613042565b036126095760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e6174757265000000000000000060448201526064016104a6565b600281600481111561261d5761261d613042565b0361266a5760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e6774680060448201526064016104a6565b600381600481111561267e5761267e613042565b03611b0e5760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b60648201526084016104a6565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a083111561270d5750600090506003612791565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015612761573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661278a57600060019250925050612791565b9150600090505b94509492505050565b6001600160a01b0381168114611b0e57600080fd5b80356127ba8161279a565b919050565b8015158114611b0e57600080fd5b600080604083850312156127e057600080fd5b82356127eb8161279a565b915060208301356127fb816127bf565b809150509250929050565b600080828403608081121561281a57600080fd5b83356128258161279a565b92506060601f198201121561283957600080fd5b506020830190509250929050565b60008060006060848603121561285c57600080fd5b83356128678161279a565b925060208401356128778161279a565b915060408401356128878161279a565b809150509250925092565b6000602082840312156128a457600080fd5b5035919050565b6000602082840312156128bd57600080fd5b81356122be8161279a565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b0381118282101715612900576129006128c8565b60405290565b604051601f8201601f191681016001600160401b038111828210171561292e5761292e6128c8565b604052919050565b600082601f83011261294757600080fd5b81356001600160401b03811115612960576129606128c8565b612973601f8201601f1916602001612906565b81815284602083860101111561298857600080fd5b816020850160208301376000918101602001919091529392505050565b600080604083850312156129b857600080fd5b82356001600160401b03808211156129cf57600080fd5b6129db86838701612936565b935060208501359150808211156129f157600080fd5b506129fe85828601612936565b9150509250929050565b600060208284031215612a1a57600080fd5b81356001600160401b03811115612a3057600080fd5b820160e081850312156122be57600080fd5b60008083601f840112612a5457600080fd5b5081356001600160401b03811115612a6b57600080fd5b6020830191508360208260051b850101111561258557600080fd5b60008060208385031215612a9957600080fd5b82356001600160401b03811115612aaf57600080fd5b612abb85828601612a42565b90969095509350505050565b60008060008060408587031215612add57600080fd5b84356001600160401b0380821115612af457600080fd5b612b0088838901612a42565b90965094506020870135915080821115612b1957600080fd5b50612b2687828801612a42565b95989497509550505050565b6001600160401b0381168114611b0e57600080fd5b600060208284031215612b5957600080fd5b81356122be81612b32565b634e487b7160e01b600052601160045260246000fd5b6001600160401b03818116838216019080821115612b9a57612b9a612b64565b5092915050565b8135612bac81612b32565b6001600160401b03811690508154816001600160401b031982161783556020840135612bd781612b32565b6fffffffffffffffff0000000000000000604091821b166fffffffffffffffffffffffffffffffff19831684178117855590850135612c1581612b32565b6001600160c01b0319929092169092179190911760809190911b67ffffffffffffffff60801b1617905550565b60006001600160401b03821115612c5b57612c5b6128c8565b5060051b60200190565b8035600481106127ba57600080fd5b600060a08284031215612c8657600080fd5b60405160a081018181106001600160401b0382111715612ca857612ca86128c8565b604052905080612cb783612c65565b81526020830135612cc78161279a565b806020830152506040830135604082015260608301356060820152608083013560808201525092915050565b600082601f830112612d0457600080fd5b81356020612d19612d1483612c42565b612906565b82815260a09283028501820192828201919087851115612d3857600080fd5b8387015b85811015612d5b57612d4e8982612c74565b8452928401928101612d3c565b5090979650505050505050565b600060c08284031215612d7a57600080fd5b60405160c081018181106001600160401b0382111715612d9c57612d9c6128c8565b604052905080612dab83612c65565b81526020830135612dbb8161279a565b8060208301525060408301356040820152606083013560608201526080830135608082015260a0830135612dee8161279a565b60a0919091015292915050565b600082601f830112612e0c57600080fd5b81356020612e1c612d1483612c42565b82815260c09283028501820192828201919087851115612e3b57600080fd5b8387015b85811015612d5b57612e518982612d68565b8452928401928101612e3f565b600060e08236031215612e7057600080fd5b612e786128de565b612e81836127af565b815260208301356001600160401b0380821115612e9d57600080fd5b612ea936838701612cf3565b60208401526040850135915080821115612ec257600080fd5b612ece36838701612dfb565b6040840152606085013560608401526080850135608084015260a085013560a084015260c0850135915080821115612f0557600080fd5b50612f1236828601612936565b60c08301525092915050565b6000808335601e19843603018112612f3557600080fd5b8301803591506001600160401b03821115612f4f57600080fd5b60200191503681900382131561258557600080fd5b6000808335601e19843603018112612f7b57600080fd5b8301803591506001600160401b03821115612f9557600080fd5b602001915060c08102360382131561258557600080fd5b6000808335601e19843603018112612fc357600080fd5b8301803591506001600160401b03821115612fdd57600080fd5b602001915060a08102360382131561258557600080fd5b634e487b7160e01b600052603260045260246000fd5b600060c0828403121561301c57600080fd5b6122be8383612d68565b600060a0828403121561303857600080fd5b6122be8383612c74565b634e487b7160e01b600052602160045260246000fd5b6004811061307657634e487b7160e01b600052602160045260246000fd5b9052565b604081016130888285613058565b6122be6020830184613058565b60008160001904831182151516156130af576130af612b64565b500290565b6000826130d157634e487b7160e01b600052601260045260246000fd5b500490565b8082018082111561226357612263612b64565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60006020828403121561311f57600080fd5b81516122be816127bf565b8181038181111561226357612263612b64565b60208082526028908201527f4552524f523a205468697320636f6c6c656374696f6e20686173206e6f2070656040820152673936b4b9b9b4b7b760c11b606082015260800190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a0608082018190526003908201526203078360ec1b60c082015260e00190565b6000823560fe198336030181126131df57600080fd5b9190910192915050565b6000600182016131fb576131fb612b64565b5060010190565b60006020828403121561321457600080fd5b81356122be816127bf565b6040808252810184905260008560608301825b878110156132625782356132458161279a565b6001600160a01b0316825260209283019290910190600101613232565b5083810360208581019190915285825291508590820160005b868110156132a257823561328e816127bf565b15158252918301919083019060010161327b565b5098975050505050505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b71086dedce6d2c8cae4c2e8d2dedc92e8cada560731b81526e1d5a5b9d0e081a5d195b551e5c194b608a1b60128201526d1859191c995cdcc81d1bdad95b8b60921b60218201527f75696e74323536206964656e7469666965724f7243726974657269612c000000602f820152731d5a5b9d0c8d4d881cdd185c9d105b5bdd5b9d0b60621b604c820152711d5a5b9d0c8d4d88195b99105b5bdd5b9d0b60721b6060820152701859191c995cdcc81c9958da5c1a595b9d607a1b6072820152602960f81b608382015260840190565b6909ecccccae492e8cada560b31b81526e1d5a5b9d0e081a5d195b551e5c194b608a1b600a8201526d1859191c995cdcc81d1bdad95b8b60921b60198201527f75696e74323536206964656e7469666965724f7243726974657269612c0000006027820152731d5a5b9d0c8d4d881cdd185c9d105b5bdd5b9d0b60621b6044820152701d5a5b9d0c8d4d88195b99105b5bdd5b9d607a1b6058820152602960f81b6069820152606a0190565b6000815160005b81811015613496576020818501810151868301520161347c565b50600093019283525090919050565b6f09ee4c8cae486dedae0dedccadce8e6560831b81526f1859191c995cdcc81bd999995c995c8b60821b60108201527113d999995c925d195b56d7481bd999995c8b60721b60208201527f436f6e73696465726174696f6e4974656d5b5d20636f6e73696465726174696f6032820152611b8b60f21b6052820152711d5a5b9d0c8d4d881cdd185c9d151a5b594b60721b60548201526f1d5a5b9d0c8d4d88195b99151a5b594b60821b60668201526c1d5a5b9d0c8d4d881cd85b1d0b609a1b60768201526e3ab4b73a191a9b1031b7bab73a32b960891b6083820152602960f81b609282015260006135a461359e6093840186613475565b84613475565b949350505050565b815160009082906020808601845b838110156135d6578151855293820193908201906001016135ba565b50929695505050505050565b86815260c081016135f66020830188613058565b6001600160a01b039590951660408201526060810193909352608083019190915260a09091015292915050565b87815260e081016136376020830189613058565b6001600160a01b0396871660408301526060820195909552608081019390935260a083019190915290921660c0909201919091529291505056fea26469706673582212208bc24d7f7527598eb591e0405d04f002de12ef8dace2a3f9fc2e7b812ff90b7064736f6c63430008100033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.