Contract 0x12190b5dff7bfd7fa79439ce66dfab15b7c3aabf

Txn Hash Method
Block
From
To
Value [Txn Fee]
0x6decda85595b2bd6fb587cf8ba8cf3133812f384d2d9a332c1bbaaf3a311224c0x60a0604067582162023-02-01 6:43:5458 days 11 hrs ago0x6be5e7da4ad8523f9c622544a938f344a1f62cf5 IN  Create: Port0 CRO25.726940
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading
This contract may be a proxy contract. Click on More Options and select Is this a proxy? to confirm and enable the "Read as Proxy" & "Write as Proxy" tabs.

Contract Source Code Verified (Exact Match)

Contract Name:
Port

Compiler Version
v0.8.4+commit.c7e474f2

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 40 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";
import "../utils/ContextUpgradeable.sol";
import "../utils/StringsUpgradeable.sol";
import "../utils/introspection/ERC165Upgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControlUpgradeable is Initializable, ContextUpgradeable, IAccessControlUpgradeable, ERC165Upgradeable {
    function __AccessControl_init() internal onlyInitializing {
    }

    function __AccessControl_init_unchained() internal onlyInitializing {
    }
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlUpgradeable).interfaceId || super.supportsInterface(interfaceId);
    }

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view virtual override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @dev Revert with a standard message if `_msgSender()` is missing `role`.
     * Overriding this function changes the behavior of the {onlyRole} modifier.
     *
     * Format of the revert message is described in {_checkRole}.
     *
     * _Available since v4.6._
     */
    function _checkRole(bytes32 role) internal view virtual {
        _checkRole(role, _msgSender());
    }

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        StringsUpgradeable.toHexString(account),
                        " is missing role ",
                        StringsUpgradeable.toHexString(uint256(role), 32)
                    )
                )
            );
        }
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleGranted} event.
     */
    function grantRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     *
     * May emit a {RoleRevoked} event.
     */
    function revokeRole(bytes32 role, address account) public virtual override onlyRole(getRoleAdmin(role)) {
        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been revoked `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     *
     * May emit a {RoleRevoked} event.
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * May emit a {RoleGranted} event.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * NOTE: This function is deprecated in favor of {_grantRole}.
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        bytes32 previousAdminRole = getRoleAdmin(role);
        _roles[role].adminRole = adminRole;
        emit RoleAdminChanged(role, previousAdminRole, adminRole);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleGranted} event.
     */
    function _grantRole(bytes32 role, address account) internal virtual {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * Internal function without access restriction.
     *
     * May emit a {RoleRevoked} event.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }

    /**
     * @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 2 of 40 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {AccessControl-_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) external view returns (bool);

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {AccessControl-_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) external;

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) external;
}

File 3 of 40 : 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 4 of 40 : draft-IERC1822Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (interfaces/draft-IERC1822.sol)

pragma solidity ^0.8.0;

/**
 * @dev ERC1822: Universal Upgradeable Proxy Standard (UUPS) documents a method for upgradeability through a simplified
 * proxy whose upgrades are fully controlled by the current implementation.
 */
interface IERC1822ProxiableUpgradeable {
    /**
     * @dev Returns the storage slot that the proxiable contract assumes is being used to store the implementation
     * address.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy.
     */
    function proxiableUUID() external view returns (bytes32);
}

File 5 of 40 : IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

import "../token/ERC1155/IERC1155ReceiverUpgradeable.sol";

File 6 of 40 : IBeaconUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (proxy/beacon/IBeacon.sol)

pragma solidity ^0.8.0;

/**
 * @dev This is the interface that {BeaconProxy} expects of its beacon.
 */
interface IBeaconUpgradeable {
    /**
     * @dev Must return an address that can be used as a delegate call target.
     *
     * {BeaconProxy} will check that this address is a contract.
     */
    function implementation() external view returns (address);
}

File 7 of 40 : ERC1967UpgradeUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (proxy/ERC1967/ERC1967Upgrade.sol)

pragma solidity ^0.8.2;

import "../beacon/IBeaconUpgradeable.sol";
import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/StorageSlotUpgradeable.sol";
import "../utils/Initializable.sol";

/**
 * @dev This abstract contract provides getters and event emitting update functions for
 * https://eips.ethereum.org/EIPS/eip-1967[EIP1967] slots.
 *
 * _Available since v4.1._
 *
 * @custom:oz-upgrades-unsafe-allow delegatecall
 */
abstract contract ERC1967UpgradeUpgradeable is Initializable {
    function __ERC1967Upgrade_init() internal onlyInitializing {
    }

    function __ERC1967Upgrade_init_unchained() internal onlyInitializing {
    }
    // This is the keccak-256 hash of "eip1967.proxy.rollback" subtracted by 1
    bytes32 private constant _ROLLBACK_SLOT = 0x4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd9143;

    /**
     * @dev Storage slot with the address of the current implementation.
     * This is the keccak-256 hash of "eip1967.proxy.implementation" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;

    /**
     * @dev Emitted when the implementation is upgraded.
     */
    event Upgraded(address indexed implementation);

    /**
     * @dev Returns the current implementation address.
     */
    function _getImplementation() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 implementation slot.
     */
    function _setImplementation(address newImplementation) private {
        require(AddressUpgradeable.isContract(newImplementation), "ERC1967: new implementation is not a contract");
        StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
    }

    /**
     * @dev Perform implementation upgrade
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeTo(address newImplementation) internal {
        _setImplementation(newImplementation);
        emit Upgraded(newImplementation);
    }

    /**
     * @dev Perform implementation upgrade with additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCall(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        _upgradeTo(newImplementation);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(newImplementation, data);
        }
    }

    /**
     * @dev Perform implementation upgrade with security checks for UUPS proxies, and additional setup call.
     *
     * Emits an {Upgraded} event.
     */
    function _upgradeToAndCallUUPS(
        address newImplementation,
        bytes memory data,
        bool forceCall
    ) internal {
        // Upgrades from old implementations will perform a rollback test. This test requires the new
        // implementation to upgrade back to the old, non-ERC1822 compliant, implementation. Removing
        // this special case will break upgrade paths from old UUPS implementation to new ones.
        if (StorageSlotUpgradeable.getBooleanSlot(_ROLLBACK_SLOT).value) {
            _setImplementation(newImplementation);
        } else {
            try IERC1822ProxiableUpgradeable(newImplementation).proxiableUUID() returns (bytes32 slot) {
                require(slot == _IMPLEMENTATION_SLOT, "ERC1967Upgrade: unsupported proxiableUUID");
            } catch {
                revert("ERC1967Upgrade: new implementation is not UUPS");
            }
            _upgradeToAndCall(newImplementation, data, forceCall);
        }
    }

    /**
     * @dev Storage slot with the admin of the contract.
     * This is the keccak-256 hash of "eip1967.proxy.admin" subtracted by 1, and is
     * validated in the constructor.
     */
    bytes32 internal constant _ADMIN_SLOT = 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103;

    /**
     * @dev Emitted when the admin account has changed.
     */
    event AdminChanged(address previousAdmin, address newAdmin);

    /**
     * @dev Returns the current admin.
     */
    function _getAdmin() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value;
    }

    /**
     * @dev Stores a new address in the EIP1967 admin slot.
     */
    function _setAdmin(address newAdmin) private {
        require(newAdmin != address(0), "ERC1967: new admin is the zero address");
        StorageSlotUpgradeable.getAddressSlot(_ADMIN_SLOT).value = newAdmin;
    }

    /**
     * @dev Changes the admin of the proxy.
     *
     * Emits an {AdminChanged} event.
     */
    function _changeAdmin(address newAdmin) internal {
        emit AdminChanged(_getAdmin(), newAdmin);
        _setAdmin(newAdmin);
    }

    /**
     * @dev The storage slot of the UpgradeableBeacon contract which defines the implementation for this proxy.
     * This is bytes32(uint256(keccak256('eip1967.proxy.beacon')) - 1)) and is validated in the constructor.
     */
    bytes32 internal constant _BEACON_SLOT = 0xa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6cb3582b35133d50;

    /**
     * @dev Emitted when the beacon is upgraded.
     */
    event BeaconUpgraded(address indexed beacon);

    /**
     * @dev Returns the current beacon.
     */
    function _getBeacon() internal view returns (address) {
        return StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value;
    }

    /**
     * @dev Stores a new beacon in the EIP1967 beacon slot.
     */
    function _setBeacon(address newBeacon) private {
        require(AddressUpgradeable.isContract(newBeacon), "ERC1967: new beacon is not a contract");
        require(
            AddressUpgradeable.isContract(IBeaconUpgradeable(newBeacon).implementation()),
            "ERC1967: beacon implementation is not a contract"
        );
        StorageSlotUpgradeable.getAddressSlot(_BEACON_SLOT).value = newBeacon;
    }

    /**
     * @dev Perform beacon upgrade with additional setup call. Note: This upgrades the address of the beacon, it does
     * not upgrade the implementation contained in the beacon (see {UpgradeableBeacon-_setImplementation} for that).
     *
     * Emits a {BeaconUpgraded} event.
     */
    function _upgradeBeaconToAndCall(
        address newBeacon,
        bytes memory data,
        bool forceCall
    ) internal {
        _setBeacon(newBeacon);
        emit BeaconUpgraded(newBeacon);
        if (data.length > 0 || forceCall) {
            _functionDelegateCall(IBeaconUpgradeable(newBeacon).implementation(), data);
        }
    }

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.4._
     */
    function _functionDelegateCall(address target, bytes memory data) private returns (bytes memory) {
        require(AddressUpgradeable.isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return AddressUpgradeable.verifyCallResult(success, returndata, "Address: low-level delegate call failed");
    }

    /**
     * @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 8 of 40 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (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 Internal function that returns the initialized version. Returns `_initialized`
     */
    function _getInitializedVersion() internal view returns (uint8) {
        return _initialized;
    }

    /**
     * @dev Internal function that returns the initialized version. Returns `_initializing`
     */
    function _isInitializing() internal view returns (bool) {
        return _initializing;
    }
}

File 9 of 40 : UUPSUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (proxy/utils/UUPSUpgradeable.sol)

pragma solidity ^0.8.0;

import "../../interfaces/draft-IERC1822Upgradeable.sol";
import "../ERC1967/ERC1967UpgradeUpgradeable.sol";
import "./Initializable.sol";

/**
 * @dev An upgradeability mechanism designed for UUPS proxies. The functions included here can perform an upgrade of an
 * {ERC1967Proxy}, when this contract is set as the implementation behind such a proxy.
 *
 * A security mechanism ensures that an upgrade does not turn off upgradeability accidentally, although this risk is
 * reinstated if the upgrade retains upgradeability but removes the security mechanism, e.g. by replacing
 * `UUPSUpgradeable` with a custom implementation of upgrades.
 *
 * The {_authorizeUpgrade} function must be overridden to include access restriction to the upgrade mechanism.
 *
 * _Available since v4.1._
 */
abstract contract UUPSUpgradeable is Initializable, IERC1822ProxiableUpgradeable, ERC1967UpgradeUpgradeable {
    function __UUPSUpgradeable_init() internal onlyInitializing {
    }

    function __UUPSUpgradeable_init_unchained() internal onlyInitializing {
    }
    /// @custom:oz-upgrades-unsafe-allow state-variable-immutable state-variable-assignment
    address private immutable __self = address(this);

    /**
     * @dev Check that the execution is being performed through a delegatecall call and that the execution context is
     * a proxy contract with an implementation (as defined in ERC1967) pointing to self. This should only be the case
     * for UUPS and transparent proxies that are using the current contract as their implementation. Execution of a
     * function through ERC1167 minimal proxies (clones) would not normally pass this test, but is not guaranteed to
     * fail.
     */
    modifier onlyProxy() {
        require(address(this) != __self, "Function must be called through delegatecall");
        require(_getImplementation() == __self, "Function must be called through active proxy");
        _;
    }

    /**
     * @dev Check that the execution is not being performed through a delegate call. This allows a function to be
     * callable on the implementing contract but not through proxies.
     */
    modifier notDelegated() {
        require(address(this) == __self, "UUPSUpgradeable: must not be called through delegatecall");
        _;
    }

    /**
     * @dev Implementation of the ERC1822 {proxiableUUID} function. This returns the storage slot used by the
     * implementation. It is used to validate the implementation's compatibility when performing an upgrade.
     *
     * IMPORTANT: A proxy pointing at a proxiable contract should not be considered proxiable itself, because this risks
     * bricking a proxy that upgrades to it, by delegating to itself until out of gas. Thus it is critical that this
     * function revert if invoked through a proxy. This is guaranteed by the `notDelegated` modifier.
     */
    function proxiableUUID() external view virtual override notDelegated returns (bytes32) {
        return _IMPLEMENTATION_SLOT;
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeTo(address newImplementation) external virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, new bytes(0), false);
    }

    /**
     * @dev Upgrade the implementation of the proxy to `newImplementation`, and subsequently execute the function call
     * encoded in `data`.
     *
     * Calls {_authorizeUpgrade}.
     *
     * Emits an {Upgraded} event.
     */
    function upgradeToAndCall(address newImplementation, bytes memory data) external payable virtual onlyProxy {
        _authorizeUpgrade(newImplementation);
        _upgradeToAndCallUUPS(newImplementation, data, true);
    }

    /**
     * @dev Function that should revert when `msg.sender` is not authorized to upgrade the contract. Called by
     * {upgradeTo} and {upgradeToAndCall}.
     *
     * Normally, this function will use an xref:access.adoc[access control] modifier such as {Ownable-onlyOwner}.
     *
     * ```solidity
     * function _authorizeUpgrade(address) internal override onlyOwner {}
     * ```
     */
    function _authorizeUpgrade(address newImplementation) internal virtual;

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

File 10 of 40 : PullPaymentUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (security/PullPayment.sol)

pragma solidity ^0.8.0;

import "../utils/escrow/EscrowUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev Simple implementation of a
 * https://consensys.github.io/smart-contract-best-practices/development-recommendations/general/external-calls/#favor-pull-over-push-for-external-calls[pull-payment]
 * strategy, where the paying contract doesn't interact directly with the
 * receiver account, which must withdraw its payments itself.
 *
 * Pull-payments are often considered the best practice when it comes to sending
 * Ether, security-wise. It prevents recipients from blocking execution, and
 * eliminates reentrancy concerns.
 *
 * 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].
 *
 * To use, derive from the `PullPayment` contract, and use {_asyncTransfer}
 * instead of Solidity's `transfer` function. Payees can query their due
 * payments with {payments}, and retrieve them with {withdrawPayments}.
 *
 * @custom:storage-size 51
 */
abstract contract PullPaymentUpgradeable is Initializable {
    EscrowUpgradeable private _escrow;

    function __PullPayment_init() internal onlyInitializing {
        __PullPayment_init_unchained();
    }

    function __PullPayment_init_unchained() internal onlyInitializing {
        _escrow = new EscrowUpgradeable();
        _escrow.initialize();
    }

    /**
     * @dev Withdraw accumulated payments, forwarding all gas to the recipient.
     *
     * Note that _any_ account can call this function, not just the `payee`.
     * This means that contracts unaware of the `PullPayment` protocol can still
     * receive funds this way, by having a separate account call
     * {withdrawPayments}.
     *
     * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
     * Make sure you trust the recipient, or are either following the
     * checks-effects-interactions pattern or using {ReentrancyGuard}.
     *
     * @param payee Whose payments will be withdrawn.
     *
     * Causes the `escrow` to emit a {Withdrawn} event.
     */
    function withdrawPayments(address payable payee) public virtual {
        _escrow.withdraw(payee);
    }

    /**
     * @dev Returns the payments owed to an address.
     * @param dest The creditor's address.
     */
    function payments(address dest) public view returns (uint256) {
        return _escrow.depositsOf(dest);
    }

    /**
     * @dev Called by the payer to store the sent amount as credit to be pulled.
     * Funds sent in this way are stored in an intermediate {Escrow} contract, so
     * there is no danger of them being spent before withdrawal.
     *
     * @param dest The destination address of the funds.
     * @param amount The amount to transfer.
     *
     * Causes the `escrow` to emit a {Deposited} event.
     */
    function _asyncTransfer(address dest, uint256 amount) internal virtual {
        _escrow.deposit{value: amount}(dest);
    }

    /**
     * @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 11 of 40 : 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 12 of 40 : IERC1155ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC1155/IERC1155Receiver.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev _Available since v3.1._
 */
interface IERC1155ReceiverUpgradeable is IERC165Upgradeable {
    /**
     * @dev Handles the receipt of a single ERC1155 token type. This function is
     * called at the end of a `safeTransferFrom` after the balance has been updated.
     *
     * NOTE: To accept the transfer, this must return
     * `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
     * (i.e. 0xf23a6e61, or its own function selector).
     *
     * @param operator The address which initiated the transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param id The ID of the token being transferred
     * @param value The amount of tokens being transferred
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
     */
    function onERC1155Received(
        address operator,
        address from,
        uint256 id,
        uint256 value,
        bytes calldata data
    ) external returns (bytes4);

    /**
     * @dev Handles the receipt of a multiple ERC1155 token types. This function
     * is called at the end of a `safeBatchTransferFrom` after the balances have
     * been updated.
     *
     * NOTE: To accept the transfer(s), this must return
     * `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
     * (i.e. 0xbc197c81, or its own function selector).
     *
     * @param operator The address which initiated the batch transfer (i.e. msg.sender)
     * @param from The address which previously owned the token
     * @param ids An array containing ids of each token being transferred (order and length must match values array)
     * @param values An array containing amounts of each token being transferred (order and length must match ids array)
     * @param data Additional data with no specified format
     * @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
     */
    function onERC1155BatchReceived(
        address operator,
        address from,
        uint256[] calldata ids,
        uint256[] calldata values,
        bytes calldata data
    ) external returns (bytes4);
}

File 13 of 40 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;

import "./IERC20Upgradeable.sol";
import "./extensions/IERC20MetadataUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the {IERC20} interface.
 *
 * This implementation is agnostic to the way tokens are created. This means
 * that a supply mechanism has to be added in a derived contract using {_mint}.
 * For a generic mechanism see {ERC20PresetMinterPauser}.
 *
 * TIP: For a detailed writeup see our guide
 * https://forum.openzeppelin.com/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin Contracts guidelines: functions revert
 * instead returning `false` on failure. This behavior is nonetheless
 * conventional and does not conflict with the expectations of ERC20
 * applications.
 *
 * Additionally, an {Approval} event is emitted on calls to {transferFrom}.
 * This allows applications to reconstruct the allowance for all accounts just
 * by listening to said events. Other implementations of the EIP may not emit
 * these events, as it isn't required by the specification.
 *
 * Finally, the non-standard {decreaseAllowance} and {increaseAllowance}
 * functions have been added to mitigate the well-known issues around setting
 * allowances. See {IERC20-approve}.
 */
contract ERC20Upgradeable is Initializable, ContextUpgradeable, IERC20Upgradeable, IERC20MetadataUpgradeable {
    mapping(address => uint256) private _balances;

    mapping(address => mapping(address => uint256)) private _allowances;

    uint256 private _totalSupply;

    string private _name;
    string private _symbol;

    /**
     * @dev Sets the values for {name} and {symbol}.
     *
     * The default value of {decimals} is 18. To select a different value for
     * {decimals} you should overload it.
     *
     * All two of these values are immutable: they can only be set once during
     * construction.
     */
    function __ERC20_init(string memory name_, string memory symbol_) internal onlyInitializing {
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
        _name = name_;
        _symbol = symbol_;
    }

    /**
     * @dev Returns the name of the token.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev Returns the symbol of the token, usually a shorter version of the
     * name.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the number of decimals used to get its user representation.
     * For example, if `decimals` equals `2`, a balance of `505` tokens should
     * be displayed to a user as `5.05` (`505 / 10 ** 2`).
     *
     * Tokens usually opt for a value of 18, imitating the relationship between
     * Ether and Wei. This is the value {ERC20} uses, unless this function is
     * overridden;
     *
     * NOTE: This information is only used for _display_ purposes: it in
     * no way affects any of the arithmetic of the contract, including
     * {IERC20-balanceOf} and {IERC20-transfer}.
     */
    function decimals() public view virtual override returns (uint8) {
        return 18;
    }

    /**
     * @dev See {IERC20-totalSupply}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        return _totalSupply;
    }

    /**
     * @dev See {IERC20-balanceOf}.
     */
    function balanceOf(address account) public view virtual override returns (uint256) {
        return _balances[account];
    }

    /**
     * @dev See {IERC20-transfer}.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address to, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _transfer(owner, to, amount);
        return true;
    }

    /**
     * @dev See {IERC20-allowance}.
     */
    function allowance(address owner, address spender) public view virtual override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @dev See {IERC20-approve}.
     *
     * NOTE: If `amount` is the maximum `uint256`, the allowance is not updated on
     * `transferFrom`. This is semantically equivalent to an infinite approval.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, amount);
        return true;
    }

    /**
     * @dev See {IERC20-transferFrom}.
     *
     * Emits an {Approval} event indicating the updated allowance. This is not
     * required by the EIP. See the note at the beginning of {ERC20}.
     *
     * NOTE: Does not update the allowance if the current allowance
     * is the maximum `uint256`.
     *
     * Requirements:
     *
     * - `from` and `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     * - the caller must have allowance for ``from``'s tokens of at least
     * `amount`.
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public virtual override returns (bool) {
        address spender = _msgSender();
        _spendAllowance(from, spender, amount);
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @dev Atomically increases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function increaseAllowance(address spender, uint256 addedValue) public virtual returns (bool) {
        address owner = _msgSender();
        _approve(owner, spender, allowance(owner, spender) + addedValue);
        return true;
    }

    /**
     * @dev Atomically decreases the allowance granted to `spender` by the caller.
     *
     * This is an alternative to {approve} that can be used as a mitigation for
     * problems described in {IERC20-approve}.
     *
     * Emits an {Approval} event indicating the updated allowance.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `spender` must have allowance for the caller of at least
     * `subtractedValue`.
     */
    function decreaseAllowance(address spender, uint256 subtractedValue) public virtual returns (bool) {
        address owner = _msgSender();
        uint256 currentAllowance = allowance(owner, spender);
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        unchecked {
            _approve(owner, spender, currentAllowance - subtractedValue);
        }

        return true;
    }

    /**
     * @dev Moves `amount` of tokens from `from` to `to`.
     *
     * This internal function is equivalent to {transfer}, and can be used to
     * e.g. implement automatic token fees, slashing mechanisms, etc.
     *
     * Emits a {Transfer} event.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `from` must have a balance of at least `amount`.
     */
    function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(from, to, amount);

        uint256 fromBalance = _balances[from];
        require(fromBalance >= amount, "ERC20: transfer amount exceeds balance");
        unchecked {
            _balances[from] = fromBalance - amount;
            // Overflow not possible: the sum of all balances is capped by totalSupply, and the sum is preserved by
            // decrementing then incrementing.
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);

        _afterTokenTransfer(from, to, amount);
    }

    /** @dev Creates `amount` tokens and assigns them to `account`, increasing
     * the total supply.
     *
     * Emits a {Transfer} event with `from` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     */
    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        _beforeTokenTransfer(address(0), account, amount);

        _totalSupply += amount;
        unchecked {
            // Overflow not possible: balance + amount is at most totalSupply + amount, which is checked above.
            _balances[account] += amount;
        }
        emit Transfer(address(0), account, amount);

        _afterTokenTransfer(address(0), account, amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, reducing the
     * total supply.
     *
     * Emits a {Transfer} event with `to` set to the zero address.
     *
     * Requirements:
     *
     * - `account` cannot be the zero address.
     * - `account` must have at least `amount` tokens.
     */
    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");

        _beforeTokenTransfer(account, address(0), amount);

        uint256 accountBalance = _balances[account];
        require(accountBalance >= amount, "ERC20: burn amount exceeds balance");
        unchecked {
            _balances[account] = accountBalance - amount;
            // Overflow not possible: amount <= accountBalance <= totalSupply.
            _totalSupply -= amount;
        }

        emit Transfer(account, address(0), amount);

        _afterTokenTransfer(account, address(0), amount);
    }

    /**
     * @dev Sets `amount` as the allowance of `spender` over the `owner` s tokens.
     *
     * This internal function is equivalent to `approve`, and can be used to
     * e.g. set automatic allowances for certain subsystems, etc.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `owner` cannot be the zero address.
     * - `spender` cannot be the zero address.
     */
    function _approve(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        _allowances[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    /**
     * @dev Updates `owner` s allowance for `spender` based on spent `amount`.
     *
     * Does not update the allowance amount in case of infinite allowance.
     * Revert if not enough allowance is available.
     *
     * Might emit an {Approval} event.
     */
    function _spendAllowance(
        address owner,
        address spender,
        uint256 amount
    ) internal virtual {
        uint256 currentAllowance = allowance(owner, spender);
        if (currentAllowance != type(uint256).max) {
            require(currentAllowance >= amount, "ERC20: insufficient allowance");
            unchecked {
                _approve(owner, spender, currentAllowance - amount);
            }
        }
    }

    /**
     * @dev Hook that is called before any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * will be transferred to `to`.
     * - when `from` is zero, `amount` tokens will be minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens will be burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

    /**
     * @dev Hook that is called after any transfer of tokens. This includes
     * minting and burning.
     *
     * Calling conditions:
     *
     * - when `from` and `to` are both non-zero, `amount` of ``from``'s tokens
     * has been transferred to `to`.
     * - when `from` is zero, `amount` tokens have been minted for `to`.
     * - when `to` is zero, `amount` of ``from``'s tokens have been burned.
     * - `from` and `to` are never both zero.
     *
     * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
     */
    function _afterTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual {}

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

File 14 of 40 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/extensions/IERC20Metadata.sol)

pragma solidity ^0.8.0;

import "../IERC20Upgradeable.sol";

/**
 * @dev Interface for the optional metadata functions from the ERC20 standard.
 *
 * _Available since v4.1._
 */
interface IERC20MetadataUpgradeable is IERC20Upgradeable {
    /**
     * @dev Returns the name of the token.
     */
    function name() external view returns (string memory);

    /**
     * @dev Returns the symbol of the token.
     */
    function symbol() external view returns (string memory);

    /**
     * @dev Returns the decimals places of the token.
     */
    function decimals() external view returns (uint8);
}

File 15 of 40 : 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 16 of 40 : 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 17 of 40 : 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 18 of 40 : CountersUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
 * of elements in a mapping, issuing ERC721 ids, or counting request ids.
 *
 * Include with `using Counters for Counters.Counter;`
 */
library CountersUpgradeable {
    struct Counter {
        // This variable should never be directly accessed by users of the library: interactions must be restricted to
        // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
        // this feature: see https://github.com/ethereum/solidity/issues/4637
        uint256 _value; // default: 0
    }

    function current(Counter storage counter) internal view returns (uint256) {
        return counter._value;
    }

    function increment(Counter storage counter) internal {
        unchecked {
            counter._value += 1;
        }
    }

    function decrement(Counter storage counter) internal {
        uint256 value = counter._value;
        require(value > 0, "Counter: decrement overflow");
        unchecked {
            counter._value = value - 1;
        }
    }

    function reset(Counter storage counter) internal {
        counter._value = 0;
    }
}

File 19 of 40 : EscrowUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/escrow/Escrow.sol)

pragma solidity ^0.8.0;

import "../../access/OwnableUpgradeable.sol";
import "../AddressUpgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @title Escrow
 * @dev Base escrow contract, holds funds designated for a payee until they
 * withdraw them.
 *
 * Intended usage: This contract (and derived escrow contracts) should be a
 * standalone contract, that only interacts with the contract that instantiated
 * it. That way, it is guaranteed that all Ether will be handled according to
 * the `Escrow` rules, and there is no need to check for payable functions or
 * transfers in the inheritance tree. The contract that uses the escrow as its
 * payment method should be its owner, and provide public methods redirecting
 * to the escrow's deposit and withdraw.
 */
contract EscrowUpgradeable is Initializable, OwnableUpgradeable {
    function __Escrow_init() internal onlyInitializing {
        __Ownable_init_unchained();
    }

    function __Escrow_init_unchained() internal onlyInitializing {
    }
    function initialize() public virtual initializer {
        __Escrow_init();
    }
    using AddressUpgradeable for address payable;

    event Deposited(address indexed payee, uint256 weiAmount);
    event Withdrawn(address indexed payee, uint256 weiAmount);

    mapping(address => uint256) private _deposits;

    function depositsOf(address payee) public view returns (uint256) {
        return _deposits[payee];
    }

    /**
     * @dev Stores the sent amount as credit to be withdrawn.
     * @param payee The destination address of the funds.
     *
     * Emits a {Deposited} event.
     */
    function deposit(address payee) public payable virtual onlyOwner {
        uint256 amount = msg.value;
        _deposits[payee] += amount;
        emit Deposited(payee, amount);
    }

    /**
     * @dev Withdraw accumulated balance for a payee, forwarding all gas to the
     * recipient.
     *
     * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
     * Make sure you trust the recipient, or are either following the
     * checks-effects-interactions pattern or using {ReentrancyGuard}.
     *
     * @param payee The address whose funds will be withdrawn and transferred to.
     *
     * Emits a {Withdrawn} event.
     */
    function withdraw(address payable payee) public virtual onlyOwner {
        uint256 payment = _deposits[payee];

        _deposits[payee] = 0;

        payee.sendValue(payment);

        emit Withdrawn(payee, payment);
    }

    /**
     * @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 20 of 40 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC165} interface.
 *
 * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
 * for the additional interface id that will be supported. For example:
 *
 * ```solidity
 * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
 *     return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
 * }
 * ```
 *
 * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
 */
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
    function __ERC165_init() internal onlyInitializing {
    }

    function __ERC165_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }

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

File 21 of 40 : 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 22 of 40 : 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 23 of 40 : StorageSlotUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/StorageSlot.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for reading and writing primitive types to specific storage slots.
 *
 * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts.
 * This library helps with reading and writing to such slots without the need for inline assembly.
 *
 * The functions in this library return Slot structs that contain a `value` member that can be used to read or write.
 *
 * Example usage to set ERC1967 implementation slot:
 * ```
 * contract ERC1967 {
 *     bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc;
 *
 *     function _getImplementation() internal view returns (address) {
 *         return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value;
 *     }
 *
 *     function _setImplementation(address newImplementation) internal {
 *         require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract");
 *         StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation;
 *     }
 * }
 * ```
 *
 * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._
 */
library StorageSlotUpgradeable {
    struct AddressSlot {
        address value;
    }

    struct BooleanSlot {
        bool value;
    }

    struct Bytes32Slot {
        bytes32 value;
    }

    struct Uint256Slot {
        uint256 value;
    }

    /**
     * @dev Returns an `AddressSlot` with member `value` located at `slot`.
     */
    function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `BooleanSlot` with member `value` located at `slot`.
     */
    function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Bytes32Slot` with member `value` located at `slot`.
     */
    function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }

    /**
     * @dev Returns an `Uint256Slot` with member `value` located at `slot`.
     */
    function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) {
        /// @solidity memory-safe-assembly
        assembly {
            r.slot := slot
        }
    }
}

File 24 of 40 : 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 25 of 40 : IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Interface for the NFT Royalty Standard.
 *
 * A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
 * support for royalty payments across all NFT marketplaces and ecosystem participants.
 *
 * _Available since v4.5._
 */
interface IERC2981 is IERC165 {
    /**
     * @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
     * exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice)
        external
        view
        returns (address receiver, uint256 royaltyAmount);
}

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

pragma solidity ^0.8.0;

import "../../utils/introspection/IERC165.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 IERC1155 is IERC165 {
    /**
     * @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 27 of 40 : IERC20.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 IERC20 {
    /**
     * @dev Emitted when `value` tokens are moved from one account (`from`) to
     * another (`to`).
     *
     * Note that `value` may be zero.
     */
    event Transfer(address indexed from, address indexed to, uint256 value);

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

    /**
     * @dev Returns the 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 28 of 40 : IERC721.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 29 of 40 : ERC165Checker.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/introspection/ERC165Checker.sol)

pragma solidity ^0.8.0;

import "./IERC165.sol";

/**
 * @dev Library used to query support of an interface declared via {IERC165}.
 *
 * Note that these functions return the actual result of the query: they do not
 * `revert` if an interface is not supported. It is up to the caller to decide
 * what to do in these cases.
 */
library ERC165Checker {
    // As per the EIP-165 spec, no interface should ever match 0xffffffff
    bytes4 private constant _INTERFACE_ID_INVALID = 0xffffffff;

    /**
     * @dev Returns true if `account` supports the {IERC165} interface.
     */
    function supportsERC165(address account) internal view returns (bool) {
        // Any contract that implements ERC165 must explicitly indicate support of
        // InterfaceId_ERC165 and explicitly indicate non-support of InterfaceId_Invalid
        return
            supportsERC165InterfaceUnchecked(account, type(IERC165).interfaceId) &&
            !supportsERC165InterfaceUnchecked(account, _INTERFACE_ID_INVALID);
    }

    /**
     * @dev Returns true if `account` supports the interface defined by
     * `interfaceId`. Support for {IERC165} itself is queried automatically.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsInterface(address account, bytes4 interfaceId) internal view returns (bool) {
        // query support of both ERC165 as per the spec and support of _interfaceId
        return supportsERC165(account) && supportsERC165InterfaceUnchecked(account, interfaceId);
    }

    /**
     * @dev Returns a boolean array where each value corresponds to the
     * interfaces passed in and whether they're supported or not. This allows
     * you to batch check interfaces for a contract where your expectation
     * is that some interfaces may not be supported.
     *
     * See {IERC165-supportsInterface}.
     *
     * _Available since v3.4._
     */
    function getSupportedInterfaces(address account, bytes4[] memory interfaceIds)
        internal
        view
        returns (bool[] memory)
    {
        // an array of booleans corresponding to interfaceIds and whether they're supported or not
        bool[] memory interfaceIdsSupported = new bool[](interfaceIds.length);

        // query support of ERC165 itself
        if (supportsERC165(account)) {
            // query support of each interface in interfaceIds
            for (uint256 i = 0; i < interfaceIds.length; i++) {
                interfaceIdsSupported[i] = supportsERC165InterfaceUnchecked(account, interfaceIds[i]);
            }
        }

        return interfaceIdsSupported;
    }

    /**
     * @dev Returns true if `account` supports all the interfaces defined in
     * `interfaceIds`. Support for {IERC165} itself is queried automatically.
     *
     * Batch-querying can lead to gas savings by skipping repeated checks for
     * {IERC165} support.
     *
     * See {IERC165-supportsInterface}.
     */
    function supportsAllInterfaces(address account, bytes4[] memory interfaceIds) internal view returns (bool) {
        // query support of ERC165 itself
        if (!supportsERC165(account)) {
            return false;
        }

        // query support of each interface in interfaceIds
        for (uint256 i = 0; i < interfaceIds.length; i++) {
            if (!supportsERC165InterfaceUnchecked(account, interfaceIds[i])) {
                return false;
            }
        }

        // all interfaces supported
        return true;
    }

    /**
     * @notice Query if a contract implements an interface, does not check ERC165 support
     * @param account The address of the contract to query for support of an interface
     * @param interfaceId The interface identifier, as specified in ERC-165
     * @return true if the contract at account indicates support of the interface with
     * identifier interfaceId, false otherwise
     * @dev Assumes that account contains a contract that supports ERC165, otherwise
     * the behavior of this method is undefined. This precondition can be checked
     * with {supportsERC165}.
     * Interface identification is specified in ERC-165.
     */
    function supportsERC165InterfaceUnchecked(address account, bytes4 interfaceId) internal view returns (bool) {
        // prepare call
        bytes memory encodedParams = abi.encodeWithSelector(IERC165.supportsInterface.selector, interfaceId);

        // perform static call
        bool success;
        uint256 returnSize;
        uint256 returnValue;
        assembly {
            success := staticcall(30000, account, add(encodedParams, 0x20), mload(encodedParams), 0x00, 0x20)
            returnSize := returndatasize()
            returnValue := mload(0x00)
        }

        return success && returnSize >= 0x20 && returnValue > 0;
    }
}

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

pragma solidity ^0.8.0;

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

File 31 of 40 : Conduit.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "./ConduitLib.sol";

contract Conduit {
    error InvalidERC721TransferAmount();
    error InvalidItemType();
    
    function execute(ConduitTransfer[] memory transfers)
        internal
    {
       
        // Retrieve the total number of transfers and place on the stack.
        uint256 totalStandardTransfers = transfers.length;

        // Iterate over each transfer.
        for (uint256 i = 0; i < totalStandardTransfers; ) {
            // Retrieve the transfer in question.
            ConduitTransfer memory standardTransfer = transfers[i];

            // Perform the transfer.
            _transfer(standardTransfer);

            // Skip overflow check as for loop is indexed starting at zero.
            unchecked {
                ++i;
            }
        }
    }
    function _transfer(ConduitTransfer memory item) private {
        // If the item type indicates Ether or a native token...
        if (item.itemType == ConduitItemType.ERC20) {
            // Transfer ERC20 token.
            IERC20(item.token).transferFrom(item.from, item.to, item.amount);
        } else if (item.itemType == ConduitItemType.ERC721) {
            // Ensure that exactly one 721 item is being transferred.
            if (item.amount != 1) {
                revert InvalidERC721TransferAmount();
            }

            IERC721(item.token).transferFrom(item.from, item.to, item.identifier);

        } else if (item.itemType == ConduitItemType.ERC1155) {
            IERC1155(item.token).safeTransferFrom(item.from, item.to, item.identifier, item.amount, "");
            // Transfer ERC1155 token.
        } else {
            // Throw with an error.
            revert InvalidItemType();
        }
    }
}

File 32 of 40 : ConduitLib.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

enum ConduitItemType {
    NATIVE, // unused
    ERC20,
    ERC721,
    ERC1155
}

struct ConduitTransfer {
    ConduitItemType itemType;
    address token;
    address from;
    address to;
    uint256 identifier;
    uint256 amount;
}

File 33 of 40 : Constants.sol
// SPDX-License-Identifier: MIT


pragma solidity ^0.8.4;
    
//Roles    
bytes32 constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");
bytes32 constant SIG_ROLE = keccak256("SIG_ROLE");
bytes32 constant STAFF_ROLE = keccak256("STAFF_ROLE");
bytes32 constant SERVER_ROLE = keccak256("SERVER_ROLE");

//Scale to be used with SafePct
uint16 constant PORT_SCALE = 10_000;

File 34 of 40 : IBundle2.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

interface IBundle2 {
    event BundleCreated(uint indexed id, address[] contracts, uint[] ids, string name, string desc);
    event BundleDestroyed(uint indexed id) ;
    
    function wrap(address[] calldata _tokens, uint256[] calldata _ids, string calldata _name, string calldata desc) external;

    function contents(uint256 _id) external view returns (address[] memory, uint[] memory);

    function unwrap(uint _id) external;
}

File 35 of 40 : IMembershipStaker.sol
// SPDX-License-Identifier: Unlicense 
pragma solidity 0.8.4;

import "@openzeppelin/contracts-upgradeable/interfaces/IERC1155ReceiverUpgradeable.sol";

interface IMembershipStaker is IERC1155ReceiverUpgradeable {

    /**
     * @dev Emitted when `staker` adds stakes one or more memberships for a new `totalStaked`
     */
    event MembershipStaked(address indexed staker, uint256 totalStaked);

    /**
     * @dev Emmited when `staker` unstaked for a new `totalStaked`
     */
     event MembershipUnstaked(address indexed staker, uint256 totalStaked);

     function stake(uint256 amount) external;

     function unstake(uint256 amount) external;

     function amountStaked(address staker) external view returns (uint256);

     function totalStaked() external view returns (uint256);

     function currentStaked() external view returns (address[] memory stakers, uint256[] memory amounts);

}

File 36 of 40 : Introspection.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/introspection/ERC165Checker.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";
import "./IBundle2.sol";

library Introspection {

    function is721(address _contract) internal view returns(bool){
        return ERC165Checker.supportsInterface(_contract, type(IERC721).interfaceId);
    }
   
    function is1155(address _contract) internal view returns(bool){
        return ERC165Checker.supportsInterface(_contract, type(IERC1155).interfaceId);
    }

    function is20(address _contract) internal view returns (bool){
        return ERC165Checker.supportsInterface(_contract, type(IERC20).interfaceId);
    }

    function isNft(address _contract) internal view returns (bool){
        return is721(_contract) || is1155(_contract);
    }

    function isRoyaltyStandard(address _contract) internal view returns (bool){
        return ERC165Checker.supportsInterface(_contract, type(IERC2981).interfaceId);
    }

    function isBundleContract(address _contract) internal view returns (bool) {
        return ERC165Checker.supportsInterface(_contract, type(IBundle2).interfaceId);
    }
}

File 37 of 40 : IterableMapping.sol
// SPDX-License-Identifier: UNLICENSED
//Copyright Ebisusbay.com 2021
pragma solidity 0.8.4;

library IterableMapping{

    struct Listing {
        uint256 listingId;
        uint256 nftId;
        address seller;
        address nft;
        uint256 price;
        uint256 fee;
        address purchaser;
        bool is1155;
        uint256 listingTime;
        uint256 saleTime;
        uint256 endingTime;
        uint256 royalty;
    }

    struct Map {
        bytes32[] keys;
        mapping(uint256 => bytes32) idToKey;
        mapping(bytes32 => Listing) values;
        mapping(bytes32 => uint) indexOf;
        mapping(bytes32 => bool) inserted;
    }

    function contains(Map storage map, bytes32 key) internal view returns (bool){
        return map.inserted[key];
    }

    function containsId(Map storage map, uint256 id) internal view returns (bool){
        return map.idToKey[id] != bytes32(0);
    }

    function get(Map storage map, bytes32 key) internal view returns (Listing storage) {
        return map.values[key];
    }

    function getById(Map storage map, uint256 id) internal view returns (Listing storage){
        return get(map, map.idToKey[id]);
    }

    function keyForId(Map storage map, uint256 id) internal view returns (bytes32){
        return map.idToKey[id];
    }

    function size(Map storage map) internal view returns (uint) {
        return map.keys.length;
    }

    function paged(Map storage map, uint256 _page, uint16 _pageSize) internal view returns (Listing[] memory){
        if(size(map) == 0){
            return new Listing[](0);
        }

        Listing[] memory result = new Listing[](_pageSize);
        uint16 returnCounter = 0;
        for(uint i = _pageSize * _page - _pageSize; i < _pageSize * _page; i++ ){
            if(i >= size(map)){
                break;
            }
            result[returnCounter] = get(map, map.keys[i]);
            returnCounter++;
        }
        return result;
    }

    function set(
        Map storage map,
        bytes32 key,
        Listing memory val
    ) internal {
        if (map.inserted[key]) {
            map.values[key] = val;
            map.idToKey[val.listingId] = key;
        } else {
            map.inserted[key] = true;
            map.values[key] = val;
            map.indexOf[key] = map.keys.length;
            map.keys.push(key);
            map.idToKey[val.listingId] = key;
        }
    }

    function remove(Map storage map, bytes32 key) internal {
        if (!map.inserted[key]) {
            return;
        }

        delete map.idToKey[map.values[key].listingId];
        delete map.inserted[key];
        delete map.values[key];

        uint index = map.indexOf[key];
        uint lastIndex = map.keys.length - 1;
        bytes32 lastKey = map.keys[lastIndex];

        map.indexOf[lastKey] = index;
        delete map.indexOf[key];

        map.keys[index] = lastKey;
        map.keys.pop();
    }
}

File 38 of 40 : Port.sol
// SPDX-License-Identifier: UNLICENSED
//Copyright Ebisusbay.com 2021
pragma solidity ^0.8.4;

import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/UUPSUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/PullPaymentUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";

import "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
import "@openzeppelin/contracts/interfaces/IERC2981.sol";

import {
    UPGRADER_ROLE,
    STAFF_ROLE,
    SERVER_ROLE,
    SIG_ROLE,
    PORT_SCALE
} from "./Constants.sol";

import "./Introspection.sol";
import "./SafePct.sol";
import "./IterableMapping.sol";
import "./IMembershipStaker.sol";
import "./conduit/Conduit.sol";
import "./IBundle2.sol";

abstract contract OwnableContract {
    function owner() public view virtual returns (address){}
}

contract Port is 
    Initializable, 
    AccessControlUpgradeable, 
    UUPSUpgradeable, 
    PullPaymentUpgradeable,
    ReentrancyGuardUpgradeable, Conduit {

    using SafeMathLite for uint256;
    using SafePct for uint256;
    using CountersUpgradeable for CountersUpgradeable.Counter;
    using AddressUpgradeable for address payable;
    using IterableMapping for IterableMapping.Map;
    using IterableMapping for IterableMapping.Listing;
    
    struct Royalty {
        address ipHolder;
        uint16 percent;
    }

    event Listed(uint256 indexed listingId);
    event Sold(uint256 indexed listingId);
    event Cancelled(uint256 indexed listingId);
    event FeesUpdate(address indexed updater, uint256 reg, uint256 fm, uint256 admin);
    event AdminWithdraw(address indexed admin, uint256 amount);
    event RoyaltyChanged(address indexed staffMember, address indexed collection, address ipHolder, uint16 fee);
    event RoyaltyRemoved(address indexed staffMember, address indexed collection);
    event StakerUpdated(address indexed admin, address newStaker);
    event RoyaltyPaid(address collection, uint id, address ipholder, uint amount);


    IERC1155 private memberships;

    uint16 public vipFee;
    uint16 public memberFee;
    uint16 public regFee;

    IterableMapping.Map private activeListings;
    IterableMapping.Map private completeListings;
    IterableMapping.Map private cancelledListings;

    CountersUpgradeable.Counter private listingId;

    mapping(address => Royalty) public royalties;
    IMembershipStaker public membershipStaker;
    IERC721 ryoshi;
    mapping(address => bool) private escrowOptin;

    function upgraderRole() public pure returns (bytes32){
        return UPGRADER_ROLE;
    }

    function serverRole() public pure returns (bytes32){
        return SERVER_ROLE;
    }

    function staffRole() public pure returns (bytes32){
        return STAFF_ROLE;
    }

    function sigRole() public pure returns (bytes32){
        return SIG_ROLE;
    }
    // constructor() initializer {}

    function initialize(IERC1155 _memberships) initializer public {
        __AccessControl_init();
        __UUPSUpgradeable_init();
        __PullPayment_init();
        __ReentrancyGuard_init();

        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _grantRole(UPGRADER_ROLE, _msgSender());
        memberships = _memberships;
        vipFee = 150;
        memberFee = 300;
        regFee = 500;       
    }

    function _authorizeUpgrade(address newImplementation)
        internal
        onlyRole(UPGRADER_ROLE)
        override
    {}

    function activeListing(uint256 _listingId) external view returns (IterableMapping.Listing memory){
        return activeListings.getById(_listingId);
    } 

    function completeListing(uint256 _listingId) external view returns (IterableMapping.Listing memory){
        return completeListings.getById(_listingId);
    }

    function cancelledListing(uint256 _listingId) external view returns (IterableMapping.Listing memory){
        return cancelledListings.getById(_listingId);
    }

    function withdrawPayments(address payable payee) public virtual override nonReentrant{
        super.withdrawPayments(payee);
    }

    function _makeListing(address _seller, address _nft, uint256 _id, uint256 _price) private {
        require(_price > 0, "invalid price");
        bool is1155 = Introspection.is1155(_nft);
        bool is721 = Introspection.is721(_nft);
        require(is1155 || is721, "unsupported type");
        if(is721){
            require(IERC721(_nft).ownerOf(_id) == _seller, "not owned");
            require(IERC721(_nft).isApprovedForAll(_seller, address(this)), "must approve transfer");
        } else {
            require(IERC1155(_nft).balanceOf(_seller, _id) > 0, "not owned");
            require(IERC1155(_nft).isApprovedForAll(_seller, address(this)), "must approve transfer");
        }

        bytes32 listingHash = keccak256(abi.encode(_nft, _seller, _id));

        uint256 royaltyAmount = calculateRoyalty(_nft, _id, _price);

        if(activeListings.contains(listingHash)){
            IterableMapping.Listing storage listing = activeListings.get(listingHash);
            listing.price = _price;
            listing.fee = _price.mulDiv(fee(_seller), PORT_SCALE);
            listing.royalty = royaltyAmount;
            emit Listed(listing.listingId);
            return;
        }

        IterableMapping.Listing memory newListing;
        newListing.listingId = listingId.current();
        newListing.nftId = _id;
        newListing.seller = _seller;
        newListing.nft = address(_nft);
        newListing.price = _price;
        newListing.fee = _price.mulDiv(fee(_seller), PORT_SCALE);
        newListing.is1155 = is1155;
        newListing.listingTime = block.timestamp;
        newListing.royalty = royaltyAmount;
        activeListings.set(listingHash, newListing);

        listingId.increment();
        emit Listed(newListing.listingId);
    }

    function makeListingServer(address _seller, address _nft, uint256 _id, uint256 _price) external {
        require(hasRole(SERVER_ROLE, _msgSender()), "not authorized");
        _makeListing(_seller, _nft, _id, _price);
    }

    function makeListing(address _nft, uint256 _id, uint256 _price) public  {
        _makeListing(_msgSender(), _nft, _id, _price);
    }

    function makeListings(address[] calldata _nfts, uint256[] calldata _ids, uint256[] calldata _prices) external {
        require(_nfts.length == _ids.length && _nfts.length == _prices.length, "missing data");
        for(uint i = 0; i < _nfts.length; i++){
            makeListing(_nfts[i], _ids[i], _prices[i]);
        }
    }

    function makeLegacyPurchase(uint256 _id, address _buyer) external payable onlyRole(SERVER_ROLE){
        require(activeListings.containsId(_id), "invalid id");
        IterableMapping.Listing memory listing = activeListings.getById(_id);
        

        activeListings.remove(activeListings.keyForId(_id));
        listing.purchaser = _buyer;
        listing.saleTime = block.timestamp;
        completeListings.set(keccak256(abi.encodePacked(_id)), listing);
        
        require(msg.value >= listing.price, "not enough funds");
        if(listing.is1155){
            _transferToken(ConduitItemType.ERC1155, listing.nft, listing.seller, _buyer, listing.nftId, 1);
        }else {
            _transferToken(ConduitItemType.ERC721, listing.nft, listing.seller, _buyer, listing.nftId, 1);
        }
        
        if (address(membershipStaker) != address(0)) {
            uint256 stakingFee = listing.fee.mulDiv(1, 2);
            payAddress(payable(address(membershipStaker)), stakingFee);
        }
      
        if (listing.royalty > 0)  {
            _payRoyalty(listing.nft, listing.nftId, listing.price);
        }
        payAddress((payable(listing.seller)), listing.price - listing.royalty);
       
        emit Sold(_id);
    }

    function priceLookup(uint256 _id) external view returns (uint256) {
        require(activeListings.containsId(_id), "invalid id");
        IterableMapping.Listing memory listing = activeListings.getById(_id);
        return listing.price;
    }

    function payAddress(address payable _address, uint _amount) private {
        if(escrowOptin[_address]){
            _asyncTransfer(_address, _amount);
        } else {
            _address.sendValue(_amount);
        }
    }

    function addToEscrow(address _address) external payable {
        _asyncTransfer(_address, msg.value);
    }

    function cancelListing(uint256 _id) public {
        require(activeListings.containsId(_id), "invalid id");
        IterableMapping.Listing memory listing = activeListings.getById(_id);
        require(listing.seller == _msgSender() || hasRole(STAFF_ROLE, _msgSender()) || hasRole(SERVER_ROLE, _msgSender()), "not lister");
        listing.saleTime = block.timestamp;
        activeListings.remove(activeListings.keyForId(_id));
        cancelledListings.set(keccak256(abi.encodePacked(_id)), listing);
        emit Cancelled(_id);
    }

    function cancelActive(address _nft, uint256 _id, address _seller) external {
        bytes32 listingHash = keccak256(abi.encode(_nft, _seller, _id));
        if(activeListings.contains(listingHash)){
            IterableMapping.Listing storage listing = activeListings.get(listingHash);
            cancelListing(listing.listingId);
        }
    }

    function cancelListings(uint[] calldata _ids) external {
        for(uint i = 0; i < _ids.length; i++){
            cancelListing(_ids[i]);
        }
    }

    /**\
        uint64 public constant FOUNDER = 1;
        uint64 public constant VIP = 2;
        uint64 public constant VVIP = 3;
     */
    function fee(address user) public view returns (uint16 userFee){
        if(memberships.balanceOf(user, 3) > 0){
            userFee = 0;
        } else if(isVIP(user)) {
            userFee = vipFee;
        } else if(isFM(user)){
            userFee = memberFee;
        }else {
            userFee = regFee;
        }
    }

    function isMember(address user) public view returns (bool){
        return isFM(user) || isVIP(user);
    }

    function isFM(address user) public view returns (bool) {
        return memberships.balanceOf(user, 1) > 0;
    }

    function isVIP(address user) public view returns (bool) {
        if(memberships.balanceOf(user, 2) > 0 || (address(ryoshi) != address(0) && ryoshi.balanceOf(user) > 0)){
            return true;
        } else if((address(membershipStaker) != address(0) && membershipStaker.amountStaked(user) > 0)){
            return true;
        }
        return false;
    }

    //=====STAFF============

    function registerRoyalty(address _nftContract, address _ipHolder, uint16 _fee) external onlyRole(STAFF_ROLE){
        royalties[_nftContract] = Royalty(_ipHolder, _fee);
        emit RoyaltyChanged(_msgSender(), _nftContract, _ipHolder, _fee);
    }

    function removeRoyalty(address _nftContract) external onlyRole(STAFF_ROLE){
        delete royalties[_nftContract];
        emit RoyaltyRemoved(_msgSender(), _nftContract);
    }

    function registerRoyaltyAsOwner(address _nftContract, address _paymentAddress, uint16 _fee) external {
        require(!isRoyaltyStandard(_nftContract), "not legacy");
        require(OwnableContract(_nftContract).owner() == _msgSender(), "not owner");
        royalties[_nftContract] = Royalty(_paymentAddress, _fee);
        emit RoyaltyChanged(_msgSender(), _nftContract, _paymentAddress, _fee);
    }

    function useEscrow(address _user) public view returns(bool){
        return escrowOptin[_user];
    }

    function setUseEscrow(address _user, bool _optIn) external nonReentrant{
        require(_msgSender() == _user || hasRole(STAFF_ROLE, _msgSender()), "not authorized");
        escrowOptin[_user] = _optIn;
        if(!_optIn && payments(_user) > 0){
            super.withdrawPayments(payable(_user));
        }
    }

    //=====ADMIN============ 

    function withdraw() external onlyRole(DEFAULT_ADMIN_ROLE){
        emit AdminWithdraw(_msgSender(), address(this).balance);
        payable(_msgSender()).sendValue(address(this).balance);
    }

    function updateFees(uint16 _regFee, uint16 _memFee, uint16 _vipFee) external onlyRole(DEFAULT_ADMIN_ROLE){
        regFee = _regFee;
        memberFee = _memFee;
        vipFee = _vipFee;
        emit FeesUpdate(_msgSender(), _regFee, _memFee, _vipFee);
    }

    function setMembershipStaker(address _membershipStaker) external onlyRole(DEFAULT_ADMIN_ROLE) {
        membershipStaker = IMembershipStaker(_membershipStaker);
        emit StakerUpdated(_msgSender(), _membershipStaker);
    }

    function setRyoshi(address _ryoshi) external onlyRole(DEFAULT_ADMIN_ROLE){
        ryoshi = IERC721(_ryoshi);
    }

    receive() external payable {}

    function bulkTransfer(address[] calldata _tokens, uint256[] calldata _ids, address _to) external{
        require(_tokens.length == _ids.length, "arrays not equal");
        _bulkTransfer(_tokens, _ids, _msgSender(), _to);
    }

    //depreciated use executeTradesServer
    function transferToken(
        ConduitItemType _type, 
        address _tokenAddress, 
        address _from, 
        address _to, 
        uint256 _identifier, 
        uint256 _amount) public onlyRole(SERVER_ROLE){
        _transferToken(_type, _tokenAddress, _from, _to, _identifier, _amount);
    }

    function _bulkTransfer(address[] calldata _tokens, uint256[] calldata _ids, address _from, address _to) private nonReentrant {
        ConduitTransfer[] memory transferInformations = new ConduitTransfer[](_tokens.length);
        for(uint i = 0; i < _tokens.length; i++){
            bool is721 = Introspection.is721(_tokens[i]);
            if(is721){
                transferInformations[i].itemType = ConduitItemType.ERC721;
            } else {
                require(Introspection.is1155(_tokens[i]), "invalid token type");
                transferInformations[i].itemType = ConduitItemType.ERC1155;
            }
            transferInformations[i].token = _tokens[i];
            transferInformations[i].from = _from;
            transferInformations[i].to = _to;
            transferInformations[i].identifier = _ids[i];
            transferInformations[i].amount = 1;
        }
        execute(transferInformations);
    }

    function executeTradesServer(ConduitTransfer[] calldata transferInformation) external onlyRole(SERVER_ROLE) nonReentrant {
        execute(transferInformation);
    }

    function transferBulkServer(address[] calldata _tokens, uint256[] calldata _ids, address _from, address _to) external onlyRole(SERVER_ROLE){
        _bulkTransfer(_tokens, _ids, _from, _to);
    }

    function _transferToken(ConduitItemType _type, address _tokenAddress, address _from, address _to, uint256 _identifier, uint256 _amount) private {
        ConduitTransfer memory transferInformation;
        ConduitTransfer[] memory transferInformations = new ConduitTransfer[](1);
        
        transferInformation.itemType = _type;
        transferInformation.token = _tokenAddress;
        transferInformation.from = _from;
        transferInformation.to = _to;
        transferInformation.identifier = _identifier;
        transferInformation.amount = _amount;

        transferInformations[0] = transferInformation;
        execute(transferInformations);
    }
    // ========Royalty============
 
    function getRoyalty(address _contract) external view returns (Royalty memory){
        return royalties[_contract];
    }

    function isRoyaltyStandard(address _contract) public view returns (bool) {
         return Introspection.isRoyaltyStandard(_contract);
    }

    function isBundleContract(address _contract) public view returns (bool) {
        return Introspection.isBundleContract(_contract);
    }

    // get Royalty including Bundle
    function calculateRoyalty(address _contract, uint256 _id, uint256 _price) public view returns (uint256) {
        uint256 royaltyAmount;

        if (isBundleContract(_contract)) {
            (address[] memory contracts, uint256[] memory ids) = IBundle2(_contract).contents(_id);
            uint len = contracts.length;
            uint256 eachAmount = _price.div(len);
            
            for (uint256 i = 0; i < len;) {
                (, uint256 amount) = getStandardNFTRoyalty(contracts[i], ids[i], eachAmount);
                royaltyAmount += amount;
                unchecked {
                    i++;
                }
            }
        } else {
            (, royaltyAmount) = getStandardNFTRoyalty(_contract, _id, _price);
        }

        return royaltyAmount;
    }

    // get royalty for ERC721 or ERC1155
    function getStandardNFTRoyalty(address _contract, uint256 _id, uint256 _price) public view returns (address ipHolder, uint256 royaltyAmount) {
        require(Introspection.is1155(_contract) || Introspection.is721(_contract), "not ERC721 or ERC1155");
        require(!isBundleContract(_contract), "not support bundle");
        
        if (isRoyaltyStandard(_contract)) {
            (ipHolder, royaltyAmount) = IERC2981(_contract).royaltyInfo(_id, _price);
        } else {
            if(royalties[_contract].percent > 0){
                royaltyAmount = _price.mulDiv(royalties[_contract].percent, PORT_SCALE);
                ipHolder = royalties[_contract].ipHolder;
            }
        }
    }

    function payRoyalty(address _contract, uint256 _id, uint256 _price) public payable {
        if(msg.value <= 0) return;
        
        uint256 amount =  calculateRoyalty(_contract, _id, _price);
        require(amount == msg.value, "invalid amount");

        _payRoyalty(_contract, _id, _price);
    }

    function payRoyaltyServer(address _contract, uint256 _id, uint256 _price) external payable onlyRole(SERVER_ROLE){
        _payRoyalty(_contract, _id, _price);
    }

    function _payRoyalty(address _contract, uint256 _id, uint256 _amount) private nonReentrant{
        if (isBundleContract(_contract)) {
            (address[] memory contracts, uint256[] memory ids) = IBundle2(_contract).contents(_id);
            uint256 len = contracts.length;
            uint256 eachAmount = _amount.div(len);

            for (uint256 i = 0; i < len; i++) {
                (address ipHolder, uint256 amount) = getStandardNFTRoyalty(contracts[i], ids[i], eachAmount);
                if(ipHolder == address(0)){
                    continue;
                }
                payAddress(payable(ipHolder), amount);
                emit RoyaltyPaid(contracts[i], ids[i], ipHolder, amount);
            }
        } else {
            (address ipHolder, uint256 amount) = getStandardNFTRoyalty(_contract, _id, _amount);
            if(ipHolder == address(0)) return;
            payAddress(payable(ipHolder), amount);
            emit RoyaltyPaid(_contract, _id, ipHolder, amount);
        }
    }
}

File 39 of 40 : SafeMathLite.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;
library SafeMathLite{

    /**
     * @dev Returns the addition of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     *
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        return a + b;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on
     * overflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     *
     * - Subtraction cannot overflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return a - b;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on
     * overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     *
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        return a * b;
    }

    /**
     * @dev Returns the integer division of two unsigned integers, reverting on
     * division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator.
     *
     * Requirements:
     *
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return a / b;
    }
}

File 40 of 40 : SafePct.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.4;

/**
 * @dev Compute percentages safely without phantom overflows.
 *
 * Intermediate operations can overflow even when the result will always
 * fit into computed type. Developers usually
 * assume that overflows raise errors. `SafePct` restores this intuition by
 * reverting the transaction when such an operation overflows.
 *
 * Using this library instead of the unchecked operations eliminates an entire
 * class of bugs, so it's recommended to use it always.
 *
 * Can be combined with {SafeMath} and {SignedSafeMath} to extend it to smaller types, by performing
 * all math on `uint256` and `int256` and then downcasting.
 */

import "./SafeMathLite.sol";

library SafePct {
    using SafeMathLite for uint256;
    /**
     * Requirements:
     *
     * - intermediate operations must revert on overflow
     */
    function mulDiv(uint256 x, uint256 y, uint256 z) internal pure returns (uint256) {
        require(z > 0, "Division by zero");

        if (x == 0) return 0;
        uint256 xy = x * y;
        if (xy / x == y) { // no overflow happened - same as in SafeMath mul
            return xy / z;
        }

        //slither-disable-next-line divide-before-multiply
        uint256 a = x / z;
        uint256 b = x % z; // x = a * z + b

        //slither-disable-next-line divide-before-multiply
        uint256 c = y / z;
        uint256 d = y % z; // y = c * z + d

        return (a.mul(c).mul(z)).add(a.mul(d)).add(b.mul(c)).add(b.mul(d).div(z));
    }


}

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

Contract ABI

[{"inputs":[],"name":"InvalidERC721TransferAmount","type":"error"},{"inputs":[],"name":"InvalidItemType","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"previousAdmin","type":"address"},{"indexed":false,"internalType":"address","name":"newAdmin","type":"address"}],"name":"AdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"AdminWithdraw","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"beacon","type":"address"}],"name":"BeaconUpgraded","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"listingId","type":"uint256"}],"name":"Cancelled","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"updater","type":"address"},{"indexed":false,"internalType":"uint256","name":"reg","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"fm","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"admin","type":"uint256"}],"name":"FeesUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"listingId","type":"uint256"}],"name":"Listed","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staffMember","type":"address"},{"indexed":true,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"address","name":"ipHolder","type":"address"},{"indexed":false,"internalType":"uint16","name":"fee","type":"uint16"}],"name":"RoyaltyChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"collection","type":"address"},{"indexed":false,"internalType":"uint256","name":"id","type":"uint256"},{"indexed":false,"internalType":"address","name":"ipholder","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"RoyaltyPaid","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"staffMember","type":"address"},{"indexed":true,"internalType":"address","name":"collection","type":"address"}],"name":"RoyaltyRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"listingId","type":"uint256"}],"name":"Sold","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"admin","type":"address"},{"indexed":false,"internalType":"address","name":"newStaker","type":"address"}],"name":"StakerUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"implementation","type":"address"}],"name":"Upgraded","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_listingId","type":"uint256"}],"name":"activeListing","outputs":[{"components":[{"internalType":"uint256","name":"listingId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"address","name":"purchaser","type":"address"},{"internalType":"bool","name":"is1155","type":"bool"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"saleTime","type":"uint256"},{"internalType":"uint256","name":"endingTime","type":"uint256"},{"internalType":"uint256","name":"royalty","type":"uint256"}],"internalType":"struct IterableMapping.Listing","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_address","type":"address"}],"name":"addToEscrow","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"address","name":"_to","type":"address"}],"name":"bulkTransfer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"calculateRoyalty","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"address","name":"_seller","type":"address"}],"name":"cancelActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"cancelListing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"_ids","type":"uint256[]"}],"name":"cancelListings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"_listingId","type":"uint256"}],"name":"cancelledListing","outputs":[{"components":[{"internalType":"uint256","name":"listingId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"address","name":"purchaser","type":"address"},{"internalType":"bool","name":"is1155","type":"bool"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"saleTime","type":"uint256"},{"internalType":"uint256","name":"endingTime","type":"uint256"},{"internalType":"uint256","name":"royalty","type":"uint256"}],"internalType":"struct IterableMapping.Listing","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_listingId","type":"uint256"}],"name":"completeListing","outputs":[{"components":[{"internalType":"uint256","name":"listingId","type":"uint256"},{"internalType":"uint256","name":"nftId","type":"uint256"},{"internalType":"address","name":"seller","type":"address"},{"internalType":"address","name":"nft","type":"address"},{"internalType":"uint256","name":"price","type":"uint256"},{"internalType":"uint256","name":"fee","type":"uint256"},{"internalType":"address","name":"purchaser","type":"address"},{"internalType":"bool","name":"is1155","type":"bool"},{"internalType":"uint256","name":"listingTime","type":"uint256"},{"internalType":"uint256","name":"saleTime","type":"uint256"},{"internalType":"uint256","name":"endingTime","type":"uint256"},{"internalType":"uint256","name":"royalty","type":"uint256"}],"internalType":"struct IterableMapping.Listing","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"enum ConduitItemType","name":"itemType","type":"uint8"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"identifier","type":"uint256"},{"internalType":"uint256","name":"amount","type":"uint256"}],"internalType":"struct ConduitTransfer[]","name":"transferInformation","type":"tuple[]"}],"name":"executeTradesServer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"fee","outputs":[{"internalType":"uint16","name":"userFee","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"getRoyalty","outputs":[{"components":[{"internalType":"address","name":"ipHolder","type":"address"},{"internalType":"uint16","name":"percent","type":"uint16"}],"internalType":"struct Port.Royalty","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"getStandardNFTRoyalty","outputs":[{"internalType":"address","name":"ipHolder","type":"address"},{"internalType":"uint256","name":"royaltyAmount","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC1155","name":"_memberships","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"isBundleContract","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isFM","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isMember","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"}],"name":"isRoyaltyStandard","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isVIP","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"address","name":"_buyer","type":"address"}],"name":"makeLegacyPurchase","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"makeListing","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_seller","type":"address"},{"internalType":"address","name":"_nft","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"makeListingServer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"_nfts","type":"address[]"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"uint256[]","name":"_prices","type":"uint256[]"}],"name":"makeListings","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"memberFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"membershipStaker","outputs":[{"internalType":"contract IMembershipStaker","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"payRoyalty","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"_contract","type":"address"},{"internalType":"uint256","name":"_id","type":"uint256"},{"internalType":"uint256","name":"_price","type":"uint256"}],"name":"payRoyaltyServer","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"dest","type":"address"}],"name":"payments","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"_id","type":"uint256"}],"name":"priceLookup","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"proxiableUUID","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"regFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContract","type":"address"},{"internalType":"address","name":"_ipHolder","type":"address"},{"internalType":"uint16","name":"_fee","type":"uint16"}],"name":"registerRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContract","type":"address"},{"internalType":"address","name":"_paymentAddress","type":"address"},{"internalType":"uint16","name":"_fee","type":"uint16"}],"name":"registerRoyaltyAsOwner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_nftContract","type":"address"}],"name":"removeRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"royalties","outputs":[{"internalType":"address","name":"ipHolder","type":"address"},{"internalType":"uint16","name":"percent","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"serverRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_membershipStaker","type":"address"}],"name":"setMembershipStaker","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_ryoshi","type":"address"}],"name":"setRyoshi","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"},{"internalType":"bool","name":"_optIn","type":"bool"}],"name":"setUseEscrow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"sigRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"staffRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address[]","name":"_tokens","type":"address[]"},{"internalType":"uint256[]","name":"_ids","type":"uint256[]"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"}],"name":"transferBulkServer","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum ConduitItemType","name":"_type","type":"uint8"},{"internalType":"address","name":"_tokenAddress","type":"address"},{"internalType":"address","name":"_from","type":"address"},{"internalType":"address","name":"_to","type":"address"},{"internalType":"uint256","name":"_identifier","type":"uint256"},{"internalType":"uint256","name":"_amount","type":"uint256"}],"name":"transferToken","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"_regFee","type":"uint16"},{"internalType":"uint16","name":"_memFee","type":"uint16"},{"internalType":"uint16","name":"_vipFee","type":"uint16"}],"name":"updateFees","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"}],"name":"upgradeTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newImplementation","type":"address"},{"internalType":"bytes","name":"data","type":"bytes"}],"name":"upgradeToAndCall","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"upgraderRole","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"address","name":"_user","type":"address"}],"name":"useEscrow","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"vipFee","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"payee","type":"address"}],"name":"withdrawPayments","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

60a06040523060601b60805234801561001757600080fd5b5060805160601c615c22620000536000396000818161147c015281816114bc015281816115f90152818161163901526116c80152615c226000f3fe6080604052600436106103855760003560e01c80636fcca69b116101d1578063b78eebe511610102578063d3098883116100a0578063e2982c211161006f578063e2982c2114610b09578063eb61e37114610b29578063f4201c3c14610bbb578063f89f7ab314610bdb57600080fd5b8063d309888314610a83578063d547741f14610aa6578063dfa3d77314610ac6578063e1053f4e14610ae657600080fd5b8063c2168d59116100dc578063c2168d5914610a03578063c4d66de814610a23578063c9272fb914610a43578063cfe542f414610a6357600080fd5b8063b78eebe51461098a578063bfd7b7e9146109c3578063c1b875c8146109e357600080fd5b806391d148541161016f578063a217fddf11610149578063a217fddf14610908578063a230c5241461091d578063a68928e21461093d578063ac7d126e1461095d57600080fd5b806391d14854146108615780639fa6b4a014610881578063a08c767f146108e757600080fd5b806384cbfe08116101ab57806384cbfe08146107cc57806389ef8292146107df5780638ad6ff1e146107ff5780638fff20f31461083e57600080fd5b80636fcca69b1461075857806379c7550f1461078b5780637e0bb3df146107ab57600080fd5b806332fac307116102b657806352d1902d116102545780635de33c10116102235780635de33c10146106e55780635ee32fef14610705578063670babe014610725578063698f5cc81461074557600080fd5b806352d1902d1461066a5780635382f5991461067f57806356fd3af2146106925780635d1d19b4146106c557600080fd5b806339f3dc5a1161029057806339f3dc5a1461060f5780633ccfd60b1461062f5780634065da63146106445780634f1ef2861461065757600080fd5b806332fac307146105af57806336568abe146105cf5780633659cfe6146105ef57600080fd5b8063248a9ca311610323578063305a67a8116102fd578063305a67a81461052f5780633153ff2d1461054f57806331b3eb941461056f578063322aac8f1461058f57600080fd5b8063248a9ca3146104bf5780632a7e7aa4146104ef5780632f2ff15d1461050f57600080fd5b806316406a851161035f57806316406a851461043d5780631afadd371461045d5780631d6c53a11461047f5780631fa8bc141461049f57600080fd5b806301ffc9a71461039157806306300cbc146103c6578063073898411461040057600080fd5b3661038c57005b600080fd5b34801561039d57600080fd5b506103b16103ac366004614ec3565b610bfb565b60405190151581526020015b60405180910390f35b3480156103d257600080fd5b506103b16103e13660046148fc565b6001600160a01b03166000908152610174602052604090205460ff1690565b34801561040c57600080fd5b507f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e35b6040519081526020016103bd565b34801561044957600080fd5b506103b16104583660046148fc565b610c32565b34801561046957600080fd5b5061047d610478366004614c4b565b610cc0565b005b34801561048b57600080fd5b5061047d61049a366004614934565b610dbf565b3480156104ab57600080fd5b5061042f6104ba366004614e6f565b610f6e565b3480156104cb57600080fd5b5061042f6104da366004614e6f565b60009081526065602052604090206001015490565b3480156104fb57600080fd5b5061047d61050a366004614eeb565b611051565b34801561051b57600080fd5b5061047d61052a366004614e9f565b611077565b34801561053b57600080fd5b5061047d61054a366004614e6f565b6110a1565b34801561055b57600080fd5b5061047d61056a366004614da5565b61127b565b34801561057b57600080fd5b5061047d61058a3660046148fc565b611301565b34801561059b57600080fd5b5061047d6105aa366004614934565b611320565b3480156105bb57600080fd5b506103b16105ca3660046148fc565b6113e8565b3480156105db57600080fd5b5061047d6105ea366004614e9f565b6113f3565b3480156105fb57600080fd5b5061047d61060a3660046148fc565b611471565b34801561061b57600080fd5b5061047d61062a366004614e14565b61154e565b34801561063b57600080fd5b5061047d61159a565b61047d6106523660046148fc565b6115e4565b61047d6106653660046149f7565b6115ee565b34801561067657600080fd5b5061042f6116bb565b61047d61068d366004614b06565b61176e565b34801561069e57600080fd5b507fce80e833f1c3f0c050749e11fed407dc3dacd109611ea11097e9f5eb6abd9aad61042f565b3480156106d157600080fd5b5061047d6106e0366004614bba565b6117db565b3480156106f157600080fd5b5061047d6107003660046148fc565b611801565b34801561071157600080fd5b5061047d61072036600461497a565b611830565b34801561073157600080fd5b5061047d610740366004614fed565b611891565b61047d610753366004614e9f565b611933565b34801561076457600080fd5b506107786107733660046148fc565b611bc9565b60405161ffff90911681526020016103bd565b34801561079757600080fd5b5061047d6107a6366004614b06565b611cba565b3480156107b757600080fd5b50600080516020615b6683398151915261042f565b61047d6107da366004614b06565b611cc6565b3480156107eb57600080fd5b5061047d6107fa366004614b3a565b611cde565b34801561080b57600080fd5b5061081f61081a366004614b06565b611d35565b604080516001600160a01b0390931683526020830191909152016103bd565b34801561084a57600080fd5b506101605461077890600160c01b900461ffff1681565b34801561086d57600080fd5b506103b161087c366004614e9f565b611efb565b34801561088d57600080fd5b506108c561089c3660046148fc565b610171602052600090815260409020546001600160a01b03811690600160a01b900461ffff1682565b604080516001600160a01b03909316835261ffff9091166020830152016103bd565b3480156108f357600080fd5b50600080516020615b8683398151915261042f565b34801561091457600080fd5b5061042f600081565b34801561092957600080fd5b506103b16109383660046148fc565b611f26565b34801561094957600080fd5b5061042f610958366004614b06565b611f40565b34801561096957600080fd5b5061097d610978366004614e6f565b612089565b6040516103bd9190615207565b34801561099657600080fd5b50610172546109ab906001600160a01b031681565b6040516001600160a01b0390911681526020016103bd565b3480156109cf57600080fd5b5061097d6109de366004614e6f565b61213f565b3480156109ef57600080fd5b5061047d6109fe3660046148fc565b612153565b348015610a0f57600080fd5b5061097d610a1e366004614e6f565b6121bd565b348015610a2f57600080fd5b5061047d610a3e3660046148fc565b6121d1565b348015610a4f57600080fd5b5061047d610a5e3660046148fc565b612365565b348015610a6f57600080fd5b5061047d610a7e3660046149bf565b6123c9565b348015610a8f57600080fd5b506101605461077890600160b01b900461ffff1681565b348015610ab257600080fd5b5061047d610ac1366004614e9f565b61248c565b348015610ad257600080fd5b5061047d610ae1366004614ac5565b6124b1565b348015610af257600080fd5b506101605461077890600160a01b900461ffff1681565b348015610b1557600080fd5b5061042f610b243660046148fc565b612513565b348015610b3557600080fd5b50610b93610b443660046148fc565b604080518082018252600080825260209182018190526001600160a01b03938416815261017182528290208251808401909352549283168252600160a01b90920461ffff169181019190915290565b6040805182516001600160a01b0316815260209283015161ffff1692810192909252016103bd565b348015610bc757600080fd5b506103b1610bd63660046148fc565b612591565b348015610be757600080fd5b506103b1610bf63660046148fc565b61276f565b60006001600160e01b03198216637965db0b60e01b1480610c2c57506301ffc9a760e01b6001600160e01b03198316145b92915050565b61016054604051627eeac760e11b81526001600160a01b03838116600483015260016024830152600092839291169062fdd58e9060440160206040518083038186803b158015610c8157600080fd5b505afa158015610c95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610cb99190614e87565b1192915050565b8483148015610cce57508481145b610d0e5760405162461bcd60e51b815260206004820152600c60248201526b6d697373696e67206461746160a01b60448201526064015b60405180910390fd5b60005b85811015610db657610da4878783818110610d3c57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190610d5191906148fc565b868684818110610d7157634e487b7160e01b600052603260045260246000fd5b90506020020135858585818110610d9857634e487b7160e01b600052603260045260246000fd5b90506020020135611cba565b80610dae816153c2565b915050610d11565b50505050505050565b610dc8836113e8565b15610e025760405162461bcd60e51b815260206004820152600a6024820152696e6f74206c656761637960b01b6044820152606401610d05565b336001600160a01b0316836001600160a01b0316638da5cb5b6040518163ffffffff1660e01b815260040160206040518083038186803b158015610e4557600080fd5b505afa158015610e59573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610e7d9190614918565b6001600160a01b031614610ebf5760405162461bcd60e51b81526020600482015260096024820152683737ba1037bbb732b960b91b6044820152606401610d05565b6040805180820182526001600160a01b03808516825261ffff80851660208085019182528884166000818152610171909252959020935184549151909216600160a01b026001600160b01b03199091169190921617179055610f1e3390565b604080516001600160a01b03868116825261ffff8616602083015292909216917f9c33f160728db2e0d663d19462fc54c52fef3827d82f8e2bf7431872caa03687910160405180910390a3505050565b60008181526101626020526040812054610f9a5760405162461bcd60e51b8152600401610d0590615100565b6000610fa86101618461277a565b6040805161018081018252825481526001830154602082015260028301546001600160a01b0390811692820192909252600383015482166060820152600483015460808201819052600584015460a0830152600684015492831660c0830152600160a01b90920460ff16151560e0820152600783015461010082015260088301546101208201526009830154610140820152600a90920154610160909201919091529392505050565b600080516020615b668339815191526110698161279e565b610db68787878787876127a8565b6000828152606560205260409020600101546110928161279e565b61109c8383612897565b505050565b600081815261016260205260409020546110cd5760405162461bcd60e51b8152600401610d0590615100565b60006110db6101618361277a565b6040805161018081018252825481526001830154602082015260028301546001600160a01b0390811692820183905260038401548116606083015260048401546080830152600584015460a0830152600684015490811660c0830152600160a01b900460ff16151560e0820152600783015461010082015260088301546101208201526009830154610140820152600a909201546101608301529091503314806111985750611198600080516020615b8683398151915233611efb565b806111b657506111b6600080516020615b6683398151915233611efb565b6111ef5760405162461bcd60e51b815260206004820152600a6024820152693737ba103634b9ba32b960b11b6044820152606401610d05565b4261012082015260008281526101626020526040902054611214905b6101619061291d565b61124c8260405160200161122a91815260200190565b60408051601f19818403018152919052805160209091012061016b9083612aaf565b60405182907fc41d93b8bfbf9fd7cf5bfe271fd649ab6a6fec0ea101c23b82a2a28eca2533a990600090a25050565b600080516020615b668339815191526112938161279e565b61129b612cc3565b6112f68383808060200260200160405190810160405280939291908181526020016000905b828210156112ec576112dd60c08302860136819003810190614f56565b815260200190600101906112c0565b5050505050612d1f565b61109c600161012e55565b611309612cc3565b61131281612d72565b61131d600161012e55565b50565b600080516020615b868339815191526113388161279e565b6040805180820182526001600160a01b03808616825261ffff80861660208085019182528984166000818152610171909252959020935184549151909216600160a01b026001600160b01b031990911691909216171790556113973390565b604080516001600160a01b03878116825261ffff8716602083015292909216917f9c33f160728db2e0d663d19462fc54c52fef3827d82f8e2bf7431872caa03687910160405180910390a350505050565b6000610c2c82612dce565b6001600160a01b03811633146114635760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610d05565b61146d8282612de1565b5050565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156114ba5760405162461bcd60e51b8152600401610d0590615124565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611503600080516020615ba6833981519152546001600160a01b031690565b6001600160a01b0316146115295760405162461bcd60e51b8152600401610d0590615170565b61153281612e48565b6040805160008082526020820190925261131d91839190612e72565b60005b8181101561109c5761158883838381811061157c57634e487b7160e01b600052603260045260246000fd5b905060200201356110a1565b80611592816153c2565b915050611551565b60006115a58161279e565b60405147815233907fba443e8671971c36cdeb74f87321041daff421230cbc5e36cb835269ed1d8b7e9060200160405180910390a261131d3347612fec565b61131d8134613105565b306001600160a01b037f00000000000000000000000000000000000000000000000000000000000000001614156116375760405162461bcd60e51b8152600401610d0590615124565b7f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316611680600080516020615ba6833981519152546001600160a01b031690565b6001600160a01b0316146116a65760405162461bcd60e51b8152600401610d0590615170565b6116af82612e48565b61146d82826001612e72565b6000306001600160a01b037f0000000000000000000000000000000000000000000000000000000000000000161461175b5760405162461bcd60e51b815260206004820152603860248201527f555550535570677261646561626c653a206d757374206e6f742062652063616c60448201527f6c6564207468726f7567682064656c656761746563616c6c00000000000000006064820152608401610d05565b50600080516020615ba683398151915290565b6000341161177b57505050565b6000611788848484611f40565b90503481146117ca5760405162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a5908185b5bdd5b9d60921b6044820152606401610d05565b6117d5848484613161565b50505050565b600080516020615b668339815191526117f38161279e565b610db68787878787876133f7565b600061180c8161279e565b5061017380546001600160a01b0319166001600160a01b0392909216919091179055565b611848600080516020615b6683398151915233611efb565b6118855760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b6044820152606401610d05565b6117d5848484846137d7565b600061189c8161279e565b610160805463ffffffff60b01b1916600160c01b61ffff87811691820261ffff60b01b191692909217600160b01b8784169081029190911761ffff60a01b1916600160a01b938716938402179093556040805191825260208201939093529182015233907f93d3bfdb56bc52c00ef2f1ffdff11a306cb6e5f2ef404c9c1bcd5bf27e88c92f9060600160405180910390a250505050565b600080516020615b6683398151915261194b8161279e565b600083815261016260205260409020546119775760405162461bcd60e51b8152600401610d0590615100565b60006119856101618561277a565b604080516101808101825282548152600183015460208083019190915260028401546001600160a01b039081168385015260038501548116606084015260048501546080840152600585015460a0840152600685015490811660c0840152600160a01b900460ff16151560e0830152600784015461010083015260088401546101208301526009840154610140830152600a909301546101608201526000878152610162909352912054909150611a3b9061120b565b6001600160a01b03831660c0820152426101208201526040805160208101869052611a83910160408051601f1981840301815291905280516020909101206101669083612aaf565b8060800151341015611aca5760405162461bcd60e51b815260206004820152601060248201526f6e6f7420656e6f7567682066756e647360801b6044820152606401610d05565b8060e0015115611af557611af060038260600151836040015186856020015160016127a8565b611b11565b611b1160028260600151836040015186856020015160016127a8565b610172546001600160a01b031615611b545760a0810151600090611b389060016002613cf9565b61017254909150611b52906001600160a01b031682613e0b565b505b61016081015115611b7657611b76816060015182602001518360800151613161565b611b9881604001518261016001518360800151611b939190615368565b613e0b565b60405184907f92f64ca637d023f354075a4be751b169c1a8a9ccb6d33cdd0cb352054399572790600090a250505050565b61016054604051627eeac760e11b81526001600160a01b03838116600483015260036024830152600092839291169062fdd58e9060440160206040518083038186803b158015611c1857600080fd5b505afa158015611c2c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c509190614e87565b1115611c5e57506000919050565b611c6782612591565b15611c81575061016054600160a01b900461ffff16919050565b611c8a82610c32565b15611ca4575061016054600160b01b900461ffff16919050565b5061016054600160c01b900461ffff165b919050565b61109c338484846137d7565b600080516020615b668339815191526117ca8161279e565b838214611d205760405162461bcd60e51b815260206004820152601060248201526f185c9c985e5cc81b9bdd08195c5d585b60821b6044820152606401610d05565b611d2e8585858533866133f7565b5050505050565b600080611d4185613e4a565b80611d505750611d5085613e5d565b611d945760405162461bcd60e51b81526020600482015260156024820152746e6f7420455243373231206f72204552433131353560581b6044820152606401610d05565b611d9d8561276f565b15611ddf5760405162461bcd60e51b81526020600482015260126024820152716e6f7420737570706f72742062756e646c6560701b6044820152606401610d05565b611de8856113e8565b15611e755760405163152a902d60e11b815260048101859052602481018490526001600160a01b03861690632a55205a90604401604080518083038186803b158015611e3357600080fd5b505afa158015611e47573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e6b9190614a98565b9092509050611ef3565b6001600160a01b03851660009081526101716020526040902054600160a01b900461ffff1615611ef3576001600160a01b03851660009081526101716020526040902054611ed2908490600160a01b900461ffff16612710613cf9565b6001600160a01b038087166000908152610171602052604090205416925090505b935093915050565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b6000611f3182610c32565b80610c2c5750610c2c82612591565b600080611f4c8561276f565b1561207057604051635af67c8960e11b81526004810185905260009081906001600160a01b0388169063b5ecf9129060240160006040518083038186803b158015611f9657600080fd5b505afa158015611faa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611fd29190810190614ce0565b815191935091506000611fe58783613e70565b905060005b8281101561206657600061204d86838151811061201757634e487b7160e01b600052603260045260246000fd5b602002602001015186848151811061203f57634e487b7160e01b600052603260045260246000fd5b602002602001015185611d35565b915061205b9050818861531d565b965050600101611fea565b505050505061207f565b61207b858585611d35565b9150505b90505b9392505050565b612091614761565b61209d61016b8361277a565b6040805161018081018252825481526001830154602082015260028301546001600160a01b039081169282019290925260038301548216606082015260048301546080820152600583015460a0820152600683015491821660c0820152600160a01b90910460ff16151560e0820152600782015461010082015260088201546101208201526009820154610140820152600a9091015461016082015292915050565b612147614761565b61209d6101618361277a565b600080516020615b8683398151915261216b8161279e565b6001600160a01b0382166000818152610171602052604080822080546001600160b01b03191690555133917f8e70db61b60e9c9516e5635687db011153ad00e07f5f478698a3a7bb3d6a883f91a35050565b6121c5614761565b61209d6101668361277a565b600054610100900460ff16158080156121f15750600054600160ff909116105b8061220b5750303b15801561220b575060005460ff166001145b61226e5760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610d05565b6000805460ff191660011790558015612291576000805461ff0019166101001790555b612299613e7c565b6122a1613e7c565b6122a9613ea5565b6122b1613ed4565b6122bc600033612897565b6122e67f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e333612897565b61016080546001600160a01b0384166001600160b01b031990911617604b60a11b1763ffffffff60b01b1916627d004b60b21b179055801561146d576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15050565b60006123708161279e565b61017280546001600160a01b0384166001600160a01b03199091168117909155604080519182525133917fe8c4d4251ccaaa5d3e3937cf5c7c9d281260ff0b8bf5f914fb4dde280eee7dee919081900360200190a25050565b6123d1612cc3565b336001600160a01b03831614806123fb57506123fb600080516020615b8683398151915233611efb565b6124385760405162461bcd60e51b815260206004820152600e60248201526d1b9bdd08185d5d1a1bdc9a5e995960921b6044820152606401610d05565b6001600160a01b038216600090815261017460205260409020805460ff1916821580159182179092556124735750600061247183612513565b115b156124815761248182612d72565b61146d600161012e55565b6000828152606560205260409020600101546124a78161279e565b61109c8383612de1565b60008382846040516020016124c8939291906150a9565b60408051808303601f190181529181528151602092830120600081815261016590935291205490915060ff16156117d5576000818152610163602052604090208054611d2e906110a1565b60fb546040516371d4ed8d60e11b81526001600160a01b038381166004830152600092169063e3a9db1a9060240160206040518083038186803b15801561255957600080fd5b505afa15801561256d573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c2c9190614e87565b61016054604051627eeac760e11b81526001600160a01b03838116600483015260026024830152600092839291169062fdd58e9060440160206040518083038186803b1580156125e057600080fd5b505afa1580156125f4573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126189190614e87565b11806126b65750610173546001600160a01b0316158015906126b65750610173546040516370a0823160e01b81526001600160a01b03848116600483015260009216906370a082319060240160206040518083038186803b15801561267c57600080fd5b505afa158015612690573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126b49190614e87565b115b156126c357506001919050565b610172546001600160a01b03161580159061275a575061017254604051630ef40a6760e41b81526001600160a01b038481166004830152600092169063ef40a6709060240160206040518083038186803b15801561272057600080fd5b505afa158015612734573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127589190614e87565b115b1561276757506001919050565b506000919050565b6000610c2c82613f03565b60008181526001830160209081526040808320548352600285019091528120612082565b61131d8133613f16565b6127b06147df565b604080516001808252818301909252600091816020015b6127cf6147df565b8152602001906001900390816127c75790505090508188600381111561280557634e487b7160e01b600052602160045260246000fd5b9081600381111561282657634e487b7160e01b600052602160045260246000fd5b9052506001600160a01b0380881660208401528681166040840152851660608301526080820184905260a0820183905280518290829060009061287957634e487b7160e01b600052603260045260246000fd5b602002602001018190525061288d81612d1f565b5050505050505050565b6128a18282611efb565b61146d5760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556128d93390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b600081815260048301602052604090205460ff16612939575050565b6000818152600280840160209081526040808420805485526001808801845282862086905586865260048089018552838720805460ff1916905586835582820187905594820180546001600160a01b031990811690915560038084018054909216909155948201869055600582018690556006820180546001600160a81b0319169055600782018690556008820186905560098201869055600a90910185905592860190915282205484549092916129f091615368565b90506000846000018281548110612a1757634e487b7160e01b600052603260045260246000fd5b600091825260208083209091015480835260038801909152604080832086905586835282209190915585549091508190869085908110612a6757634e487b7160e01b600052603260045260246000fd5b6000918252602090912001558454859080612a9257634e487b7160e01b600052603160045260246000fd5b600190038181906000526020600020016000905590555050505050565b600082815260048401602052604090205460ff1615612baa5760008281526002848101602090815260408084208551808255868401516001808401919091558784015195830180546001600160a01b03199081166001600160a01b039889161790915560608901516003850180549092169088161790556080880151600484015560a0880151600584015560c088015160068401805460e08b0151929098166001600160a81b031990981697909717600160a01b911515919091021790955561010087015160078301556101208701516008830155610140870151600983015561016090960151600a90910155938352940190935290912055565b6000828152600484810160209081526040808420805460ff19166001908117909155600280890184528286208751815587850151818401558784015191810180546001600160a01b039384166001600160a01b031991821617909155606089015160038084018054928616929093169190911790915560808901519682019690965560a0880151600582015560c088015160068201805460e08b01511515600160a01b026001600160a81b0319909116929094169190911792909217909155610100870151600782015561012087015160088201556101408701516009820155610160870151600a9091015587549388018352818520849055838101885587855282852090930186905593518352940190935290912055565b600261012e541415612d175760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610d05565b600261012e55565b805160005b8181101561109c576000838281518110612d4e57634e487b7160e01b600052603260045260246000fd5b60200260200101519050612d6181613f6f565b50600101612d24565b600161012e55565b60fb546040516351cff8d960e01b81526001600160a01b038381166004830152909116906351cff8d9906024015b600060405180830381600087803b158015612dba57600080fd5b505af1158015611d2e573d6000803e3d6000fd5b6000610c2c8263152a902d60e11b61416a565b612deb8282611efb565b1561146d5760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e361146d8161279e565b7f4910fdfa16fed3260ed0e7147f7cc6da11a60208b5b9406d12a635614ffd91435460ff1615612ea55761109c83614186565b826001600160a01b03166352d1902d6040518163ffffffff1660e01b815260040160206040518083038186803b158015612ede57600080fd5b505afa925050508015612f0e575060408051601f3d908101601f19168201909252612f0b91810190614e87565b60015b612f715760405162461bcd60e51b815260206004820152602e60248201527f45524331393637557067726164653a206e657720696d706c656d656e7461746960448201526d6f6e206973206e6f74205555505360901b6064820152608401610d05565b600080516020615ba68339815191528114612fe05760405162461bcd60e51b815260206004820152602960248201527f45524331393637557067726164653a20756e737570706f727465642070726f786044820152681a58589b195555525160ba1b6064820152608401610d05565b5061109c838383614222565b8047101561303c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610d05565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613089576040519150601f19603f3d011682016040523d82523d6000602084013e61308e565b606091505b505090508061109c5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610d05565b60fb5460405163f340fa0160e01b81526001600160a01b0384811660048301529091169063f340fa019083906024016000604051808303818588803b15801561314d57600080fd5b505af1158015610db6573d6000803e3d6000fd5b613169612cc3565b6131728361276f565b1561336757604051635af67c8960e11b81526004810183905260009081906001600160a01b0386169063b5ecf9129060240160006040518083038186803b1580156131bc57600080fd5b505afa1580156131d0573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526131f89190810190614ce0565b81519193509150600061320b8583613e70565b905060005b8281101561335d5760008061327487848151811061323e57634e487b7160e01b600052603260045260246000fd5b602002602001015187858151811061326657634e487b7160e01b600052603260045260246000fd5b602002602001015186611d35565b90925090506001600160a01b03821661328e57505061334b565b6132988282613e0b565b7fe3af12256b9679feef6d76d73f3373020e13baa6b7c5bfba4d28c4b96318c92a8784815181106132d957634e487b7160e01b600052603260045260246000fd5b602002602001015187858151811061330157634e487b7160e01b600052603260045260246000fd5b6020026020010151848460405161334094939291906001600160a01b039485168152602081019390935292166040820152606081019190915260800190565b60405180910390a150505b80613355816153c2565b915050613210565b50505050506112f6565b600080613375858585611d35565b90925090506001600160a01b03821661338f5750506112f6565b6133998282613e0b565b604080516001600160a01b038781168252602082018790528416818301526060810183905290517fe3af12256b9679feef6d76d73f3373020e13baa6b7c5bfba4d28c4b96318c92a9181900360800190a1505061109c600161012e55565b6133ff612cc3565b6000856001600160401b0381111561342757634e487b7160e01b600052604160045260246000fd5b60405190808252806020026020018201604052801561346057816020015b61344d6147df565b8152602001906001900390816134455790505b50905060005b868110156137b95760006134ad89898481811061349357634e487b7160e01b600052603260045260246000fd5b90506020020160208101906134a891906148fc565b613e5d565b9050801561352b5760028383815181106134d757634e487b7160e01b600052603260045260246000fd5b602002602001015160000190600381111561350257634e487b7160e01b600052602160045260246000fd5b9081600381111561352357634e487b7160e01b600052602160045260246000fd5b90525061361b565b61356889898481811061354e57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061356391906148fc565b613e4a565b6135a95760405162461bcd60e51b8152602060048201526012602482015271696e76616c696420746f6b656e207479706560701b6044820152606401610d05565b60038383815181106135cb57634e487b7160e01b600052603260045260246000fd5b60200260200101516000019060038111156135f657634e487b7160e01b600052602160045260246000fd5b9081600381111561361757634e487b7160e01b600052602160045260246000fd5b9052505b88888381811061363b57634e487b7160e01b600052603260045260246000fd5b905060200201602081019061365091906148fc565b83838151811061367057634e487b7160e01b600052603260045260246000fd5b6020026020010151602001906001600160a01b031690816001600160a01b031681525050848383815181106136b557634e487b7160e01b600052603260045260246000fd5b6020026020010151604001906001600160a01b031690816001600160a01b031681525050838383815181106136fa57634e487b7160e01b600052603260045260246000fd5b6020026020010151606001906001600160a01b031690816001600160a01b03168152505086868381811061373e57634e487b7160e01b600052603260045260246000fd5b9050602002013583838151811061376557634e487b7160e01b600052603260045260246000fd5b60200260200101516080018181525050600183838151811061379757634e487b7160e01b600052603260045260246000fd5b602090810291909101015160a0015250806137b1816153c2565b915050613466565b506137c381612d1f565b506137cf600161012e55565b505050505050565b600081116138175760405162461bcd60e51b815260206004820152600d60248201526c696e76616c696420707269636560981b6044820152606401610d05565b600061382284613e4a565b9050600061382f85613e5d565b9050818061383a5750805b6138795760405162461bcd60e51b815260206004820152601060248201526f756e737570706f72746564207479706560801b6044820152606401610d05565b8015613a06576040516331a9108f60e11b8152600481018590526001600160a01b038088169190871690636352211e9060240160206040518083038186803b1580156138c457600080fd5b505afa1580156138d8573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906138fc9190614918565b6001600160a01b03161461393e5760405162461bcd60e51b81526020600482015260096024820152681b9bdd081bdddb995960ba1b6044820152606401610d05565b60405163e985e9c560e01b81526001600160a01b03878116600483015230602483015286169063e985e9c59060440160206040518083038186803b15801561398557600080fd5b505afa158015613999573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906139bd9190614e53565b613a015760405162461bcd60e51b815260206004820152601560248201527436bab9ba1030b8383937bb32903a3930b739b332b960591b6044820152606401610d05565b613b84565b604051627eeac760e11b81526001600160a01b038781166004830152602482018690526000919087169062fdd58e9060440160206040518083038186803b158015613a5057600080fd5b505afa158015613a64573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613a889190614e87565b11613ac15760405162461bcd60e51b81526020600482015260096024820152681b9bdd081bdddb995960ba1b6044820152606401610d05565b60405163e985e9c560e01b81526001600160a01b03878116600483015230602483015286169063e985e9c59060440160206040518083038186803b158015613b0857600080fd5b505afa158015613b1c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190613b409190614e53565b613b845760405162461bcd60e51b815260206004820152601560248201527436bab9ba1030b8383937bb32903a3930b739b332b960591b6044820152606401610d05565b6000858786604051602001613b9b939291906150a9565b6040516020818303038152906040528051906020012090506000613bc0878787611f40565b6000838152610165602052604090205490915060ff1615613c4c5760008281526101636020526040902060048101869055613c0b613bfd8a611bc9565b879061ffff16612710613cf9565b6005820155600a810182905580546040517ff3ecdc9ffda52c5ad69793c567cb456f83bba2d14f196542e0be80c919a8bda390600090a250505050506117d5565b613c54614761565b610170548152602081018790526001600160a01b03808a1660408301528816606082015260808101869052613c8b613bfd8a611bc9565b60a082015284151560e0820152426101008201526101608101829052613cb46101618483612aaf565b613cc361017080546001019055565b80516040517ff3ecdc9ffda52c5ad69793c567cb456f83bba2d14f196542e0be80c919a8bda390600090a2505050505050505050565b6000808211613d3d5760405162461bcd60e51b815260206004820152601060248201526f4469766973696f6e206279207a65726f60801b6044820152606401610d05565b83613d4a57506000612082565b6000613d568486615349565b905083613d638683615335565b1415613d7b57613d738382615335565b915050612082565b6000613d878487615335565b90506000613d9585886153dd565b90506000613da38688615335565b90506000613db187896153dd565b9050613dfe613dca88613dc48685614247565b90613e70565b613df8613dd78686614247565b613df8613de48987614247565b613df88d613df28c8b614247565b90614247565b90614253565b9998505050505050505050565b6001600160a01b0382166000908152610174602052604090205460ff1615613e375761146d8282613105565b61146d6001600160a01b03831682612fec565b6000610c2c82636cdb3d1360e11b61416a565b6000610c2c826380ac58cd60e01b61416a565b60006120828284615335565b600054610100900460ff16613ea35760405162461bcd60e51b8152600401610d05906151bc565b565b600054610100900460ff16613ecc5760405162461bcd60e51b8152600401610d05906151bc565b613ea361425f565b600054610100900460ff16613efb5760405162461bcd60e51b8152600401610d05906151bc565b613ea3614319565b6000610c2c8263065164a760e11b61416a565b613f208282611efb565b61146d57613f2d81614340565b613f38836020614352565b604051602001613f49929190615034565b60408051601f198184030181529082905262461bcd60e51b8252610d05916004016150cd565b600181516003811115613f9257634e487b7160e01b600052602160045260246000fd5b141561402a5780602001516001600160a01b03166323b872dd826040015183606001518460a001516040518463ffffffff1660e01b8152600401613fd8939291906150a9565b602060405180830381600087803b158015613ff257600080fd5b505af1158015614006573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061146d9190614e53565b60028151600381111561404d57634e487b7160e01b600052602160045260246000fd5b14156140b8578060a001516001146140785760405163efcc00b160e01b815260040160405180910390fd5b80602001516001600160a01b03166323b872dd8260400151836060015184608001516040518463ffffffff1660e01b8152600401612da0939291906150a9565b6003815160038111156140db57634e487b7160e01b600052602160045260246000fd5b14156141515760208101516040808301516060840151608085015160a0808701519451637921219560e11b81526001600160a01b0394851660048201529284166024840152604483019190915260648201939093526084810192909252600060a48301529091169063f242432a9060c401612da0565b604051631e4cbc7f60e21b815260040160405180910390fd5b600061417583614533565b801561208257506120828383614566565b6001600160a01b0381163b6141f35760405162461bcd60e51b815260206004820152602d60248201527f455243313936373a206e657720696d706c656d656e746174696f6e206973206e60448201526c1bdd08184818dbdb9d1c9858dd609a1b6064820152608401610d05565b600080516020615ba683398151915280546001600160a01b0319166001600160a01b0392909216919091179055565b61422b836145ef565b6000825111806142385750805b1561109c576117d5838361462f565b60006120828284615349565b6000612082828461531d565b600054610100900460ff166142865760405162461bcd60e51b8152600401610d05906151bc565b60405161429290614816565b604051809103906000f0801580156142ae573d6000803e3d6000fd5b5060fb80546001600160a01b0319166001600160a01b039290921691821790556040805163204a7f0760e21b81529051638129fc1c9160048082019260009290919082900301818387803b15801561430557600080fd5b505af11580156117d5573d6000803e3d6000fd5b600054610100900460ff16612d6a5760405162461bcd60e51b8152600401610d05906151bc565b6060610c2c6001600160a01b03831660145b60606000614361836002615349565b61436c90600261531d565b6001600160401b0381111561439157634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156143bb576020820181803683370190505b509050600360fc1b816000815181106143e457634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061442157634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a9053506000614445846002615349565b61445090600161531d565b90505b60018111156144e4576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061449257634e487b7160e01b600052603260045260246000fd5b1a60f81b8282815181106144b657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936144dd816153ab565b9050614453565b5083156120825760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610d05565b6000614546826301ffc9a760e01b614566565b8015610c2c575061455f826001600160e01b0319614566565b1592915050565b604080516001600160e01b03198316602480830191909152825180830390910181526044909101909152602080820180516001600160e01b03166301ffc9a760e01b178152825160009392849283928392918391908a617530fa92503d915060005190508280156145d8575060208210155b80156145e45750600081115b979650505050505050565b6145f881614186565b6040516001600160a01b038216907fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a250565b60606001600160a01b0383163b6146975760405162461bcd60e51b815260206004820152602660248201527f416464726573733a2064656c65676174652063616c6c20746f206e6f6e2d636f6044820152651b9d1c9858dd60d21b6064820152608401610d05565b600080846001600160a01b0316846040516146b29190615018565b600060405180830381855af49150503d80600081146146ed576040519150601f19603f3d011682016040523d82523d6000602084013e6146f2565b606091505b509150915061471a8282604051806060016040528060278152602001615bc660279139614723565b95945050505050565b60608315614732575081612082565b61208283838151156147475781518083602001fd5b8060405162461bcd60e51b8152600401610d0591906150cd565b604051806101800160405280600081526020016000815260200160006001600160a01b0316815260200160006001600160a01b03168152602001600081526020016000815260200160006001600160a01b03168152602001600015158152602001600081526020016000815260200160008152602001600081525090565b6040805160c08101909152806000815260006020820181905260408201819052606082018190526080820181905260a09091015290565b61070f8061545783390190565b60008083601f840112614834578182fd5b5081356001600160401b0381111561484a578182fd5b6020830191508360208260051b850101111561486557600080fd5b9250929050565b600082601f83011261487c578081fd5b8151602061489161488c836152fa565b6152ca565b80838252828201915082860187848660051b89010111156148b0578586fd5b855b858110156148ce578151845292840192908401906001016148b2565b5090979650505050505050565b803560048110611cb557600080fd5b803561ffff81168114611cb557600080fd5b60006020828403121561490d578081fd5b813561208281615433565b600060208284031215614929578081fd5b815161208281615433565b600080600060608486031215614948578182fd5b833561495381615433565b9250602084013561496381615433565b9150614971604085016148ea565b90509250925092565b6000806000806080858703121561498f578182fd5b843561499a81615433565b935060208501356149aa81615433565b93969395505050506040820135916060013590565b600080604083850312156149d1578182fd5b82356149dc81615433565b915060208301356149ec81615448565b809150509250929050565b60008060408385031215614a09578182fd5b8235614a1481615433565b91506020838101356001600160401b0380821115614a30578384fd5b818601915086601f830112614a43578384fd5b813581811115614a5557614a5561541d565b614a67601f8201601f191685016152ca565b91508082528784828501011115614a7c578485fd5b8084840185840137810190920192909252919491935090915050565b60008060408385031215614aaa578182fd5b8251614ab581615433565b6020939093015192949293505050565b600080600060608486031215614ad9578081fd5b8335614ae481615433565b9250602084013591506040840135614afb81615433565b809150509250925092565b600080600060608486031215614b1a578081fd5b8335614b2581615433565b95602085013595506040909401359392505050565b600080600080600060608688031215614b51578283fd5b85356001600160401b0380821115614b67578485fd5b614b7389838a01614823565b90975095506020880135915080821115614b8b578485fd5b50614b9888828901614823565b9094509250506040860135614bac81615433565b809150509295509295909350565b60008060008060008060808789031215614bd2578384fd5b86356001600160401b0380821115614be8578586fd5b614bf48a838b01614823565b90985096506020890135915080821115614c0c578586fd5b50614c1989828a01614823565b9095509350506040870135614c2d81615433565b91506060870135614c3d81615433565b809150509295509295509295565b60008060008060008060608789031215614c63578384fd5b86356001600160401b0380821115614c79578586fd5b614c858a838b01614823565b90985096506020890135915080821115614c9d578586fd5b614ca98a838b01614823565b90965094506040890135915080821115614cc1578384fd5b50614cce89828a01614823565b979a9699509497509295939492505050565b60008060408385031215614cf2578182fd5b82516001600160401b0380821115614d08578384fd5b818501915085601f830112614d1b578384fd5b81516020614d2b61488c836152fa565b8083825282820191508286018a848660051b8901011115614d4a578889fd5b8896505b84871015614d75578051614d6181615433565b835260019690960195918301918301614d4e565b5091880151919650909350505080821115614d8e578283fd5b50614d9b8582860161486c565b9150509250929050565b60008060208385031215614db7578182fd5b82356001600160401b0380821115614dcd578384fd5b818501915085601f830112614de0578384fd5b813581811115614dee578485fd5b86602060c083028501011115614e02578485fd5b60209290920196919550909350505050565b60008060208385031215614e26578182fd5b82356001600160401b03811115614e3b578283fd5b614e4785828601614823565b90969095509350505050565b600060208284031215614e64578081fd5b815161208281615448565b600060208284031215614e80578081fd5b5035919050565b600060208284031215614e98578081fd5b5051919050565b60008060408385031215614eb1578182fd5b8235915060208301356149ec81615433565b600060208284031215614ed4578081fd5b81356001600160e01b031981168114612082578182fd5b60008060008060008060c08789031215614f03578384fd5b614f0c876148db565b95506020870135614f1c81615433565b94506040870135614f2c81615433565b93506060870135614f3c81615433565b9598949750929560808101359460a0909101359350915050565b600060c08284031215614f67578081fd5b60405160c081018181106001600160401b0382111715614f8957614f8961541d565b604052614f95836148db565b81526020830135614fa581615433565b60208201526040830135614fb881615433565b60408201526060830135614fcb81615433565b60608201526080838101359082015260a0928301359281019290925250919050565b600080600060608486031215615001578081fd5b61500a846148ea565b9250614963602085016148ea565b6000825161502a81846020870161537f565b9190910192915050565b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161506c81601785016020880161537f565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161509d81602884016020880161537f565b01602801949350505050565b6001600160a01b039384168152919092166020820152604081019190915260600190565b60208152600082518060208401526150ec81604085016020870161537f565b601f01601f19169190910160400192915050565b6020808252600a90820152691a5b9d985b1a59081a5960b21b604082015260600190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b19195b1959d85d1958d85b1b60a21b606082015260800190565b6020808252602c908201527f46756e6374696f6e206d7573742062652063616c6c6564207468726f7567682060408201526b6163746976652070726f787960a01b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000610180820190508251825260208301516020830152604083015161523860408401826001600160a01b03169052565b50606083015161525360608401826001600160a01b03169052565b506080830151608083015260a083015160a083015260c083015161528260c08401826001600160a01b03169052565b5060e083015161529660e084018215159052565b5061010083810151908301526101208084015190830152610140808401519083015261016092830151929091019190915290565b604051601f8201601f191681016001600160401b03811182821017156152f2576152f261541d565b604052919050565b60006001600160401b038211156153135761531361541d565b5060051b60200190565b60008219821115615330576153306153f1565b500190565b60008261534457615344615407565b500490565b6000816000190483118215151615615363576153636153f1565b500290565b60008282101561537a5761537a6153f1565b500390565b60005b8381101561539a578181015183820152602001615382565b838111156117d55750506000910152565b6000816153ba576153ba6153f1565b506000190190565b60006000198214156153d6576153d66153f1565b5060010190565b6000826153ec576153ec615407565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b038116811461131d57600080fd5b801515811461131d57600080fdfe608060405234801561001057600080fd5b506106ef806100206000396000f3fe6080604052600436106100705760003560e01c80638da5cb5b1161004e5780638da5cb5b146100c1578063e3a9db1a146100ee578063f2fde38b14610132578063f340fa011461015257600080fd5b806351cff8d914610075578063715018a6146100975780638129fc1c146100ac575b600080fd5b34801561008157600080fd5b50610095610090366004610612565b610165565b005b3480156100a357600080fd5b506100956101dc565b3480156100b857600080fd5b506100956101f0565b3480156100cd57600080fd5b506033546040516001600160a01b0390911681526020015b60405180910390f35b3480156100fa57600080fd5b50610124610109366004610612565b6001600160a01b031660009081526065602052604090205490565b6040519081526020016100e5565b34801561013e57600080fd5b5061009561014d366004610612565b610306565b610095610160366004610612565b61037c565b61016d6103ee565b6001600160a01b03811660008181526065602052604081208054919055906101959082610448565b816001600160a01b03167f7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5826040516101d091815260200190565b60405180910390a25050565b6101e46103ee565b6101ee6000610566565b565b600054610100900460ff16158080156102105750600054600160ff909116105b8061022a5750303b15801561022a575060005460ff166001145b6102925760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b60648201526084015b60405180910390fd5b6000805460ff1916600117905580156102b5576000805461ff0019166101001790555b6102bd6105b8565b8015610303576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b50565b61030e6103ee565b6001600160a01b0381166103735760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610289565b61030381610566565b6103846103ee565b6001600160a01b0381166000908152606560205260408120805434928392916103ae908490610680565b90915550506040518181526001600160a01b038316907f2da466a7b24304f47e87fa2e1e5a81b9831ce54fec19055ce277ca2f39ba42c4906020016101d0565b6033546001600160a01b031633146101ee5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610289565b804710156104985760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610289565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146104e5576040519150601f19603f3d011682016040523d82523d6000602084013e6104ea565b606091505b50509050806105615760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610289565b505050565b603380546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b600054610100900460ff166105df5760405162461bcd60e51b815260040161028990610635565b6101ee600054610100900460ff166106095760405162461bcd60e51b815260040161028990610635565b6101ee33610566565b600060208284031215610623578081fd5b813561062e816106a4565b9392505050565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000821982111561069f57634e487b7160e01b81526011600452602481fd5b500190565b6001600160a01b038116811461030357600080fdfea2646970667358221220f45d265415524d225dfd95877da512ff66555411b31749bfc5d12fa9a24752e264736f6c63430008040033a8a7bc421f721cb936ea99efdad79237e6ee0b871a2a08cf648691f9584cdc775620a1113a72b02a617976b3f6b15600dd7a8b3a916a9ca01e23119d989a0543360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc416464726573733a206c6f772d6c6576656c2064656c65676174652063616c6c206661696c6564a2646970667358221220a439f3817548dd61395f2379aff76b014a7ee41868b5c6d8d44b9e1bf37e512364736f6c63430008040033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.