Mumbai Testnet

Contract

0x1Fc79E01fe724Ef4A1f8995f1299B90565a6AD39

Overview

MATIC Balance

Polygon PoS Chain LogoPolygon PoS Chain LogoPolygon PoS Chain Logo0 MATIC

Multichain Info

N/A
Transaction Hash
Method
Block
From
To
Value
0x60806040158510982021-07-02 21:30:361000 days ago1625261436IN
 Create: Directory
0 MATIC0.1059653220

Parent Txn Hash Block From To Value
View All Internal Transactions
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
Directory

Compiler Version
v0.8.3+commit.8d00100c

Optimization Enabled:
Yes with 100 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 53 : Directory.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";

import "hardhat/console.sol";

import "./Submissions.sol";
import "./Uniquettes.sol";

contract Directory is ContextUpgradeable, Common, Submissions, Uniquettes {
    event SubmissionFunded(
        address indexed operator,
        address indexed collector,
        uint256 indexed tokenId,
        string submissionHash,
        uint256 appreciatedPrice,
        uint256 payment
    );

    mapping(uint256 => string) internal _fundedSubmissionHashByUniquetteTokenId;

    Token private _token;
    Vault private _vault;
    string private _tokensBaseURI;

    // This mapping helps with un-funded uniquettes to have a proper representation in other platforms such as OpenSea
    mapping(uint256 => string) internal _highlightedSubmissionHashByUniquetteTokenId;

    function initialize(
        string memory name,
        string memory symbol,
        string memory tokensBaseURI,
        address token,
        address payable vault,
        address payable treasury,
        address payable marketer,
        uint256 protocolFee,
        uint256 minMetadataVersion,
        uint256 currentMetadataVersion,
        uint256 maxPriceAppreciation,
        uint256 submissionDeposit
    ) public initializer {
        __Common_init(
            protocolFee,
            minMetadataVersion,
            currentMetadataVersion,
            maxPriceAppreciation,
            submissionDeposit
        );

        __Uniquettes_init(name, symbol, token, vault, treasury, marketer);
        __Submissions_init(treasury);

        _token = Token(token);
        _vault = Vault(vault);
        _tokensBaseURI = tokensBaseURI;

        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(GOVERNOR_ROLE, _msgSender());
    }

    //
    // Admin functions
    //
    function setTreasuryAddress(address payable newAddress) public override(Uniquettes, Submissions) isGovernor() {
        Uniquettes.setTreasuryAddress(newAddress);
        Submissions.setTreasuryAddress(newAddress);
    }

    /**
     * This is a temporary helper to allow fix original minted uniquettes highlighted submissions
     */
    function setHighlightedSubmission(uint256 tokenId, string calldata hash) public isGovernor() {
        _highlightedSubmissionHashByUniquetteTokenId[tokenId] = hash;
    }

    //
    // Overrides
    //
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlUpgradeable, Submissions, Uniquettes)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    //
    // Customized ERC-721 functions
    //
    function tokenURI(uint256 tokenId) public view virtual override tokenExists(tokenId) returns (string memory) {
        if (bytes(_fundedSubmissionHashByUniquetteTokenId[tokenId]).length != 0) {
            // For already funded uniquettes use their funded submission metadata hash
            return string(abi.encodePacked(_tokensBaseURI, _fundedSubmissionHashByUniquetteTokenId[tokenId]));
        } else {
            // For un-funded uniquettes use what is chosen as their highlighted submission (usually last funded)
            return string(abi.encodePacked(_tokensBaseURI, _highlightedSubmissionHashByUniquetteTokenId[tokenId]));
        }
    }

    //
    // Unique Directory functions
    //
    function uniquetteGetFundedSubmission(uint256 tokenId) public view virtual returns (string memory) {
        return _fundedSubmissionHashByUniquetteTokenId[tokenId];
    }

    // We must mint a new ERC-721 token for approved submission for a new Uniquette
    function _afterSubmissionApprove(string memory hash) internal virtual override(Submissions) {
        if (_submissions[hash].tokenId > 0) {
            // Skip if there is already a Uniquette for this submission.
            return;
        }

        require(_submissions[hash].status == SubmissionStatus.Approved, "DIRECTORY/SUBMISSION_NOT_APPROVED");

        // Mint the new uniquette into Vault
        uint256 newTokenId = uniquetteMint();

        // Update submission with the new token ID
        _submissions[hash].tokenId = newTokenId;

        // Take last approved submission as highlight for cases when there's no funded submission yet
        _highlightedSubmissionHashByUniquetteTokenId[newTokenId] = hash;
    }

    function submissionFund(
        address to,
        uint256 tokenId,
        string calldata submissionHash
    )
        public
        payable
        virtual
        tokenExists(tokenId)
        submissionExists(submissionHash)
        submissionIsApproved(submissionHash)
        submissionIsUpToDate(submissionHash)
        nonReentrant
    {
        Submission memory submission = submissionGetByHash(submissionHash);

        {
            require(submission.tokenId == tokenId, "DIRECTORY/INVALID_SUBMISSION_FOR_UNIQUETTE");
            _fundedSubmissionHashByUniquetteTokenId[tokenId] = submissionHash;
            _markSubmissionAsFunded(submissionHash);
        }

        {
            uint256 appreciatedPrice;
            (, appreciatedPrice, , ) = _uniquetteTakeOver(_msgSender(), to, tokenId, submission.addedValue);

            _token.mint(submission.author, submission.reward);
            emit SubmissionFunded(_msgSender(), to, tokenId, submissionHash, appreciatedPrice, msg.value);
        }
    }

    function uniquetteCollect(address to, uint256 tokenId) public payable virtual tokenExists(tokenId) nonReentrant {
        require(
            bytes(_fundedSubmissionHashByUniquetteTokenId[tokenId]).length > 0,
            "DIRECTORY/NO_SUBMISSION_FUNDED_FOR_UNIQUETTE"
        );

        _uniquetteTakeOver(_msgSender(), to, tokenId, 0);
    }

    function uniquetteListOnOpenSea(uint256 tokenId) public tokenExists(tokenId) nonReentrant {
        require(
            bytes(_fundedSubmissionHashByUniquetteTokenId[tokenId]).length > 0 ||
            bytes(_highlightedSubmissionHashByUniquetteTokenId[tokenId]).length > 0
            ,
            "DIRECTORY/NO_SUBMISSION_FUNDED_OR_APPROVED_FOR_UNIQUETTE"
        );

        Uniquette memory uniquette = uniquetteGetById(tokenId);

        require(
            uniquette.owner == _msgSender() || hasRole(GOVERNOR_ROLE, _msgSender()),
            "DIRECTORY/NOT_OWNER_OR_GOVERNOR"
        );

        _putForSale(
            uniquette.owner,
            tokenId,
            calculateEffectivePrice(_msgSender(), address(0), uniquette)
        );
    }

    function uniquetteRemoveFromOpenSea(uint256 tokenId) public tokenExists(tokenId) nonReentrant {
        require(
            bytes(_fundedSubmissionHashByUniquetteTokenId[tokenId]).length > 0 ||
            bytes(_highlightedSubmissionHashByUniquetteTokenId[tokenId]).length > 0
            ,
            "DIRECTORY/NO_SUBMISSION_FUNDED_OR_APPROVED_FOR_UNIQUETTE"
        );

        Uniquette memory uniquette = uniquetteGetById(tokenId);

        require(
            uniquette.owner == _msgSender() || hasRole(GOVERNOR_ROLE, _msgSender()),
            "DIRECTORY/NOT_OWNER_OR_GOVERNOR"
        );

        _putOffSale(
            uniquette.owner,
            tokenId
        );
    }
}

File 2 of 53 : Initializable.sol
// SPDX-License-Identifier: MIT

// solhint-disable-next-line compiler-version
pragma solidity ^0.8.0;

/**
 * @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 a proxied contract can't have 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.
 *
 * 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.
 */
abstract contract Initializable {

    /**
     * @dev Indicates that the contract has been initialized.
     */
    bool private _initialized;

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

    /**
     * @dev Modifier to protect an initializer function from being invoked twice.
     */
    modifier initializer() {
        require(_initializing || !_initialized, "Initializable: contract is already initialized");

        bool isTopLevelCall = !_initializing;
        if (isTopLevelCall) {
            _initializing = true;
            _initialized = true;
        }

        _;

        if (isTopLevelCall) {
            _initializing = false;
        }
    }
}

File 3 of 53 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @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
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize, which returns 0 for contracts in
        // construction, since the code is only stored at the end of the
        // constructor execution.

        uint256 size;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 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");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (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 functionCall(target, data, "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");
        require(isContract(target), "Address: call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(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) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // 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

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 4 of 53 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    bytes16 private constant alphabet = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = alphabet[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

}

File 5 of 53 : ReentrancyGuardUpgradeable.sol
// SPDX-License-Identifier: MIT

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 initializer {
        __ReentrancyGuard_init_unchained();
    }

    function __ReentrancyGuard_init_unchained() internal initializer {
        _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 make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 6 of 53 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControlUpgradeable {
    function hasRole(bytes32 role, address account) external view returns (bool);
    function getRoleAdmin(bytes32 role) external view returns (bytes32);
    function grantRole(bytes32 role, address account) external;
    function revokeRole(bytes32 role, address account) external;
    function renounceRole(bytes32 role, address account) external;
}

/**
 * @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 initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
    }

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

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @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 {_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 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]{20}) is missing role (0x[0-9a-f]{32})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

    /**
     * @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 override returns (bool) {
        return _roles[role].members[account];
    }

    /**
     * @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]{20}) is missing role (0x[0-9a-f]{32})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if(!hasRole(role, account)) {
            revert(string(abi.encodePacked(
                "AccessControl: account ",
                StringsUpgradeable.toHexString(uint160(account), 20),
                " 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 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.
     */
    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.
     */
    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 granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    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.
     *
     * [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}.
     * ====
     */
    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 {
        emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
    uint256[49] private __gap;
}

File 7 of 53 : ContextUpgradeable.sol
// SPDX-License-Identifier: MIT

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 initializer {
        __Context_init_unchained();
    }

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

    function _msgData() internal view virtual returns (bytes calldata) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
    uint256[50] private __gap;
}

File 8 of 53 : console.sol
// SPDX-License-Identifier: MIT
pragma solidity >= 0.4.22 <0.9.0;

library console {
	address constant CONSOLE_ADDRESS = address(0x000000000000000000636F6e736F6c652e6c6f67);

	function _sendLogPayload(bytes memory payload) private view {
		uint256 payloadLength = payload.length;
		address consoleAddress = CONSOLE_ADDRESS;
		assembly {
			let payloadStart := add(payload, 32)
			let r := staticcall(gas(), consoleAddress, payloadStart, payloadLength, 0, 0)
		}
	}

	function log() internal view {
		_sendLogPayload(abi.encodeWithSignature("log()"));
	}

	function logInt(int p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(int)", p0));
	}

	function logUint(uint p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint)", p0));
	}

	function logString(string memory p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
	}

	function logBool(bool p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
	}

	function logAddress(address p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
	}

	function logBytes(bytes memory p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes)", p0));
	}

	function logBytes1(bytes1 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes1)", p0));
	}

	function logBytes2(bytes2 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes2)", p0));
	}

	function logBytes3(bytes3 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes3)", p0));
	}

	function logBytes4(bytes4 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes4)", p0));
	}

	function logBytes5(bytes5 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes5)", p0));
	}

	function logBytes6(bytes6 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes6)", p0));
	}

	function logBytes7(bytes7 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes7)", p0));
	}

	function logBytes8(bytes8 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes8)", p0));
	}

	function logBytes9(bytes9 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes9)", p0));
	}

	function logBytes10(bytes10 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes10)", p0));
	}

	function logBytes11(bytes11 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes11)", p0));
	}

	function logBytes12(bytes12 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes12)", p0));
	}

	function logBytes13(bytes13 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes13)", p0));
	}

	function logBytes14(bytes14 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes14)", p0));
	}

	function logBytes15(bytes15 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes15)", p0));
	}

	function logBytes16(bytes16 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes16)", p0));
	}

	function logBytes17(bytes17 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes17)", p0));
	}

	function logBytes18(bytes18 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes18)", p0));
	}

	function logBytes19(bytes19 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes19)", p0));
	}

	function logBytes20(bytes20 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes20)", p0));
	}

	function logBytes21(bytes21 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes21)", p0));
	}

	function logBytes22(bytes22 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes22)", p0));
	}

	function logBytes23(bytes23 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes23)", p0));
	}

	function logBytes24(bytes24 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes24)", p0));
	}

	function logBytes25(bytes25 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes25)", p0));
	}

	function logBytes26(bytes26 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes26)", p0));
	}

	function logBytes27(bytes27 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes27)", p0));
	}

	function logBytes28(bytes28 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes28)", p0));
	}

	function logBytes29(bytes29 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes29)", p0));
	}

	function logBytes30(bytes30 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes30)", p0));
	}

	function logBytes31(bytes31 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes31)", p0));
	}

	function logBytes32(bytes32 p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bytes32)", p0));
	}

	function log(uint p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint)", p0));
	}

	function log(string memory p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string)", p0));
	}

	function log(bool p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool)", p0));
	}

	function log(address p0) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address)", p0));
	}

	function log(uint p0, uint p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint)", p0, p1));
	}

	function log(uint p0, string memory p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string)", p0, p1));
	}

	function log(uint p0, bool p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool)", p0, p1));
	}

	function log(uint p0, address p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address)", p0, p1));
	}

	function log(string memory p0, uint p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint)", p0, p1));
	}

	function log(string memory p0, string memory p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string)", p0, p1));
	}

	function log(string memory p0, bool p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool)", p0, p1));
	}

	function log(string memory p0, address p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address)", p0, p1));
	}

	function log(bool p0, uint p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint)", p0, p1));
	}

	function log(bool p0, string memory p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string)", p0, p1));
	}

	function log(bool p0, bool p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool)", p0, p1));
	}

	function log(bool p0, address p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address)", p0, p1));
	}

	function log(address p0, uint p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint)", p0, p1));
	}

	function log(address p0, string memory p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string)", p0, p1));
	}

	function log(address p0, bool p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool)", p0, p1));
	}

	function log(address p0, address p1) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address)", p0, p1));
	}

	function log(uint p0, uint p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint)", p0, p1, p2));
	}

	function log(uint p0, uint p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string)", p0, p1, p2));
	}

	function log(uint p0, uint p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool)", p0, p1, p2));
	}

	function log(uint p0, uint p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address)", p0, p1, p2));
	}

	function log(uint p0, string memory p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint)", p0, p1, p2));
	}

	function log(uint p0, string memory p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,string)", p0, p1, p2));
	}

	function log(uint p0, string memory p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool)", p0, p1, p2));
	}

	function log(uint p0, string memory p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,address)", p0, p1, p2));
	}

	function log(uint p0, bool p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint)", p0, p1, p2));
	}

	function log(uint p0, bool p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string)", p0, p1, p2));
	}

	function log(uint p0, bool p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool)", p0, p1, p2));
	}

	function log(uint p0, bool p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address)", p0, p1, p2));
	}

	function log(uint p0, address p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint)", p0, p1, p2));
	}

	function log(uint p0, address p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,string)", p0, p1, p2));
	}

	function log(uint p0, address p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool)", p0, p1, p2));
	}

	function log(uint p0, address p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,address)", p0, p1, p2));
	}

	function log(string memory p0, uint p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint)", p0, p1, p2));
	}

	function log(string memory p0, uint p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,string)", p0, p1, p2));
	}

	function log(string memory p0, uint p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool)", p0, p1, p2));
	}

	function log(string memory p0, uint p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,address)", p0, p1, p2));
	}

	function log(string memory p0, string memory p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,uint)", p0, p1, p2));
	}

	function log(string memory p0, string memory p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,string)", p0, p1, p2));
	}

	function log(string memory p0, string memory p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,bool)", p0, p1, p2));
	}

	function log(string memory p0, string memory p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,address)", p0, p1, p2));
	}

	function log(string memory p0, bool p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint)", p0, p1, p2));
	}

	function log(string memory p0, bool p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,string)", p0, p1, p2));
	}

	function log(string memory p0, bool p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool)", p0, p1, p2));
	}

	function log(string memory p0, bool p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,address)", p0, p1, p2));
	}

	function log(string memory p0, address p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,uint)", p0, p1, p2));
	}

	function log(string memory p0, address p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,string)", p0, p1, p2));
	}

	function log(string memory p0, address p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,bool)", p0, p1, p2));
	}

	function log(string memory p0, address p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,address)", p0, p1, p2));
	}

	function log(bool p0, uint p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint)", p0, p1, p2));
	}

	function log(bool p0, uint p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string)", p0, p1, p2));
	}

	function log(bool p0, uint p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool)", p0, p1, p2));
	}

	function log(bool p0, uint p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address)", p0, p1, p2));
	}

	function log(bool p0, string memory p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint)", p0, p1, p2));
	}

	function log(bool p0, string memory p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,string)", p0, p1, p2));
	}

	function log(bool p0, string memory p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool)", p0, p1, p2));
	}

	function log(bool p0, string memory p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,address)", p0, p1, p2));
	}

	function log(bool p0, bool p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint)", p0, p1, p2));
	}

	function log(bool p0, bool p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string)", p0, p1, p2));
	}

	function log(bool p0, bool p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool)", p0, p1, p2));
	}

	function log(bool p0, bool p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address)", p0, p1, p2));
	}

	function log(bool p0, address p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint)", p0, p1, p2));
	}

	function log(bool p0, address p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,string)", p0, p1, p2));
	}

	function log(bool p0, address p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool)", p0, p1, p2));
	}

	function log(bool p0, address p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,address)", p0, p1, p2));
	}

	function log(address p0, uint p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint)", p0, p1, p2));
	}

	function log(address p0, uint p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,string)", p0, p1, p2));
	}

	function log(address p0, uint p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool)", p0, p1, p2));
	}

	function log(address p0, uint p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,address)", p0, p1, p2));
	}

	function log(address p0, string memory p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,uint)", p0, p1, p2));
	}

	function log(address p0, string memory p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,string)", p0, p1, p2));
	}

	function log(address p0, string memory p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,bool)", p0, p1, p2));
	}

	function log(address p0, string memory p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,address)", p0, p1, p2));
	}

	function log(address p0, bool p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint)", p0, p1, p2));
	}

	function log(address p0, bool p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,string)", p0, p1, p2));
	}

	function log(address p0, bool p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool)", p0, p1, p2));
	}

	function log(address p0, bool p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,address)", p0, p1, p2));
	}

	function log(address p0, address p1, uint p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,uint)", p0, p1, p2));
	}

	function log(address p0, address p1, string memory p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,string)", p0, p1, p2));
	}

	function log(address p0, address p1, bool p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,bool)", p0, p1, p2));
	}

	function log(address p0, address p1, address p2) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,address)", p0, p1, p2));
	}

	function log(uint p0, uint p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,string)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,uint,address)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,string)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,string,address)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,string)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,bool,address)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,string)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, uint p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,uint,address,address)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,string)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,uint,address)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,string)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,string,address)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,string)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,bool,address)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,string)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, string memory p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,string,address,address)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,string)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,uint,address)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,string)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,string,address)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,string)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,bool,address)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,string)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, bool p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,bool,address,address)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,string)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,uint,address)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,string)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,string,address)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,string)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,bool,address)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,uint)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,string)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,bool)", p0, p1, p2, p3));
	}

	function log(uint p0, address p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(uint,address,address,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,uint,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,string,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,bool,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, uint p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,uint,address,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,uint,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,string,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,string,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,string,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,string,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,bool,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,address,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,address,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,address,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, string memory p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,string,address,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,uint,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,string,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,bool,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, bool p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,bool,address,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,uint,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,string,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,string,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,string,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,string,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,bool,address)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,address,uint)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,address,string)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,address,bool)", p0, p1, p2, p3));
	}

	function log(string memory p0, address p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(string,address,address,address)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,string)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,uint,address)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,string)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,string,address)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,string)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,bool,address)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,string)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, uint p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,uint,address,address)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,string)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,uint,address)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,string)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,string,address)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,string)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,bool,address)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,string)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, string memory p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,string,address,address)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,string)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,uint,address)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,string)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,string,address)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,string)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,bool,address)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,string)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, bool p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,bool,address,address)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,string)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,uint,address)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,string)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,string,address)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,string)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,bool,address)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,uint)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,string)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,bool)", p0, p1, p2, p3));
	}

	function log(bool p0, address p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(bool,address,address,address)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,uint)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,string)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,bool)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,uint,address)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,uint)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,string)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,bool)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,string,address)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,uint)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,string)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,bool)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,bool,address)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,uint)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,string)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,bool)", p0, p1, p2, p3));
	}

	function log(address p0, uint p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,uint,address,address)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,uint)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,string)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,bool)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,uint,address)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,string,uint)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,string,string)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,string,bool)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,string,address)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,uint)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,string)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,bool)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,bool,address)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,address,uint)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,address,string)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,address,bool)", p0, p1, p2, p3));
	}

	function log(address p0, string memory p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,string,address,address)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,uint)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,string)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,bool)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,uint,address)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,uint)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,string)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,bool)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,string,address)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,uint)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,string)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,bool)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,bool,address)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,uint)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,string)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,bool)", p0, p1, p2, p3));
	}

	function log(address p0, bool p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,bool,address,address)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, uint p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,uint)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, uint p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,string)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, uint p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,bool)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, uint p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,uint,address)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, string memory p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,string,uint)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, string memory p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,string,string)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, string memory p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,string,bool)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, string memory p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,string,address)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, bool p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,uint)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, bool p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,string)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, bool p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,bool)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, bool p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,bool,address)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, address p2, uint p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,address,uint)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, address p2, string memory p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,address,string)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, address p2, bool p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,address,bool)", p0, p1, p2, p3));
	}

	function log(address p0, address p1, address p2, address p3) internal view {
		_sendLogPayload(abi.encodeWithSignature("log(address,address,address,address)", p0, p1, p2, p3));
	}

}

File 9 of 53 : Submissions.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";

import "hardhat/console.sol";

import "./Common.sol";
import "./Treasury.sol";

contract Submissions is Initializable, ContextUpgradeable, AccessControlUpgradeable, ReentrancyGuardUpgradeable, Common {
    using AddressUpgradeable for address;
    using AddressUpgradeable for address payable;

    enum SubmissionStatus {Pending, Approved, Funded}

    struct Submission {
        address author; // Who must be rewarded for the submission
        uint256 addedValue; // How much value does this submission brings (in "wei")
        uint256 reward; // How many UNQ erc-20 tokens to reward for author
        uint256 metadataVersion; // Version of metadata of the submission
        uint256 tokenId; // Which Uniquette is this submission targeted to upgrade (it is 0 for new Uniquette submissions)
        uint256 parentHash; // Hash of parent when submission is an upgrade for an existing one
        uint256 deposit; // How much author have deposited as submission deposit (to prevent spam)
        SubmissionStatus status;
    }

    event SubmissionCreated(
        address indexed submitter,
        uint256 indexed tokenId,
        string hash,
        uint256 addedValue,
        uint256 deposit
    );
    event SubmissionUpdated(address indexed submitter, string hash, uint256 addedValue);
    event SubmissionApproved(
        address approver,
        address indexed author,
        string hash,
        uint256 reward
    );
    event SubmissionRejected(address approver, address indexed author, string hash);

    Treasury private _treasury;

    mapping(string => Submission) internal _submissions;

    function __Submissions_init(
        address payable treasury
    ) internal initializer {
        __Submissions_init_unchained(treasury);
    }

    function __Submissions_init_unchained(
        address payable treasury
    ) internal initializer {
        _treasury = Treasury(treasury);

        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(GOVERNOR_ROLE, _msgSender());
    }

    //
    // Modifiers
    //
    modifier submissionExists(string calldata hash) {
        require(_submissions[hash].author != address(0), "SUBMISSIONS/DOES_NOT_EXIST");
        _;
    }

    modifier submissionIsPending(string calldata hash) {
        require(_submissions[hash].status == SubmissionStatus.Pending, "SUBMISSIONS/NOT_PENDING");
        _;
    }

    modifier submissionIsApproved(string calldata hash) {
        require(_submissions[hash].status == SubmissionStatus.Approved, "SUBMISSIONS/NOT_APPROVED");
        _;
    }

    modifier submissionIsUpToDate(string calldata hash) {
        require(_submissions[hash].metadataVersion >= _minMetadataVersion, "SUBMISSIONS/OUTDATED_METADATA_VERSION");
        _;
    }

    //
    // Generic and standard functions
    //
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlUpgradeable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    //
    // Admin functions
    //
    function setTreasuryAddress(address payable newAddress) public virtual isGovernor() {
        _treasury = Treasury(newAddress);
    }

    //
    // Submissions Logic
    //
    function submissionGetByHash(string calldata hash)
        public
        view
        virtual
        submissionExists(hash)
        returns (Submission memory)
    {
        return _submissions[hash];
    }

    function submissionCreate(
        uint256 tokenId,
        string calldata hash,
        uint256 metadataVersion,
        uint256 addedValue
    ) public payable {
        require(_submissions[hash].author == address(0), "SUBMISSIONS/ALREADY_CREATED");
        require(msg.value == _submissionDeposit, "SUBMISSIONS/EXACT_DEPOSIT_REQUIRED");
        require(metadataVersion >= _minMetadataVersion, "SUBMISSIONS/UNSUPPORTED_METADATA_VERSION");

        _submissions[hash].author = _msgSender();
        _submissions[hash].tokenId = tokenId;
        _submissions[hash].metadataVersion = metadataVersion;
        _submissions[hash].addedValue = addedValue;
        //_submissions[hash].reward = calculateReward(addedValue); TODO To be done via price oracles
        _submissions[hash].deposit = msg.value;
        _submissions[hash].status = SubmissionStatus.Pending;

        emit SubmissionCreated(_msgSender(), tokenId, hash, addedValue, msg.value);
    }

    function submissionUpdate(string calldata hash, uint256 tokenId, uint256 addedValue)
        public
        submissionExists(hash)
        submissionIsPending(hash)
        submissionIsUpToDate(hash)
        nonReentrant
    {
        require(
            _submissions[hash].author == _msgSender() || hasRole(GOVERNOR_ROLE, _msgSender()),
            "SUBMISSIONS/NOT_AUTHOR_OR_GOVERNOR"
        );
        _submissions[hash].tokenId = tokenId;
        _submissions[hash].addedValue = addedValue;

        emit SubmissionUpdated(_msgSender(), hash, addedValue);
    }

    function submissionCreateBulk(
        string[] calldata hashes,
        uint256[] calldata metadataVersions,
        uint256[] calldata tokenIds,
        uint256[] calldata addedValues
    ) public payable nonReentrant {
        require(
            hashes.length == metadataVersions.length,
            "Submissions: number of hashes do not match metadataVersions"
        );
        require(hashes.length == tokenIds.length, "Submissions: number of hashes do not match tokenIds");
        require(hashes.length == addedValues.length, "Submissions: number of hashes do not match values");

        for (uint256 i = 0; i < hashes.length; ++i) {
            this.submissionCreate(tokenIds[i], hashes[i], metadataVersions[i], addedValues[i]);
        }
    }

    function _afterSubmissionApprove(string memory hash) internal virtual {}

    function _approveSubmission(
        string calldata hash,
        uint256 rewardOverride
    ) internal virtual submissionExists(hash) submissionIsPending(hash) submissionIsUpToDate(hash) {
        _submissions[hash].reward = rewardOverride;
        _submissions[hash].status = SubmissionStatus.Approved;

        _afterSubmissionApprove(hash);

        emit SubmissionApproved(_msgSender(), _submissions[hash].author, hash, rewardOverride);
    }

    function submissionApprove(
        string calldata hash,
        uint256 rewardOverride
    ) public isGovernor() nonReentrant {
        _approveSubmission(hash, rewardOverride);
    }

    function submissionApproveBulk(
        string[] calldata hashes,
        uint256[] calldata rewards
    ) public isGovernor() nonReentrant {
        require(hashes.length == rewards.length, "Submissions: number of hashes do not match rewards");

        for (uint256 i = 0; i < hashes.length; ++i) {
            _approveSubmission(hashes[i], rewards[i]);
        }
    }

    function submissionReject(string calldata hash)
        public
        isGovernor()
        submissionExists(hash)
        submissionIsPending(hash)
        nonReentrant
    {
        address originalSubmitter = _submissions[hash].author;
        uint256 submissionDeposit = _submissions[hash].deposit;
        delete _submissions[hash];

        // Seize the submit deposit to treasury
        if (submissionDeposit > 0) {
            payable(address(_treasury)).sendValue(submissionDeposit);
        }

        emit SubmissionRejected(_msgSender(), originalSubmitter, hash);
    }

    function _markSubmissionAsFunded(string calldata hash) submissionExists(hash) submissionIsApproved(hash) internal virtual {
        _submissions[hash].status = SubmissionStatus.Funded;
    }
}

File 10 of 53 : Uniquettes.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";

import "./Token.sol";
import "./Vault.sol";
import "./Treasury.sol";
import "./Marketer.sol";

import "./Submissions.sol";

contract Uniquettes is
    Initializable,
    ContextUpgradeable,
    AccessControlUpgradeable,
    ERC721Upgradeable,
    ERC721EnumerableUpgradeable,
    ERC721PausableUpgradeable,
    ReentrancyGuardUpgradeable,
    Common
{
    using AddressUpgradeable for address;
    using AddressUpgradeable for address payable;
    using CountersUpgradeable for CountersUpgradeable.Counter;

    struct Uniquette {
        uint256 tokenId;
        address owner;
        uint256 collateralValue;
        uint256 lastPurchaseAmount;
    }

    event UniquetteRejected(address approver, address indexed submitter, string hash);
    event UniquetteCollected(
        address operator,
        address indexed seller,
        address indexed collector,
        uint256 indexed tokenId,
        uint256 effectivePrice,
        uint256 appreciatedPrice,
        uint256 principalAmount
    );
    event UniquetteCollateralIncreased(
        address indexed operator,
        address indexed owner,
        uint256 indexed tokenId,
        uint256 additionalCollateral
    );
    event ProtocolFeePaid(
        address indexed operator,
        address seller,
        address indexed collector,
        uint256 indexed tokenId,
        uint256 feePaid
    );

    Token private _token;
    Vault private _vault;
    Treasury private _treasury;
    Marketer private _marketer;

    mapping(uint256 => Uniquette) internal _uniquettes;

    CountersUpgradeable.Counter private _tokenIdTracker;

    address private _marketerProxy;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __Uniquettes_init(
        string memory name,
        string memory symbol,
        address token,
        address payable vault,
        address payable treasury,
        address payable marketer
    ) internal initializer {
        __ERC721_init(name, symbol);
        __Uniquettes_init_unchained(name, symbol, token, vault, treasury, marketer);
    }

    function __Uniquettes_init_unchained(
        string memory name,
        string memory symbol,
        address token,
        address payable vault,
        address payable treasury,
        address payable marketer
    ) internal initializer {
        _token = Token(token);
        _vault = Vault(vault);
        _treasury = Treasury(treasury);
        _marketer = Marketer(marketer);
    }

    //
    // Modifiers
    //
    modifier tokenExists(uint256 tokenId) {
        require(_exists(tokenId) && _uniquettes[tokenId].tokenId > 0, "UNIQUETTES/DOES_NOT_EXIST");
        _;
    }

    //
    // Generic and standard functions
    //
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlUpgradeable, ERC721Upgradeable, ERC721EnumerableUpgradeable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    //
    // Admin functions
    //
    function pause() public virtual isGovernor() {
        _pause();
    }

    function unpause() public virtual isGovernor() {
        _unpause();
    }

    function setTokenAddress(address newAddress) public isGovernor() {
        _token = Token(newAddress);
    }

    function setVaultAddress(address payable newAddress) public isGovernor() {
        _vault = Vault(newAddress);
    }

    function setTreasuryAddress(address payable newAddress) public virtual isGovernor() {
        _treasury = Treasury(newAddress);
    }

    function setMarketerAddress(address payable newAddress) public isGovernor() {
        _marketer = Marketer(newAddress);
    }

    function setMarketerProxyAddress(address payable newAddress) public isGovernor() {
        _marketerProxy = newAddress;
    }

    //
    // Customized ERC-721 functions
    //
    function burn(uint256 tokenId) public virtual isGovernor() {
        Uniquette memory uniquette = _uniquettes[tokenId];
        require(
            // It must be owned by Vault which means it's liquidated and currently locked in Vault
            (uniquette.owner == address(_vault)),
            "UNIQUETTES/NOT_OWNED_BY_VAULT"
        );

        _burn(tokenId);
    }

    function batchBurn(uint256[] calldata tokenIds) public virtual isGovernor() {
        for (uint256 i = 0; i < tokenIds.length; ++i) {
            uint256 id = tokenIds[i];
            this.burn(id);
        }
    }

    function isApprovedForAll(address account, address operator) public view virtual override returns (bool) {
        return (// Transfers must be either operated by governor (when approving a submission)
        hasRole(GOVERNOR_ROLE, operator) ||
            // or, operated by marketer contract (when selling on an exchange)
            operator == address(_marketer) ||
            operator == address(_marketerProxy) ||
            // or, operated by vault contract (when liquidating a uniquette)
            operator == address(_vault) ||
            // or, operator is approved during buy operation
            super.isApprovedForAll(account, operator));
    }

    // We need to override to remove "orOwner" since we should not allow transfers initiated directly by owners
    function _isApprovedOrOwner(address spender, uint256 tokenId)
        internal
        view
        virtual
        override
        tokenExists(tokenId)
        returns (bool)
    {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (getApproved(tokenId) == spender || this.isApprovedForAll(owner, spender));
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 tokenId
    ) internal virtual override(ERC721Upgradeable, ERC721PausableUpgradeable, ERC721EnumerableUpgradeable) {
        if (to != address(_marketer)) {
            _uniquettes[tokenId].owner = to;
            super._beforeTokenTransfer(from, to, tokenId);
        }
    }

    function approve(address to, uint256 tokenId) public virtual override {
        revert("Directory: approve not supported on uniquette transfers");
    }

    function setApprovalForAll(address operator, bool approved) public virtual override {
        revert("Directory: setApprovalForAll not supported on uniquette transfers");
    }

    //
    // Unique functions
    //
    function uniquetteGetById(uint256 tokenId) public view virtual tokenExists(tokenId) returns (Uniquette memory) {
        return _uniquettes[tokenId];
    }

    function uniquetteIncreaseCollateral(uint256 tokenId) public payable virtual tokenExists(tokenId) nonReentrant {
        payable(address(_vault)).sendValue(msg.value);

        _uniquettes[tokenId].collateralValue += msg.value;

        emit UniquetteCollateralIncreased(_msgSender(), _uniquettes[tokenId].owner, tokenId, msg.value);
    }

    //
    // Internal functions
    //
    function uniquetteMint() internal virtual returns (uint256) {
        // Issue a new token ID
        _tokenIdTracker.increment();
        uint256 newTokenId = _tokenIdTracker.current();

        _uniquettes[newTokenId].owner = address(_vault);
        _uniquettes[newTokenId].tokenId = newTokenId;
        _uniquettes[newTokenId].collateralValue = 0;
        _uniquettes[newTokenId].lastPurchaseAmount = 0;

        // Mint the new uniquette into Vault
        _mint(address(_vault), newTokenId);

        return newTokenId;
    }

    function _uniquetteTakeOver(
        address operator,
        address to,
        uint256 tokenId,
        uint256 addedValue
    )
        internal
        virtual
        tokenExists(tokenId)
        returns (
            uint256 effectivePrice,
            uint256 appreciatedPrice,
            uint256 principalAmount,
            uint256 protocolFeeAmount
        )
    {
        require(to != address(0), "UNIQUETTES/COLLECT_TO_ZERO_ADDR");

        Uniquette memory uniquette = uniquetteGetById(tokenId);

        // Require some payment unless current owner is trying to fund a zero-value submission
        require(msg.value > 0 || (addedValue == 0 && operator == to && uniquette.owner == to), "UNIQUETTES/PAYMENT_REQUIRED");

        effectivePrice = calculateEffectivePrice(operator, to, uniquette);
        appreciatedPrice = effectivePrice + addedValue;
        protocolFeeAmount = (appreciatedPrice * _protocolFee) / 10000;
        principalAmount = msg.value - protocolFeeAmount;

        require(principalAmount >= appreciatedPrice, "UNIQUETTES/NOT_ENOUGH_PRINCIPAL");

        uint256 additionalCollateral = principalAmount - effectivePrice;

        require(appreciatedPrice >= effectivePrice, "UNIQUETTES/UNEXPECTED_DEPRECIATED_PRICE");
        require(additionalCollateral <= msg.value, "UNIQUETTES/UNEXPECTED_EXCESS_COLLATERAL");

        // Calculate extra ETH sent to be kept as collateral
        _uniquettes[tokenId].collateralValue += additionalCollateral;

        // Remember last amount this uniquette was sold for
        _uniquettes[tokenId].lastPurchaseAmount = appreciatedPrice;

        // Transfer ownership of uniquette in ERC-721 fashion (and remember the seller)
        address seller = uniquette.owner;

        _approve(operator, tokenId);
        _transfer(ownerOf(tokenId), to, tokenId);
        emit UniquetteCollected(operator, seller, to, tokenId, effectivePrice, appreciatedPrice, principalAmount);

        // Pay the protocol fee, move the collateral to Vault, pay the seller
        payable(address(_treasury)).sendValue(protocolFeeAmount);
        emit ProtocolFeePaid(operator, seller, to, tokenId, protocolFeeAmount);

        // Pay the previous owner (seller)
        payable(address(seller)).sendValue(effectivePrice);

        if (additionalCollateral > 0) {
            payable(address(_vault)).sendValue(additionalCollateral);
            emit UniquetteCollateralIncreased(operator, to, tokenId, additionalCollateral);
        }

        return (
            effectivePrice,
            appreciatedPrice,
            principalAmount,
            protocolFeeAmount
        );
    }

    function _putForSale(
        address owner,
        uint256 tokenId,
        uint256 effectivePrice
    )
    internal
    virtual
    {
        uint256 protocolFeeAmount = (effectivePrice * _protocolFee) / 10000;

        // Move the Uniquette to Marketer contract
        if (ownerOf(tokenId) != address(_marketer)) {
            _transfer(ownerOf(tokenId), address(_marketer), tokenId);
        }

        // Put it on sale on behalf of current owner via Marketer
        _marketer.putForSale(address(_marketer), tokenId, effectivePrice + protocolFeeAmount);
    }

    function _putOffSale(
        address owner,
        uint256 tokenId
    )
    internal
    virtual
    {
        // Move the Uniquette back to the owner
        if (ownerOf(tokenId) != owner) {
            _transfer(ownerOf(tokenId), owner, tokenId);
        }

        // TODO cancelOrder on OpenSea
    }

    function calculateEffectivePrice(address operator, address to, Uniquette memory uniquette) internal view virtual returns (uint256) {
        // If current owner is trying to fund a submission for their own uniquette
        // then effective price they need to pay for the uniquette itself must be 0.
        if (operator == to && uniquette.owner == to) {
            return 0;
        }

        if (uniquette.lastPurchaseAmount < uniquette.collateralValue) {
            return uniquette.collateralValue + ((uniquette.collateralValue * _maxPriceAppreciation) / 10000);
        } else {
            return uniquette.lastPurchaseAmount + ((uniquette.lastPurchaseAmount * _maxPriceAppreciation) / 10000);
        }
    }
}

File 11 of 53 : ERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

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 initializer {
        __ERC165_init_unchained();
    }

    function __ERC165_init_unchained() internal initializer {
    }
    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IERC165Upgradeable).interfaceId;
    }
    uint256[50] private __gap;
}

File 12 of 53 : IERC165Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

File 13 of 53 : Common.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";

contract Common is Initializable, ContextUpgradeable, AccessControlUpgradeable {
    bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");

    // Protocol parameters
    uint256 internal _protocolFee;
    uint256 internal _currentMetadataVersion;
    uint256 internal _minMetadataVersion;
    uint256 internal _maxPriceAppreciation;
    uint256 internal _submissionDeposit;

    function __Common_init(
        uint256 protocolFee,
        uint256 minMetadataVersion,
        uint256 currentMetadataVersion,
        uint256 maxPriceAppreciation,
        uint256 submissionDeposit
    ) internal initializer {
        __Common_init_unchained(
            protocolFee,
            minMetadataVersion,
            currentMetadataVersion,
            maxPriceAppreciation,
            submissionDeposit
        );
    }

    function __Common_init_unchained(
        uint256 protocolFee,
        uint256 minMetadataVersion,
        uint256 currentMetadataVersion,
        uint256 maxPriceAppreciation,
        uint256 submissionDeposit
    ) internal initializer {
        _protocolFee = protocolFee;
        _minMetadataVersion = minMetadataVersion;
        _currentMetadataVersion = currentMetadataVersion;
        _maxPriceAppreciation = maxPriceAppreciation;
        _submissionDeposit = submissionDeposit;

        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(GOVERNOR_ROLE, _msgSender());
    }

    //
    // Modifiers
    //
    modifier isGovernor() {
        require(hasRole(GOVERNOR_ROLE, _msgSender()), "COMMON/CALLER_NOT_GOVERNOR");
        _;
    }

    //
    // Admin
    //
    function setProtocolFee(uint256 newValue) public isGovernor() {
        _protocolFee = newValue;
    }

    function setMinMetadataVersion(uint256 newValue) public isGovernor() {
        _minMetadataVersion = newValue;
    }

    function setCurrentMetadataVersion(uint256 newValue) public isGovernor() {
        _currentMetadataVersion = newValue;
    }

    function setMaxPriceAppreciation(uint256 newValue) public isGovernor() {
        _maxPriceAppreciation = newValue;
    }

    function setSubmissionDeposit(uint256 newValue) public isGovernor() {
        _submissionDeposit = newValue;
    }

    //
    // Public
    //
    function getParameters()
    public
    view
    virtual
    returns (
        uint256 protocolFee,
        uint256 currentMetadataVersion,
        uint256 minMetadataVersion,
        uint256 maxPriceAppreciation,
        uint256 submissionDeposit
    )
    {
        return (_protocolFee, _currentMetadataVersion, _minMetadataVersion, _maxPriceAppreciation, _submissionDeposit);
    }
}

File 14 of 53 : Treasury.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@uniswap/v2-periphery/contracts/interfaces/IUniswapV2Router02.sol";

import "./Token.sol";
import "./PaymentRecipientUpgradable.sol";

contract Treasury is AccessControlUpgradeable, PaymentRecipientUpgradable {
    bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");

    event BoughtBack(address initiator, uint256 ethAmount, uint256 tokensBought);
    event Burnt(address initiator, uint256 ethAmount);

    Token private _tokenAddress;
    IUniswapV2Router02 private _uniswapRouter;

    function initialize(address payable uniswapRouter) public initializer {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(GOVERNOR_ROLE, _msgSender());

        _uniswapRouter = IUniswapV2Router02(uniswapRouter);
    }

    //
    // Modifiers
    //
    modifier isGovernor() {
        require(hasRole(GOVERNOR_ROLE, _msgSender()), "Treasury: caller is not governor");
        _;
    }

    //
    // Admin functions
    //
    function setTokenAddress(address tokenAddress) public isGovernor() {
        _tokenAddress = Token(tokenAddress);
    }

    function buybackAndBurn(uint256 ethAmount, uint256 amountOutMin) public isGovernor() {
        require(ethAmount >= address(this).balance, "Treasury: amount is more than balance");
        require(address(_tokenAddress) != address(0), "Treasury: token address not set");

        // Build arguments for uniswap router call
        address[] memory path = new address[](2);
        path[0] = _uniswapRouter.WETH();
        path[1] = address(_tokenAddress);

        // Make the call and give it 30 seconds
        uint256[] memory amounts =
            _uniswapRouter.swapExactETHForTokens{value: ethAmount}(
                amountOutMin,
                path,
                address(this),
                block.timestamp + 30
            );
        uint256 amountBought = amounts[amounts.length - 1];
        emit BoughtBack(_msgSender(), ethAmount, amountBought);

        _tokenAddress.burn(amountBought);
        emit Burnt(_msgSender(), amountBought);
    }
}

File 15 of 53 : IUniswapV2Router02.sol
pragma solidity >=0.6.2;

import './IUniswapV2Router01.sol';

interface IUniswapV2Router02 is IUniswapV2Router01 {
    function removeLiquidityETHSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountETH);
    function removeLiquidityETHWithPermitSupportingFeeOnTransferTokens(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountETH);

    function swapExactTokensForTokensSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
    function swapExactETHForTokensSupportingFeeOnTransferTokens(
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external payable;
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external;
}

File 16 of 53 : Token.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/ERC20Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20BurnableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20PausableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/ERC20SnapshotUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC20/extensions/draft-ERC20PermitUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol";

contract Token is
    Initializable,
    ContextUpgradeable,
    AccessControlEnumerableUpgradeable,
    ERC20BurnableUpgradeable,
    ERC20PausableUpgradeable,
    ERC20SnapshotUpgradeable,
    ERC20PermitUpgradeable
{
    bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");
    bytes32 public constant MINTER_ROLE = keccak256("MINTER_ROLE");

    function initialize(string memory name, string memory symbol) public initializer {
        __ERC20_init(name, symbol);
        __ERC20Permit_init(name);

        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(GOVERNOR_ROLE, _msgSender());
    }

    //
    // Modifiers
    //
    modifier isGovernor() {
        require(hasRole(GOVERNOR_ROLE, _msgSender()), "Token: caller is not governor");
        _;
    }

    //
    // Admin functions
    //
    function pause() public virtual isGovernor() {
        _pause();
    }

    function unpause() public virtual isGovernor() {
        _unpause();
    }

    //
    // Customized ERC-20 functions
    //
    function mint(address to, uint256 amount) public virtual {
        require(hasRole(MINTER_ROLE, _msgSender()), "Token: must have minter role to mint");
        _mint(to, amount);
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal virtual override(ERC20Upgradeable, ERC20PausableUpgradeable, ERC20SnapshotUpgradeable) {
        super._beforeTokenTransfer(from, to, amount);
    }
}

File 17 of 53 : PaymentRecipientUpgradable.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/utils/ContextUpgradeable.sol";

contract PaymentRecipientUpgradable is ContextUpgradeable {
    event ReceivedEther(address indexed sender, uint256 amount);

    /**
     * @dev Receive Ether and generate a log event
     */
    receive() external payable {
        emit ReceivedEther(_msgSender(), msg.value);
    }
}

File 18 of 53 : IUniswapV2Router01.sol
pragma solidity >=0.6.2;

interface IUniswapV2Router01 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);

    function addLiquidity(
        address tokenA,
        address tokenB,
        uint amountADesired,
        uint amountBDesired,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB, uint liquidity);
    function addLiquidityETH(
        address token,
        uint amountTokenDesired,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external payable returns (uint amountToken, uint amountETH, uint liquidity);
    function removeLiquidity(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETH(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline
    ) external returns (uint amountToken, uint amountETH);
    function removeLiquidityWithPermit(
        address tokenA,
        address tokenB,
        uint liquidity,
        uint amountAMin,
        uint amountBMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountA, uint amountB);
    function removeLiquidityETHWithPermit(
        address token,
        uint liquidity,
        uint amountTokenMin,
        uint amountETHMin,
        address to,
        uint deadline,
        bool approveMax, uint8 v, bytes32 r, bytes32 s
    ) external returns (uint amountToken, uint amountETH);
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapTokensForExactTokens(
        uint amountOut,
        uint amountInMax,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
    function swapExactETHForTokens(uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);
    function swapTokensForExactETH(uint amountOut, uint amountInMax, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapExactTokensForETH(uint amountIn, uint amountOutMin, address[] calldata path, address to, uint deadline)
        external
        returns (uint[] memory amounts);
    function swapETHForExactTokens(uint amountOut, address[] calldata path, address to, uint deadline)
        external
        payable
        returns (uint[] memory amounts);

    function quote(uint amountA, uint reserveA, uint reserveB) external pure returns (uint amountB);
    function getAmountOut(uint amountIn, uint reserveIn, uint reserveOut) external pure returns (uint amountOut);
    function getAmountIn(uint amountOut, uint reserveIn, uint reserveOut) external pure returns (uint amountIn);
    function getAmountsOut(uint amountIn, address[] calldata path) external view returns (uint[] memory amounts);
    function getAmountsIn(uint amountOut, address[] calldata path) external view returns (uint[] memory amounts);
}

File 19 of 53 : ERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

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.zeppelin.solutions/t/how-to-implement-erc20-supply-mechanisms/226[How
 * to implement supply mechanisms].
 *
 * We have followed general OpenZeppelin guidelines: functions revert instead
 * of 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 defaut 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 initializer {
        __Context_init_unchained();
        __ERC20_init_unchained(name_, symbol_);
    }

    function __ERC20_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _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:
     *
     * - `recipient` cannot be the zero address.
     * - the caller must have a balance of at least `amount`.
     */
    function transfer(address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(_msgSender(), recipient, 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}.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     */
    function approve(address spender, uint256 amount) public virtual override returns (bool) {
        _approve(_msgSender(), 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}.
     *
     * Requirements:
     *
     * - `sender` and `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     * - the caller must have allowance for ``sender``'s tokens of at least
     * `amount`.
     */
    function transferFrom(address sender, address recipient, uint256 amount) public virtual override returns (bool) {
        _transfer(sender, recipient, amount);

        uint256 currentAllowance = _allowances[sender][_msgSender()];
        require(currentAllowance >= amount, "ERC20: transfer amount exceeds allowance");
        _approve(sender, _msgSender(), currentAllowance - 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) {
        _approve(_msgSender(), spender, _allowances[_msgSender()][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) {
        uint256 currentAllowance = _allowances[_msgSender()][spender];
        require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
        _approve(_msgSender(), spender, currentAllowance - subtractedValue);

        return true;
    }

    /**
     * @dev Moves tokens `amount` from `sender` to `recipient`.
     *
     * This is 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:
     *
     * - `sender` cannot be the zero address.
     * - `recipient` cannot be the zero address.
     * - `sender` must have a balance of at least `amount`.
     */
    function _transfer(address sender, address recipient, uint256 amount) internal virtual {
        require(sender != address(0), "ERC20: transfer from the zero address");
        require(recipient != address(0), "ERC20: transfer to the zero address");

        _beforeTokenTransfer(sender, recipient, amount);

        uint256 senderBalance = _balances[sender];
        require(senderBalance >= amount, "ERC20: transfer amount exceeds balance");
        _balances[sender] = senderBalance - amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, 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:
     *
     * - `to` 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;
        _balances[account] += amount;
        emit Transfer(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");
        _balances[account] = accountBalance - amount;
        _totalSupply -= amount;

        emit Transfer(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 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 to 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 { }
    uint256[45] private __gap;
}

File 20 of 53 : ERC20BurnableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Extension of {ERC20} that allows token holders to destroy both their own
 * tokens and those that they have an allowance for, in a way that can be
 * recognized off-chain (via event analysis).
 */
abstract contract ERC20BurnableUpgradeable is Initializable, ContextUpgradeable, ERC20Upgradeable {
    function __ERC20Burnable_init() internal initializer {
        __Context_init_unchained();
        __ERC20Burnable_init_unchained();
    }

    function __ERC20Burnable_init_unchained() internal initializer {
    }
    /**
     * @dev Destroys `amount` tokens from the caller.
     *
     * See {ERC20-_burn}.
     */
    function burn(uint256 amount) public virtual {
        _burn(_msgSender(), amount);
    }

    /**
     * @dev Destroys `amount` tokens from `account`, deducting from the caller's
     * allowance.
     *
     * See {ERC20-_burn} and {ERC20-allowance}.
     *
     * Requirements:
     *
     * - the caller must have allowance for ``accounts``'s tokens of at least
     * `amount`.
     */
    function burnFrom(address account, uint256 amount) public virtual {
        uint256 currentAllowance = allowance(account, _msgSender());
        require(currentAllowance >= amount, "ERC20: burn amount exceeds allowance");
        _approve(account, _msgSender(), currentAllowance - amount);
        _burn(account, amount);
    }
    uint256[50] private __gap;
}

File 21 of 53 : ERC20PausableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20Upgradeable.sol";
import "../../../security/PausableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev ERC20 token with pausable token transfers, minting and burning.
 *
 * Useful for scenarios such as preventing trades until the end of an evaluation
 * period, or having an emergency switch for freezing all token transfers in the
 * event of a large bug.
 */
abstract contract ERC20PausableUpgradeable is Initializable, ERC20Upgradeable, PausableUpgradeable {
    function __ERC20Pausable_init() internal initializer {
        __Context_init_unchained();
        __Pausable_init_unchained();
        __ERC20Pausable_init_unchained();
    }

    function __ERC20Pausable_init_unchained() internal initializer {
    }
    /**
     * @dev See {ERC20-_beforeTokenTransfer}.
     *
     * Requirements:
     *
     * - the contract must not be paused.
     */
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
        super._beforeTokenTransfer(from, to, amount);

        require(!paused(), "ERC20Pausable: token transfer while paused");
    }
    uint256[50] private __gap;
}

File 22 of 53 : ERC20SnapshotUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC20Upgradeable.sol";
import "../../../utils/ArraysUpgradeable.sol";
import "../../../utils/CountersUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev This contract extends an ERC20 token with a snapshot mechanism. When a snapshot is created, the balances and
 * total supply at the time are recorded for later access.
 *
 * This can be used to safely create mechanisms based on token balances such as trustless dividends or weighted voting.
 * In naive implementations it's possible to perform a "double spend" attack by reusing the same balance from different
 * accounts. By using snapshots to calculate dividends or voting power, those attacks no longer apply. It can also be
 * used to create an efficient ERC20 forking mechanism.
 *
 * Snapshots are created by the internal {_snapshot} function, which will emit the {Snapshot} event and return a
 * snapshot id. To get the total supply at the time of a snapshot, call the function {totalSupplyAt} with the snapshot
 * id. To get the balance of an account at the time of a snapshot, call the {balanceOfAt} function with the snapshot id
 * and the account address.
 *
 * ==== Gas Costs
 *
 * Snapshots are efficient. Snapshot creation is _O(1)_. Retrieval of balances or total supply from a snapshot is _O(log
 * n)_ in the number of snapshots that have been created, although _n_ for a specific account will generally be much
 * smaller since identical balances in subsequent snapshots are stored as a single entry.
 *
 * There is a constant overhead for normal ERC20 transfers due to the additional snapshot bookkeeping. This overhead is
 * only significant for the first transfer that immediately follows a snapshot for a particular account. Subsequent
 * transfers will have normal cost until the next snapshot, and so on.
 */
abstract contract ERC20SnapshotUpgradeable is Initializable, ERC20Upgradeable {
    function __ERC20Snapshot_init() internal initializer {
        __Context_init_unchained();
        __ERC20Snapshot_init_unchained();
    }

    function __ERC20Snapshot_init_unchained() internal initializer {
    }
    // Inspired by Jordi Baylina's MiniMeToken to record historical balances:
    // https://github.com/Giveth/minimd/blob/ea04d950eea153a04c51fa510b068b9dded390cb/contracts/MiniMeToken.sol

    using ArraysUpgradeable for uint256[];
    using CountersUpgradeable for CountersUpgradeable.Counter;

    // Snapshotted values have arrays of ids and the value corresponding to that id. These could be an array of a
    // Snapshot struct, but that would impede usage of functions that work on an array.
    struct Snapshots {
        uint256[] ids;
        uint256[] values;
    }

    mapping (address => Snapshots) private _accountBalanceSnapshots;
    Snapshots private _totalSupplySnapshots;

    // Snapshot ids increase monotonically, with the first value being 1. An id of 0 is invalid.
    CountersUpgradeable.Counter private _currentSnapshotId;

    /**
     * @dev Emitted by {_snapshot} when a snapshot identified by `id` is created.
     */
    event Snapshot(uint256 id);

    /**
     * @dev Creates a new snapshot and returns its snapshot id.
     *
     * Emits a {Snapshot} event that contains the same id.
     *
     * {_snapshot} is `internal` and you have to decide how to expose it externally. Its usage may be restricted to a
     * set of accounts, for example using {AccessControl}, or it may be open to the public.
     *
     * [WARNING]
     * ====
     * While an open way of calling {_snapshot} is required for certain trust minimization mechanisms such as forking,
     * you must consider that it can potentially be used by attackers in two ways.
     *
     * First, it can be used to increase the cost of retrieval of values from snapshots, although it will grow
     * logarithmically thus rendering this attack ineffective in the long term. Second, it can be used to target
     * specific accounts and increase the cost of ERC20 transfers for them, in the ways specified in the Gas Costs
     * section above.
     *
     * We haven't measured the actual numbers; if this is something you're interested in please reach out to us.
     * ====
     */
    function _snapshot() internal virtual returns (uint256) {
        _currentSnapshotId.increment();

        uint256 currentId = _currentSnapshotId.current();
        emit Snapshot(currentId);
        return currentId;
    }

    /**
     * @dev Retrieves the balance of `account` at the time `snapshotId` was created.
     */
    function balanceOfAt(address account, uint256 snapshotId) public view virtual returns (uint256) {
        (bool snapshotted, uint256 value) = _valueAt(snapshotId, _accountBalanceSnapshots[account]);

        return snapshotted ? value : balanceOf(account);
    }

    /**
     * @dev Retrieves the total supply at the time `snapshotId` was created.
     */
    function totalSupplyAt(uint256 snapshotId) public view virtual returns(uint256) {
        (bool snapshotted, uint256 value) = _valueAt(snapshotId, _totalSupplySnapshots);

        return snapshotted ? value : totalSupply();
    }


    // Update balance and/or total supply snapshots before the values are modified. This is implemented
    // in the _beforeTokenTransfer hook, which is executed for _mint, _burn, and _transfer operations.
    function _beforeTokenTransfer(address from, address to, uint256 amount) internal virtual override {
      super._beforeTokenTransfer(from, to, amount);

      if (from == address(0)) {
        // mint
        _updateAccountSnapshot(to);
        _updateTotalSupplySnapshot();
      } else if (to == address(0)) {
        // burn
        _updateAccountSnapshot(from);
        _updateTotalSupplySnapshot();
      } else {
        // transfer
        _updateAccountSnapshot(from);
        _updateAccountSnapshot(to);
      }
    }

    function _valueAt(uint256 snapshotId, Snapshots storage snapshots)
        private view returns (bool, uint256)
    {
        require(snapshotId > 0, "ERC20Snapshot: id is 0");
        // solhint-disable-next-line max-line-length
        require(snapshotId <= _currentSnapshotId.current(), "ERC20Snapshot: nonexistent id");

        // When a valid snapshot is queried, there are three possibilities:
        //  a) The queried value was not modified after the snapshot was taken. Therefore, a snapshot entry was never
        //  created for this id, and all stored snapshot ids are smaller than the requested one. The value that corresponds
        //  to this id is the current one.
        //  b) The queried value was modified after the snapshot was taken. Therefore, there will be an entry with the
        //  requested id, and its value is the one to return.
        //  c) More snapshots were created after the requested one, and the queried value was later modified. There will be
        //  no entry for the requested id: the value that corresponds to it is that of the smallest snapshot id that is
        //  larger than the requested one.
        //
        // In summary, we need to find an element in an array, returning the index of the smallest value that is larger if
        // it is not found, unless said value doesn't exist (e.g. when all values are smaller). Arrays.findUpperBound does
        // exactly this.

        uint256 index = snapshots.ids.findUpperBound(snapshotId);

        if (index == snapshots.ids.length) {
            return (false, 0);
        } else {
            return (true, snapshots.values[index]);
        }
    }

    function _updateAccountSnapshot(address account) private {
        _updateSnapshot(_accountBalanceSnapshots[account], balanceOf(account));
    }

    function _updateTotalSupplySnapshot() private {
        _updateSnapshot(_totalSupplySnapshots, totalSupply());
    }

    function _updateSnapshot(Snapshots storage snapshots, uint256 currentValue) private {
        uint256 currentId = _currentSnapshotId.current();
        if (_lastSnapshotId(snapshots.ids) < currentId) {
            snapshots.ids.push(currentId);
            snapshots.values.push(currentValue);
        }
    }

    function _lastSnapshotId(uint256[] storage ids) private view returns (uint256) {
        if (ids.length == 0) {
            return 0;
        } else {
            return ids[ids.length - 1];
        }
    }
    uint256[46] private __gap;
}

File 23 of 53 : draft-ERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./draft-IERC20PermitUpgradeable.sol";
import "../ERC20Upgradeable.sol";
import "../../../utils/cryptography/draft-EIP712Upgradeable.sol";
import "../../../utils/cryptography/ECDSAUpgradeable.sol";
import "../../../utils/CountersUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on `{IERC20-approve}`, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 *
 * _Available since v3.4._
 */
abstract contract ERC20PermitUpgradeable is Initializable, ERC20Upgradeable, IERC20PermitUpgradeable, EIP712Upgradeable {
    using CountersUpgradeable for CountersUpgradeable.Counter;

    mapping (address => CountersUpgradeable.Counter) private _nonces;

    // solhint-disable-next-line var-name-mixedcase
    bytes32 private _PERMIT_TYPEHASH;

    /**
     * @dev Initializes the {EIP712} domain separator using the `name` parameter, and setting `version` to `"1"`.
     *
     * It's a good idea to use the same `name` that is defined as the ERC20 token name.
     */
    function __ERC20Permit_init(string memory name) internal initializer {
        __Context_init_unchained();
        __EIP712_init_unchained(name, "1");
        __ERC20Permit_init_unchained(name);
    }

    function __ERC20Permit_init_unchained(string memory name) internal initializer {
        _PERMIT_TYPEHASH = keccak256("Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)");
    }

    /**
     * @dev See {IERC20Permit-permit}.
     */
    function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) public virtual override {
        // solhint-disable-next-line not-rely-on-time
        require(block.timestamp <= deadline, "ERC20Permit: expired deadline");

        bytes32 structHash = keccak256(
            abi.encode(
                _PERMIT_TYPEHASH,
                owner,
                spender,
                value,
                _useNonce(owner),
                deadline
            )
        );

        bytes32 hash = _hashTypedDataV4(structHash);

        address signer = ECDSAUpgradeable.recover(hash, v, r, s);
        require(signer == owner, "ERC20Permit: invalid signature");

        _approve(owner, spender, value);
    }

    /**
     * @dev See {IERC20Permit-nonces}.
     */
    function nonces(address owner) public view virtual override returns (uint256) {
        return _nonces[owner].current();
    }

    /**
     * @dev See {IERC20Permit-DOMAIN_SEPARATOR}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view override returns (bytes32) {
        return _domainSeparatorV4();
    }

    /**
     * @dev "Consume a nonce": return the current value and increment.
     *
     * _Available since v4.1._
     */
    function _useNonce(address owner) internal virtual returns (uint256 current) {
        CountersUpgradeable.Counter storage nonce = _nonces[owner];
        current = nonce.current();
        nonce.increment();
    }
    uint256[49] private __gap;
}

File 24 of 53 : AccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./AccessControlUpgradeable.sol";
import "../utils/structs/EnumerableSetUpgradeable.sol";
import "../proxy/utils/Initializable.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerableUpgradeable {
    function getRoleMember(bytes32 role, uint256 index) external view returns (address);
    function getRoleMemberCount(bytes32 role) external view returns (uint256);
}

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerableUpgradeable is Initializable, IAccessControlEnumerableUpgradeable, AccessControlUpgradeable {
    function __AccessControlEnumerable_init() internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __AccessControl_init_unchained();
        __AccessControlEnumerable_init_unchained();
    }

    function __AccessControlEnumerable_init_unchained() internal initializer {
    }
    using EnumerableSetUpgradeable for EnumerableSetUpgradeable.AddressSet;

    mapping (bytes32 => EnumerableSetUpgradeable.AddressSet) private _roleMembers;

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

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view override returns (address) {
        return _roleMembers[role].at(index);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view override returns (uint256) {
        return _roleMembers[role].length();
    }

    /**
     * @dev Overload {grantRole} to track enumerable memberships
     */
    function grantRole(bytes32 role, address account) public virtual override {
        super.grantRole(role, account);
        _roleMembers[role].add(account);
    }

    /**
     * @dev Overload {revokeRole} to track enumerable memberships
     */
    function revokeRole(bytes32 role, address account) public virtual override {
        super.revokeRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {renounceRole} to track enumerable memberships
     */
    function renounceRole(bytes32 role, address account) public virtual override {
        super.renounceRole(role, account);
        _roleMembers[role].remove(account);
    }

    /**
     * @dev Overload {_setupRole} to track enumerable memberships
     */
    function _setupRole(bytes32 role, address account) internal virtual override {
        super._setupRole(role, account);
        _roleMembers[role].add(account);
    }
    uint256[49] private __gap;
}

File 25 of 53 : CountersUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title Counters
 * @author Matt Condon (@shrugs)
 * @dev Provides counters that can only be incremented or decremented by one. 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;
        }
    }
}

File 26 of 53 : IERC20Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 standard as defined in the EIP.
 */
interface IERC20Upgradeable {
    /**
     * @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 `recipient`.
     *
     * Returns a boolean value indicating whether the operation succeeded.
     *
     * Emits a {Transfer} event.
     */
    function transfer(address recipient, 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 `sender` to `recipient` 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 sender, address recipient, uint256 amount) external returns (bool);

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

File 27 of 53 : IERC20MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT

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 28 of 53 : PausableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

/**
 * @dev Contract module which allows children to implement an emergency stop
 * mechanism that can be triggered by an authorized account.
 *
 * This module is used through inheritance. It will make available the
 * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
 * the functions of your contract. Note that they will not be pausable by
 * simply including this module, only once the modifiers are put in place.
 */
abstract contract PausableUpgradeable is Initializable, ContextUpgradeable {
    /**
     * @dev Emitted when the pause is triggered by `account`.
     */
    event Paused(address account);

    /**
     * @dev Emitted when the pause is lifted by `account`.
     */
    event Unpaused(address account);

    bool private _paused;

    /**
     * @dev Initializes the contract in unpaused state.
     */
    function __Pausable_init() internal initializer {
        __Context_init_unchained();
        __Pausable_init_unchained();
    }

    function __Pausable_init_unchained() internal initializer {
        _paused = false;
    }

    /**
     * @dev Returns true if the contract is paused, and false otherwise.
     */
    function paused() public view virtual returns (bool) {
        return _paused;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is not paused.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    modifier whenNotPaused() {
        require(!paused(), "Pausable: paused");
        _;
    }

    /**
     * @dev Modifier to make a function callable only when the contract is paused.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    modifier whenPaused() {
        require(paused(), "Pausable: not paused");
        _;
    }

    /**
     * @dev Triggers stopped state.
     *
     * Requirements:
     *
     * - The contract must not be paused.
     */
    function _pause() internal virtual whenNotPaused {
        _paused = true;
        emit Paused(_msgSender());
    }

    /**
     * @dev Returns to normal state.
     *
     * Requirements:
     *
     * - The contract must be paused.
     */
    function _unpause() internal virtual whenPaused {
        _paused = false;
        emit Unpaused(_msgSender());
    }
    uint256[49] private __gap;
}

File 29 of 53 : ArraysUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./math/MathUpgradeable.sol";

/**
 * @dev Collection of functions related to array types.
 */
library ArraysUpgradeable {
   /**
     * @dev Searches a sorted `array` and returns the first index that contains
     * a value greater or equal to `element`. If no such index exists (i.e. all
     * values in the array are strictly less than `element`), the array length is
     * returned. Time complexity O(log n).
     *
     * `array` is expected to be sorted in ascending order, and to contain no
     * repeated elements.
     */
    function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
        if (array.length == 0) {
            return 0;
        }

        uint256 low = 0;
        uint256 high = array.length;

        while (low < high) {
            uint256 mid = MathUpgradeable.average(low, high);

            // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
            // because Math.average rounds down (it does integer division with truncation).
            if (array[mid] > element) {
                high = mid;
            } else {
                low = mid + 1;
            }
        }

        // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
        if (low > 0 && array[low - 1] == element) {
            return low - 1;
        } else {
            return low;
        }
    }
}

File 30 of 53 : MathUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library MathUpgradeable {
    /**
     * @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, so we distribute
        return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
    }
}

File 31 of 53 : draft-IERC20PermitUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in
 * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].
 *
 * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by
 * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't
 * need to send a transaction, and thus is not required to hold Ether at all.
 */
interface IERC20PermitUpgradeable {
    /**
     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,
     * given ``owner``'s signed approval.
     *
     * IMPORTANT: The same issues {IERC20-approve} has related to transaction
     * ordering also apply here.
     *
     * Emits an {Approval} event.
     *
     * Requirements:
     *
     * - `spender` cannot be the zero address.
     * - `deadline` must be a timestamp in the future.
     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`
     * over the EIP712-formatted function arguments.
     * - the signature must use ``owner``'s current nonce (see {nonces}).
     *
     * For more information on the signature format, see the
     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP
     * section].
     */
    function permit(address owner, address spender, uint256 value, uint256 deadline, uint8 v, bytes32 r, bytes32 s) external;

    /**
     * @dev Returns the current nonce for `owner`. This value must be
     * included whenever a signature is generated for {permit}.
     *
     * Every successful call to {permit} increases ``owner``'s nonce by one. This
     * prevents a signature from being used multiple times.
     */
    function nonces(address owner) external view returns (uint256);

    /**
     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.
     */
    // solhint-disable-next-line func-name-mixedcase
    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

File 32 of 53 : draft-EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

File 33 of 53 : ECDSAUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
 *
 * These functions can be used to verify that a message was signed by the holder
 * of the private keys of a given address.
 */
library ECDSAUpgradeable {
    /**
     * @dev Returns the address that signed a hashed message (`hash`) with
     * `signature`. This address can then be used for verification purposes.
     *
     * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
     * this function rejects them by requiring the `s` value to be in the lower
     * half order, and the `v` value to be either 27 or 28.
     *
     * IMPORTANT: `hash` _must_ be the result of a hash operation for the
     * verification to be secure: it is possible to craft signatures that
     * recover to arbitrary addresses for non-hashed data. A safe way to ensure
     * this is by receiving a hash of the original message (which may otherwise
     * be too long), and then calling {toEthSignedMessageHash} on it.
     */
    function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
        // Divide the signature in r, s and v variables
        bytes32 r;
        bytes32 s;
        uint8 v;

        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            // solhint-disable-next-line no-inline-assembly
            assembly {
                r := mload(add(signature, 0x20))
                s := mload(add(signature, 0x40))
                v := byte(0, mload(add(signature, 0x60)))
            }
        } else if (signature.length == 64) {
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            // solhint-disable-next-line no-inline-assembly
            assembly {
                let vs := mload(add(signature, 0x40))
                r := mload(add(signature, 0x20))
                s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
                v := add(shr(255, vs), 27)
            }
        } else {
            revert("ECDSA: invalid signature length");
        }

        return recover(hash, v, r, s);
    }

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

        // If the signature is valid (and not malleable), return the signer address
        address signer = ecrecover(hash, v, r, s);
        require(signer != address(0), "ECDSA: invalid signature");

        return signer;
    }

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

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

File 34 of 53 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(uint160(value))));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint160(uint256(_at(set._inner, index))));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 35 of 53 : ERC721Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";

/**
 * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
 * the Metadata extension, but not including the Enumerable extension, which is available separately as
 * {ERC721Enumerable}.
 */
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
    using AddressUpgradeable for address;
    using StringsUpgradeable for uint256;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to owner address
    mapping (uint256 => address) private _owners;

    // Mapping owner address to token count
    mapping (address => uint256) private _balances;

    // Mapping from token ID to approved address
    mapping (uint256 => address) private _tokenApprovals;

    // Mapping from owner to operator approvals
    mapping (address => mapping (address => bool)) private _operatorApprovals;

    /**
     * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
     */
    function __ERC721_init(string memory name_, string memory symbol_) internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC721_init_unchained(name_, symbol_);
    }

    function __ERC721_init_unchained(string memory name_, string memory symbol_) internal initializer {
        _name = name_;
        _symbol = symbol_;
    }

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

    /**
     * @dev See {IERC721-balanceOf}.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        require(owner != address(0), "ERC721: balance query for the zero address");
        return _balances[owner];
    }

    /**
     * @dev See {IERC721-ownerOf}.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        address owner = _owners[tokenId];
        require(owner != address(0), "ERC721: owner query for nonexistent token");
        return owner;
    }

    /**
     * @dev See {IERC721Metadata-name}.
     */
    function name() public view virtual override returns (string memory) {
        return _name;
    }

    /**
     * @dev See {IERC721Metadata-symbol}.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev See {IERC721Metadata-tokenURI}.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");

        string memory baseURI = _baseURI();
        return bytes(baseURI).length > 0
            ? string(abi.encodePacked(baseURI, tokenId.toString()))
            : '';
    }

    /**
     * @dev Base URI for computing {tokenURI}. Empty by default, can be overriden
     * in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return "";
    }

    /**
     * @dev See {IERC721-approve}.
     */
    function approve(address to, uint256 tokenId) public virtual override {
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        require(to != owner, "ERC721: approval to current owner");

        require(_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
            "ERC721: approve caller is not owner nor approved for all"
        );

        _approve(to, tokenId);
    }

    /**
     * @dev See {IERC721-getApproved}.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        require(_exists(tokenId), "ERC721: approved query for nonexistent token");

        return _tokenApprovals[tokenId];
    }

    /**
     * @dev See {IERC721-setApprovalForAll}.
     */
    function setApprovalForAll(address operator, bool approved) public virtual override {
        require(operator != _msgSender(), "ERC721: approve to caller");

        _operatorApprovals[_msgSender()][operator] = approved;
        emit ApprovalForAll(_msgSender(), operator, approved);
    }

    /**
     * @dev See {IERC721-isApprovedForAll}.
     */
    function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
        return _operatorApprovals[owner][operator];
    }

    /**
     * @dev See {IERC721-transferFrom}.
     */
    function transferFrom(address from, address to, uint256 tokenId) public virtual override {
        //solhint-disable-next-line max-line-length
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");

        _transfer(from, to, tokenId);
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId) public virtual override {
        safeTransferFrom(from, to, tokenId, "");
    }

    /**
     * @dev See {IERC721-safeTransferFrom}.
     */
    function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory _data) public virtual override {
        require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
        _safeTransfer(from, to, tokenId, _data);
    }

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
     * are aware of the ERC721 protocol to prevent tokens from being forever locked.
     *
     * `_data` is additional data, it has no specified format and it is sent in call to `to`.
     *
     * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
     * implement alternative mechanisms to perform token transfer, such as signature-based.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must exist and be owned by `from`.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeTransfer(address from, address to, uint256 tokenId, bytes memory _data) internal virtual {
        _transfer(from, to, tokenId);
        require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Returns whether `tokenId` exists.
     *
     * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
     *
     * Tokens start existing when they are minted (`_mint`),
     * and stop existing when they are burned (`_burn`).
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return _owners[tokenId] != address(0);
    }

    /**
     * @dev Returns whether `spender` is allowed to manage `tokenId`.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
        require(_exists(tokenId), "ERC721: operator query for nonexistent token");
        address owner = ERC721Upgradeable.ownerOf(tokenId);
        return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
    }

    /**
     * @dev Safely mints `tokenId` and transfers it to `to`.
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
     *
     * Emits a {Transfer} event.
     */
    function _safeMint(address to, uint256 tokenId) internal virtual {
        _safeMint(to, tokenId, "");
    }

    /**
     * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
     * forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
     */
    function _safeMint(address to, uint256 tokenId, bytes memory _data) internal virtual {
        _mint(to, tokenId);
        require(_checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
    }

    /**
     * @dev Mints `tokenId` and transfers it to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
     *
     * Requirements:
     *
     * - `tokenId` must not exist.
     * - `to` cannot be the zero address.
     *
     * Emits a {Transfer} event.
     */
    function _mint(address to, uint256 tokenId) internal virtual {
        require(to != address(0), "ERC721: mint to the zero address");
        require(!_exists(tokenId), "ERC721: token already minted");

        _beforeTokenTransfer(address(0), to, tokenId);

        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(address(0), to, tokenId);
    }

    /**
     * @dev Destroys `tokenId`.
     * The approval is cleared when the token is burned.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     *
     * Emits a {Transfer} event.
     */
    function _burn(uint256 tokenId) internal virtual {
        address owner = ERC721Upgradeable.ownerOf(tokenId);

        _beforeTokenTransfer(owner, address(0), tokenId);

        // Clear approvals
        _approve(address(0), tokenId);

        _balances[owner] -= 1;
        delete _owners[tokenId];

        emit Transfer(owner, address(0), tokenId);
    }

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *  As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     *
     * Emits a {Transfer} event.
     */
    function _transfer(address from, address to, uint256 tokenId) internal virtual {
        require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
        require(to != address(0), "ERC721: transfer to the zero address");

        _beforeTokenTransfer(from, to, tokenId);

        // Clear approvals from the previous owner
        _approve(address(0), tokenId);

        _balances[from] -= 1;
        _balances[to] += 1;
        _owners[tokenId] = to;

        emit Transfer(from, to, tokenId);
    }

    /**
     * @dev Approve `to` to operate on `tokenId`
     *
     * Emits a {Approval} event.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _tokenApprovals[tokenId] = to;
        emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId);
    }

    /**
     * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
     * The call is not executed if the target address is not a contract.
     *
     * @param from address representing the previous owner of the given token ID
     * @param to target address that will receive the tokens
     * @param tokenId uint256 ID of the token to be transferred
     * @param _data bytes optional data to send along with the call
     * @return bool whether the call correctly returned the expected magic value
     */
    function _checkOnERC721Received(address from, address to, uint256 tokenId, bytes memory _data)
        private returns (bool)
    {
        if (to.isContract()) {
            try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
                return retval == IERC721ReceiverUpgradeable(to).onERC721Received.selector;
            } catch (bytes memory reason) {
                if (reason.length == 0) {
                    revert("ERC721: transfer to non ERC721Receiver implementer");
                } else {
                    // solhint-disable-next-line no-inline-assembly
                    assembly {
                        revert(add(32, reason), mload(reason))
                    }
                }
            }
        } else {
            return true;
        }
    }

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

File 36 of 53 : ERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev This implements an optional extension of {ERC721} defined in the EIP that adds
 * enumerability of all the token ids in the contract as well as all token ids owned by each
 * account.
 */
abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
    function __ERC721Enumerable_init() internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __ERC721Enumerable_init_unchained();
    }

    function __ERC721Enumerable_init_unchained() internal initializer {
    }
    // Mapping from owner to list of owned token IDs
    mapping(address => mapping(uint256 => uint256)) private _ownedTokens;

    // Mapping from token ID to index of the owner tokens list
    mapping(uint256 => uint256) private _ownedTokensIndex;

    // Array with all token ids, used for enumeration
    uint256[] private _allTokens;

    // Mapping from token id to position in the allTokens array
    mapping(uint256 => uint256) private _allTokensIndex;

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

    /**
     * @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
        return _ownedTokens[owner][index];
    }

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

    /**
     * @dev See {IERC721Enumerable-tokenByIndex}.
     */
    function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
        require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds");
        return _allTokens[index];
    }

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

        if (from == address(0)) {
            _addTokenToAllTokensEnumeration(tokenId);
        } else if (from != to) {
            _removeTokenFromOwnerEnumeration(from, tokenId);
        }
        if (to == address(0)) {
            _removeTokenFromAllTokensEnumeration(tokenId);
        } else if (to != from) {
            _addTokenToOwnerEnumeration(to, tokenId);
        }
    }

    /**
     * @dev Private function to add a token to this extension's ownership-tracking data structures.
     * @param to address representing the new owner of the given token ID
     * @param tokenId uint256 ID of the token to be added to the tokens list of the given address
     */
    function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
        uint256 length = ERC721Upgradeable.balanceOf(to);
        _ownedTokens[to][length] = tokenId;
        _ownedTokensIndex[tokenId] = length;
    }

    /**
     * @dev Private function to add a token to this extension's token tracking data structures.
     * @param tokenId uint256 ID of the token to be added to the tokens list
     */
    function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
        _allTokensIndex[tokenId] = _allTokens.length;
        _allTokens.push(tokenId);
    }

    /**
     * @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
     * while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
     * gas optimizations e.g. when performing a transfer operation (avoiding double writes).
     * This has O(1) time complexity, but alters the order of the _ownedTokens array.
     * @param from address representing the previous owner of the given token ID
     * @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
     */
    function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
        // To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1;
        uint256 tokenIndex = _ownedTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary
        if (tokenIndex != lastTokenIndex) {
            uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];

            _ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
            _ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
        }

        // This also deletes the contents at the last position of the array
        delete _ownedTokensIndex[tokenId];
        delete _ownedTokens[from][lastTokenIndex];
    }

    /**
     * @dev Private function to remove a token from this extension's token tracking data structures.
     * This has O(1) time complexity, but alters the order of the _allTokens array.
     * @param tokenId uint256 ID of the token to be removed from the tokens list
     */
    function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
        // To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
        // then delete the last slot (swap and pop).

        uint256 lastTokenIndex = _allTokens.length - 1;
        uint256 tokenIndex = _allTokensIndex[tokenId];

        // When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
        // rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
        // an 'if' statement (like in _removeTokenFromOwnerEnumeration)
        uint256 lastTokenId = _allTokens[lastTokenIndex];

        _allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
        _allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index

        // This also deletes the contents at the last position of the array
        delete _allTokensIndex[tokenId];
        _allTokens.pop();
    }
    uint256[46] private __gap;
}

File 37 of 53 : ERC721PausableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../ERC721Upgradeable.sol";
import "../../../security/PausableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";

/**
 * @dev ERC721 token with pausable token transfers, minting and burning.
 *
 * Useful for scenarios such as preventing trades until the end of an evaluation
 * period, or having an emergency switch for freezing all token transfers in the
 * event of a large bug.
 */
abstract contract ERC721PausableUpgradeable is Initializable, ERC721Upgradeable, PausableUpgradeable {
    function __ERC721Pausable_init() internal initializer {
        __Context_init_unchained();
        __ERC165_init_unchained();
        __Pausable_init_unchained();
        __ERC721Pausable_init_unchained();
    }

    function __ERC721Pausable_init_unchained() internal initializer {
    }
    /**
     * @dev See {ERC721-_beforeTokenTransfer}.
     *
     * Requirements:
     *
     * - the contract must not be paused.
     */
    function _beforeTokenTransfer(address from, address to, uint256 tokenId) internal virtual override {
        super._beforeTokenTransfer(from, to, tokenId);

        require(!paused(), "ERC721Pausable: token transfer while paused");
    }
    uint256[50] private __gap;
}

File 38 of 53 : Vault.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721ReceiverUpgradeable.sol";

import "./PaymentRecipientUpgradable.sol";
import "./Directory.sol";
import "./Uniquettes.sol";

contract Vault is
    ReentrancyGuardUpgradeable,
    AccessControlUpgradeable,
    IERC721ReceiverUpgradeable,
    PaymentRecipientUpgradable
{
    bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");

    event UniquetteLiquidated(
        address indexed operator,
        address indexed owner,
        address beneficiary,
        uint256 indexed tokenId,
        uint256 collateralValue
    );

    // TODO Avoid importing directory to prevent re-deploying Vault every time Directory is updated
    Directory private _directory;

    function initialize() public initializer {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(GOVERNOR_ROLE, _msgSender());
    }

    //
    // Modifiers
    //
    modifier isGovernor() {
        require(hasRole(GOVERNOR_ROLE, _msgSender()), "Vault: caller is not governor");
        _;
    }

    //
    // Admin functions
    //
    function setDirectoryAddress(address newDirectoryAddress) public virtual {
        require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "Vault: caller is not an admin");
        _directory = Directory(newDirectoryAddress);
    }

    //
    // Generic and standard functions
    //
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external pure override returns (bytes4) {
        return IERC721ReceiverUpgradeable.onERC721Received.selector;
    }

    //
    // Unique functions
    //
    function uniquetteLiquidate(uint256 tokenId, address payable beneficiary) public virtual nonReentrant {
        address operator = _msgSender();

        Uniquettes.Uniquette memory uniquette = _directory.uniquetteGetById(tokenId);

        require(
            uniquette.owner == operator || _directory.isApprovedForAll(uniquette.owner, operator),
            "Vault: not an owner or approved operator"
        );

        _directory.safeTransferFrom(uniquette.owner, address(this), tokenId);
        payable(address(beneficiary)).transfer(uniquette.collateralValue);

        //_directory.uniquetteForSale(tokenId, uniquette.collateralValue); TODO Allow to collect by paying just collateral value

        emit UniquetteLiquidated(operator, uniquette.owner, beneficiary, tokenId, uniquette.collateralValue);
    }
}

File 39 of 53 : Marketer.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol";

import "./PaymentRecipient.sol";
import "./OpenSeaExchangeInterface.sol";
import "./OpenSeaRegistryInterface.sol";

contract Marketer is
ReentrancyGuard,
AccessControl,
IERC721Receiver,
PaymentRecipient
{
    bytes32 public constant GOVERNOR_ROLE = keccak256("GOVERNOR_ROLE");

    bytes constant emptyBytes = bytes("");
    bytes constant replacementPattern = bytes(hex"000000000000000000000000000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF0000000000000000000000000000000000000000000000000000000000000000");

    address private _directory;
    OpenSeaExchangeInterface private _openSeaExchange;
    address private _openSeaWallet;

    constructor() {
        _setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
        _setupRole(GOVERNOR_ROLE, _msgSender());
    }

    //
    // Modifiers
    //
    modifier isGovernor() {
        require(hasRole(GOVERNOR_ROLE, _msgSender()) || hasRole(GOVERNOR_ROLE, msg.sender), "Marketer: caller is not governor");
        _;
    }

    modifier isDirectory() {
        require(_msgSender() == _directory || msg.sender == _directory, "Marketer: caller is not directory");
        _;
    }

    //
    // Generic and standard functions
    //
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external pure override returns (bytes4) {
        return IERC721Receiver.onERC721Received.selector;
    }

    //
    // Admin functions
    //
    function registerOpenSeaProxy(address registryAddress) public virtual isGovernor() {
        OpenSeaRegistryInterface(registryAddress).registerProxy();
    }

    function setDirectoryAddress(address newAddress) public virtual isGovernor() {
        _directory = newAddress;
    }

    function setOpenSeaExchangeAddress(address newAddress) public virtual isGovernor() {
        _openSeaExchange = OpenSeaExchangeInterface(newAddress);
    }

    function setOpenSeaWalletAddress(address newAddress) public virtual isGovernor() {
        _openSeaWallet = newAddress;
    }

    function putForSale(
        address owner,
        uint256 tokenId,
        uint256 salePrice
    ) public virtual isDirectory()
    {
        uint zero = 0;
        uint one = 1;

        address zeroAddr = address(0);
        bytes memory transferCalldata = abi.encodeWithSignature("transferFrom(address,address,uint256)", owner, zeroAddr, tokenId);
        address[7] memory addrs;
        uint[9] memory uints;

        {
            addrs = [
            // Exchange
            address(_openSeaExchange),
            // Maker
            address(this),
            // Taker
            zeroAddr,
            // Fee Recipient
            _openSeaWallet, // TODO could be unique's treasury directly
            // Target (Asset Contract)
            address(_directory),
            // Static Target
            zeroAddr,
            // Token used to pay for the order, or the zero-address as a sentinel value for Ether
            zeroAddr
            ];
        }
        {
            uints = [
            // Maker Relayer Fee
            zero, // TODO get relayer fee from param (could be unique's 5% fee)
            // Taker Relayer Fee
            zero,
            // Maker Protocol Fee
            zero, // TODO get protocol fee from param
            // Taker Protocol Fee
            zero,
            // Base price of the order (in paymentTokens)
            salePrice,
            // Auction extra parameter - minimum bid increment for English auctions, starting/ending price difference
            zero,
            // Listing Time
            block.timestamp,
            // Expiration timestamp - 0 for no expiry
            zero,
            // Order salt, used to prevent duplicate hashes
            uint(keccak256(abi.encodePacked(block.difficulty, block.timestamp)))
            ];
        }

        {
            _approveWyvernOrder(
                addrs,
                uints,
                transferCalldata
            );
        }
    }

    function _approveWyvernOrder(
        address[7] memory addrs,
        uint[9] memory uints,
        bytes memory transferCalldata
    ) internal {
        _openSeaExchange.approveOrder_(
        addrs,
        uints,
        // Fee Method
        OpenSeaExchangeInterface.FeeMethod.ProtocolFee,
        // Side (sell)
        OpenSeaExchangeInterface.Side.Sell,
        // Sale Kind (fixed price)
        OpenSeaExchangeInterface.SaleKind.FixedPrice,
        // How to call (call)
        OpenSeaExchangeInterface.HowToCall.Call,
        // Call Data
        transferCalldata,
        // Replacement Pattern
        replacementPattern,
        // staticExtradata
        emptyBytes,
        // orderbookInclusionDesired
        true
        );
    }
}

File 40 of 53 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

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

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

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

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

    /**
     * @dev Safely transfers `tokenId` token from `from` to `to`, 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 be 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: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * 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 Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) external view returns (address operator);

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

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

File 41 of 53 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(address operator, address from, uint256 tokenId, bytes calldata data) external returns (bytes4);
}

File 42 of 53 : IERC721MetadataUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721MetadataUpgradeable is IERC721Upgradeable {

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

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

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) external view returns (string memory);
}

File 43 of 53 : IERC721EnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../IERC721Upgradeable.sol";

/**
 * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
 * @dev See https://eips.ethereum.org/EIPS/eip-721
 */
interface IERC721EnumerableUpgradeable is IERC721Upgradeable {

    /**
     * @dev Returns the total amount of tokens stored by the contract.
     */
    function totalSupply() external view returns (uint256);

    /**
     * @dev Returns a token ID owned by `owner` at a given `index` of its token list.
     * Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
     */
    function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);

    /**
     * @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
     * Use along with {totalSupply} to enumerate all tokens.
     */
    function tokenByIndex(uint256 index) external view returns (uint256);
}

File 44 of 53 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 45 of 53 : AccessControl.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev External interface of AccessControl declared to support ERC165 detection.
 */
interface IAccessControl {
    function hasRole(bytes32 role, address account) external view returns (bool);

    function getRoleAdmin(bytes32 role) external view returns (bytes32);

    function grantRole(bytes32 role, address account) external;

    function revokeRole(bytes32 role, address account) external;

    function renounceRole(bytes32 role, address account) external;
}

/**
 * @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 AccessControl is Context, IAccessControl, ERC165 {
    struct RoleData {
        mapping(address => bool) members;
        bytes32 adminRole;
    }

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @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 {_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 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]{20}) is missing role (0x[0-9a-f]{32})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role, _msgSender());
        _;
    }

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

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

    /**
     * @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]{20}) is missing role (0x[0-9a-f]{32})$/
     */
    function _checkRole(bytes32 role, address account) internal view {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(uint160(account), 20),
                        " is missing role ",
                        Strings.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 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.
     */
    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.
     */
    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 granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    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.
     *
     * [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}.
     * ====
     */
    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 {
        emit RoleAdminChanged(role, getRoleAdmin(role), adminRole);
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (!hasRole(role, account)) {
            _roles[role].members[account] = true;
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 46 of 53 : IERC721Receiver.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721Receiver {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

File 47 of 53 : PaymentRecipient.sol
//SPDX-License-Identifier: AGPL-3.0
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/utils/Context.sol";

contract PaymentRecipient is Context {
    event ReceivedEther(address indexed sender, uint256 amount);

    /**
     * @dev Receive Ether and generate a log event
     */
    receive() external payable {
        emit ReceivedEther(_msgSender(), msg.value);
    }
}

File 48 of 53 : OpenSeaExchangeInterface.sol
interface OpenSeaExchangeInterface {
    enum FeeMethod { ProtocolFee, SplitFee }

    /**
     * Side: buy or sell.
     */
    enum Side { Buy, Sell }

    /**
     * Currently supported kinds of sale: fixed price, Dutch auction.
     * English auctions cannot be supported without stronger escrow guarantees.
     * Future interesting options: Vickrey auction, nonlinear Dutch auctions.
     */
    enum SaleKind { FixedPrice, DutchAuction }

    enum HowToCall { Call, DelegateCall }

    function approveOrder_(
        address[7] calldata addrs,
        uint[9] calldata uints,
        FeeMethod feeMethod, // FeeMethod
        Side side, // Side
        SaleKind saleKind, // SaleKind
        HowToCall howToCall, //HowToCall
        bytes calldata,
        bytes memory replacementPattern,
        bytes memory staticExtradata,
        bool orderbookInclusionDesired) external;
}

File 49 of 53 : OpenSeaRegistryInterface.sol
interface OpenSeaRegistryInterface {
    function registerProxy() external;
}

File 50 of 53 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

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

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

File 51 of 53 : Strings.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @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] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }
}

File 52 of 53 : ERC165.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.8.0;

import "./IERC165.sol";

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

File 53 of 53 : IERC165.sol
// SPDX-License-Identifier: MIT

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);
}

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

Contract ABI

[{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"approved","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Approval","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"bool","name":"approved","type":"bool"}],"name":"ApprovalForAll","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":false,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"collector","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"feePaid","type":"uint256"}],"name":"ProtocolFeePaid","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":false,"internalType":"address","name":"approver","type":"address"},{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":false,"internalType":"string","name":"hash","type":"string"},{"indexed":false,"internalType":"uint256","name":"reward","type":"uint256"}],"name":"SubmissionApproved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"submitter","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"hash","type":"string"},{"indexed":false,"internalType":"uint256","name":"addedValue","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"deposit","type":"uint256"}],"name":"SubmissionCreated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"collector","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"string","name":"submissionHash","type":"string"},{"indexed":false,"internalType":"uint256","name":"appreciatedPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"payment","type":"uint256"}],"name":"SubmissionFunded","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"approver","type":"address"},{"indexed":true,"internalType":"address","name":"author","type":"address"},{"indexed":false,"internalType":"string","name":"hash","type":"string"}],"name":"SubmissionRejected","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"submitter","type":"address"},{"indexed":false,"internalType":"string","name":"hash","type":"string"},{"indexed":false,"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"SubmissionUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"owner","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"additionalCollateral","type":"uint256"}],"name":"UniquetteCollateralIncreased","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"operator","type":"address"},{"indexed":true,"internalType":"address","name":"seller","type":"address"},{"indexed":true,"internalType":"address","name":"collector","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"effectivePrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"appreciatedPrice","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"principalAmount","type":"uint256"}],"name":"UniquetteCollected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"approver","type":"address"},{"indexed":true,"internalType":"address","name":"submitter","type":"address"},{"indexed":false,"internalType":"string","name":"hash","type":"string"}],"name":"UniquetteRejected","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GOVERNOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"batchBurn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"getParameters","outputs":[{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"currentMetadataVersion","type":"uint256"},{"internalType":"uint256","name":"minMetadataVersion","type":"uint256"},{"internalType":"uint256","name":"maxPriceAppreciation","type":"uint256"},{"internalType":"uint256","name":"submissionDeposit","type":"uint256"}],"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":"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":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"tokensBaseURI","type":"string"},{"internalType":"address","name":"token","type":"address"},{"internalType":"address payable","name":"vault","type":"address"},{"internalType":"address payable","name":"treasury","type":"address"},{"internalType":"address payable","name":"marketer","type":"address"},{"internalType":"uint256","name":"protocolFee","type":"uint256"},{"internalType":"uint256","name":"minMetadataVersion","type":"uint256"},{"internalType":"uint256","name":"currentMetadataVersion","type":"uint256"},{"internalType":"uint256","name":"maxPriceAppreciation","type":"uint256"},{"internalType":"uint256","name":"submissionDeposit","type":"uint256"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"pause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"paused","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","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":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"bytes","name":"_data","type":"bytes"}],"name":"safeTransferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setCurrentMetadataVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"hash","type":"string"}],"name":"setHighlightedSubmission","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newAddress","type":"address"}],"name":"setMarketerAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newAddress","type":"address"}],"name":"setMarketerProxyAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setMaxPriceAppreciation","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setMinMetadataVersion","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setProtocolFee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newValue","type":"uint256"}],"name":"setSubmissionDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"newAddress","type":"address"}],"name":"setTokenAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newAddress","type":"address"}],"name":"setTreasuryAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"newAddress","type":"address"}],"name":"setVaultAddress","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"hash","type":"string"},{"internalType":"uint256","name":"rewardOverride","type":"uint256"}],"name":"submissionApprove","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string[]","name":"hashes","type":"string[]"},{"internalType":"uint256[]","name":"rewards","type":"uint256[]"}],"name":"submissionApproveBulk","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"hash","type":"string"},{"internalType":"uint256","name":"metadataVersion","type":"uint256"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"submissionCreate","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string[]","name":"hashes","type":"string[]"},{"internalType":"uint256[]","name":"metadataVersions","type":"uint256[]"},{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"},{"internalType":"uint256[]","name":"addedValues","type":"uint256[]"}],"name":"submissionCreateBulk","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"string","name":"submissionHash","type":"string"}],"name":"submissionFund","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"string","name":"hash","type":"string"}],"name":"submissionGetByHash","outputs":[{"components":[{"internalType":"address","name":"author","type":"address"},{"internalType":"uint256","name":"addedValue","type":"uint256"},{"internalType":"uint256","name":"reward","type":"uint256"},{"internalType":"uint256","name":"metadataVersion","type":"uint256"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"parentHash","type":"uint256"},{"internalType":"uint256","name":"deposit","type":"uint256"},{"internalType":"enum Submissions.SubmissionStatus","name":"status","type":"uint8"}],"internalType":"struct Submissions.Submission","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"string","name":"hash","type":"string"}],"name":"submissionReject","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"hash","type":"string"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"addedValue","type":"uint256"}],"name":"submissionUpdate","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"tokenOfOwnerByIndex","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"from","type":"address"},{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"transferFrom","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uniquetteCollect","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uniquetteGetById","outputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"collateralValue","type":"uint256"},{"internalType":"uint256","name":"lastPurchaseAmount","type":"uint256"}],"internalType":"struct Uniquettes.Uniquette","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uniquetteGetFundedSubmission","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uniquetteIncreaseCollateral","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uniquetteListOnOpenSea","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"uniquetteRemoveFromOpenSea","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b50615ede80620000216000396000f3fe6080604052600436106102df5760003560e01c80636a62b36211610186578063a6dfa18b116100d7578063ccc5749011610085578063ccc574901461092e578063d547741f14610950578063dc8e92ea14610970578063e65e1a1014610990578063e985e9c5146109a3578063ee499375146109c3578063ffe329d9146109e3576102df565b8063a6dfa18b1461085b578063aa066d571461087b578063b88d4fde1461089b578063bde1312d146108bb578063bf140572146108ce578063c7771a3f146108ee578063c87b56dd1461090e576102df565b806385535cc51161013457806385535cc51461075b57806391d148541461077b57806395d89b411461079b5780639b7bddb0146107b0578063a217fddf146107dd578063a22cb465146107f2578063a5ea11da14610812576102df565b80636a62b3621461069357806370a08231146106b3578063714b63dc146106d357806372491ead146106f3578063787dce3d146107065780637d36b348146107265780638456cb5914610746576102df565b80632c1da7f31161024057806342966c68116101ee57806342966c68146105bb5780634c11893c146105db5780634f6ccce7146105fb5780635c975abb1461061b5780636352211e1461063357806363ff2c26146106535780636605bfda14610673576102df565b80632c1da7f3146104e65780632f2ff15d146105065780632f745c591461052657806332f72e391461054657806336568abe146105665780633f4ba83a1461058657806342842e0e1461059b576102df565b806318160ddd1161029d57806318160ddd146103c8578063194aaa13146103e757806320cbbb0c146103fa5780632324eef01461045657806323b872dd14610476578063248a9ca31461049657806326a4e8d2146104c6576102df565b8062f1e4cb146102e457806301ffc9a7146102f957806304d7bbbb1461032e57806306fdde031461034e578063081812fc14610370578063095ea7b3146103a8575b600080fd5b6102f76102f236600461517a565b610a03565b005b34801561030557600080fd5b506103196103143660046153af565b610b10565b60405190151581526020015b60405180910390f35b34801561033a57600080fd5b506102f76103493660046155b7565b610b23565b34801561035a57600080fd5b50610363610b77565b60405161032591906158dc565b34801561037c57600080fd5b5061039061038b366004615373565b610c09565b6040516001600160a01b039091168152602001610325565b3480156103b457600080fd5b506102f76103c336600461517a565b610c91565b3480156103d457600080fd5b5060cb545b604051908152602001610325565b6102f76103f53660046151a5565b610cf9565b34801561040657600080fd5b5061041a610415366004615373565b610ff7565b6040516103259190815181526020808301516001600160a01b031690820152604080830151908201526060918201519181019190915260800190565b34801561046257600080fd5b506102f7610471366004615373565b6110bf565b34801561048257600080fd5b506102f7610491366004615091565b6110f9565b3480156104a257600080fd5b506103d96104b1366004615373565b60009081526065602052604090206001015490565b3480156104d257600080fd5b506102f76104e136600461503d565b61112f565b3480156104f257600080fd5b506102f76105013660046151fe565b611186565b34801561051257600080fd5b506102f761052136600461538b565b6112c5565b34801561053257600080fd5b506103d961054136600461517a565b6112ec565b34801561055257600080fd5b506102f7610561366004615373565b611382565b34801561057257600080fd5b506102f761058136600461538b565b6113bc565b34801561059257600080fd5b506102f761143a565b3480156105a757600080fd5b506102f76105b6366004615091565b611478565b3480156105c757600080fd5b506102f76105d6366004615373565b611493565b3480156105e757600080fd5b506102f76105f6366004615463565b611570565b34801561060757600080fd5b506103d9610616366004615373565b6117fc565b34801561062757600080fd5b5060fb5460ff16610319565b34801561063f57600080fd5b5061039061064e366004615373565b61189d565b34801561065f57600080fd5b506102f761066e3660046154b1565b611914565b34801561067f57600080fd5b506102f761068e36600461503d565b611a1b565b34801561069f57600080fd5b506102f76106ae36600461503d565b611a64565b3480156106bf57600080fd5b506103d96106ce36600461503d565b611abb565b3480156106df57600080fd5b506102f76106ee3660046153e7565b611b42565b6102f761070136600461525a565b611d91565b34801561071257600080fd5b506102f7610721366004615373565b611ffa565b34801561073257600080fd5b506102f761074136600461541a565b612034565b34801561075257600080fd5b506102f76120a8565b34801561076757600080fd5b506102f761077636600461503d565b6120e4565b34801561078757600080fd5b5061031961079636600461538b565b61213b565b3480156107a757600080fd5b50610363612166565b3480156107bc57600080fd5b506107d06107cb3660046153e7565b612175565b6040516103259190615bef565b3480156107e957600080fd5b506103d9600081565b3480156107fe57600080fd5b506102f761080d36600461514d565b6122a6565b34801561081e57600080fd5b506101915461019254610193546101945461019554604080519586526020860194909452928401919091526060830152608082015260a001610325565b34801561086757600080fd5b506102f7610876366004615373565b61231e565b34801561088757600080fd5b506102f7610896366004615373565b61245d565b3480156108a757600080fd5b506102f76108b63660046150d1565b61258a565b6102f76108c9366004615600565b6125bc565b3480156108da57600080fd5b506102f76108e9366004615373565b61288b565b3480156108fa57600080fd5b50610363610909366004615373565b6128c5565b34801561091a57600080fd5b50610363610929366004615373565b612968565b34801561093a57600080fd5b506103d9600080516020615e4983398151915281565b34801561095c57600080fd5b506102f761096b36600461538b565b612a31565b34801561097c57600080fd5b506102f761098b366004615318565b612a57565b6102f761099e366004615373565b612b28565b3480156109af57600080fd5b506103196109be366004615059565b612c3b565b3480156109cf57600080fd5b506102f76109de36600461503d565b612cd7565b3480156109ef57600080fd5b506102f76109fe366004615373565b612d2e565b80610a0d81612d68565b8015610a275750600081815261019c602052604090205415155b610a4c5760405162461bcd60e51b8152600401610a4390615b4e565b60405180910390fd5b600261015f541415610a705760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55600082815261019f602052604081208054610a9090615d93565b905011610af45760405162461bcd60e51b815260206004820152602c60248201527f4449524543544f52592f4e4f5f5355424d495353494f4e5f46554e4445445f4660448201526b4f525f554e4951554554544560a01b6064820152608401610a43565b610b013384846000612d85565b5050600161015f555050505050565b6000610b1b826131e7565b90505b919050565b610b3b600080516020615e4983398151915233610796565b610b575760405162461bcd60e51b8152600401610a4390615b81565b60008381526101a360205260409020610b71908383614d9d565b50505050565b606060978054610b8690615d93565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb290615d93565b8015610bff5780601f10610bd457610100808354040283529160200191610bff565b820191906000526020600020905b815481529060010190602001808311610be257829003601f168201915b5050505050905090565b6000610c1482612d68565b610c755760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a43565b506000908152609b60205260409020546001600160a01b031690565b60405162461bcd60e51b815260206004820152603760248201527f4469726563746f72793a20617070726f7665206e6f7420737570706f72746564604482015276206f6e20756e69717565747465207472616e736665727360481b6064820152608401610a43565b82610d0381612d68565b8015610d1d5750600081815261019c602052604090205415155b610d395760405162461bcd60e51b8152600401610a4390615b4e565b828260006001600160a01b03166101978383604051610d59929190615749565b908152604051908190036020019020546001600160a01b03161415610d905760405162461bcd60e51b8152600401610a4390615978565b848460016101978383604051610da7929190615749565b9081526040519081900360200190206007015460ff166002811115610ddc57634e487b7160e01b600052602160045260246000fd5b14610df95760405162461bcd60e51b8152600401610a4390615a07565b8686610193546101978383604051610e12929190615749565b9081526020016040518091039020600301541015610e425760405162461bcd60e51b8152600401610a4390615a87565b600261015f541415610e665760405162461bcd60e51b8152600401610a4390615bb8565b600261015f556000610e788a8a612175565b90508a816080015114610ee05760405162461bcd60e51b815260206004820152602a60248201527f4449524543544f52592f494e56414c49445f5355424d495353494f4e5f464f526044820152695f554e4951554554544560b01b6064820152608401610a43565b60008b815261019f60205260409020610efa908b8b614d9d565b50610f058a8a6131f2565b6000610f17338e8e8560200151612d85565b50506101a054845160408087015190516340c10f1960e01b81526001600160a01b03928316600482015260248101919091529294501691506340c10f1990604401600060405180830381600087803b158015610f7257600080fd5b505af1158015610f86573d6000803e3d6000fd5b505050508b8d6001600160a01b0316610f9c3390565b6001600160a01b03167f1e0392d89fc63a5033fa3b8ccb7befb7fd00ac557728fa9518a257c0fb6e08f88e8e8634604051610fda94939291906158b5565b60405180910390a45050600161015f555050505050505050505050565b61102b60405180608001604052806000815260200160006001600160a01b0316815260200160008152602001600081525090565b8161103581612d68565b801561104f5750600081815261019c602052604090205415155b61106b5760405162461bcd60e51b8152600401610a4390615b4e565b600083815261019c602090815260409182902082516080810184528154815260018201546001600160a01b031692810192909252600281015492820192909252600390910154606082015291505b50919050565b6110d7600080516020615e4983398151915233610796565b6110f35760405162461bcd60e51b8152600401610a4390615b81565b61019255565b611103338261330e565b61111f5760405162461bcd60e51b8152600401610a4390615afd565b61112a838383613408565b505050565b611147600080516020615e4983398151915233610796565b6111635760405162461bcd60e51b8152600401610a4390615b81565b61019880546001600160a01b0319166001600160a01b0392909216919091179055565b61119e600080516020615e4983398151915233610796565b6111ba5760405162461bcd60e51b8152600401610a4390615b81565b600261015f5414156111de5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5582811461123c5760405162461bcd60e51b81526020600482015260326024820152600080516020615e89833981519152604482015271206e6f74206d61746368207265776172647360701b6064820152608401610a43565b60005b838110156112b8576112a885858381811061126a57634e487b7160e01b600052603260045260246000fd5b905060200281019061127c9190615c9e565b85858581811061129c57634e487b7160e01b600052603260045260246000fd5b905060200201356135a1565b6112b181615dc8565b905061123f565b5050600161015f55505050565b6000828152606560205260409020600101546112e281335b6137e0565b61112a8383613844565b60006112f783611abb565b82106113595760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610a43565b506001600160a01b0391909116600090815260c960209081526040808320938352929052205490565b61139a600080516020615e4983398151915233610796565b6113b65760405162461bcd60e51b8152600401610a4390615b81565b61019555565b6001600160a01b038116331461142c5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a43565b61143682826138ca565b5050565b611452600080516020615e4983398151915233610796565b61146e5760405162461bcd60e51b8152600401610a4390615b81565b611476613931565b565b61112a8383836040518060200160405280600081525061258a565b6114ab600080516020615e4983398151915233610796565b6114c75760405162461bcd60e51b8152600401610a4390615b81565b600081815261019c602090815260409182902082516080810184528154815260018201546001600160a01b03908116938201849052600283015494820194909452600390910154606082015261019954909216146115675760405162461bcd60e51b815260206004820152601d60248201527f554e49515545545445532f4e4f545f4f574e45445f42595f5641554c540000006044820152606401610a43565b611436826139c4565b838360006001600160a01b03166101978383604051611590929190615749565b908152604051908190036020019020546001600160a01b031614156115c75760405162461bcd60e51b8152600401610a4390615978565b8585600061019783836040516115de929190615749565b9081526040519081900360200190206007015460ff16600281111561161357634e487b7160e01b600052602160045260246000fd5b146116305760405162461bcd60e51b8152600401610a4390615acc565b8787610193546101978383604051611649929190615749565b90815260200160405180910390206003015410156116795760405162461bcd60e51b8152600401610a4390615a87565b600261015f54141561169d5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55336001600160a01b03166101978b8b6040516116c0929190615749565b908152604051908190036020019020546001600160a01b031614806116f857506116f8600080516020615e4983398151915233610796565b61174f5760405162461bcd60e51b815260206004820152602260248201527f5355424d495353494f4e532f4e4f545f415554484f525f4f525f474f5645524e60448201526127a960f11b6064820152608401610a43565b876101978b8b604051611763929190615749565b908152602001604051809103902060040181905550866101978b8b60405161178c929190615749565b908152604051908190036020019020600101556117a63390565b6001600160a01b03167f5d65f7cb575787e992f9f65bcde54aff4e5796220138384beb8d746b439a4aad8b8b8a6040516117e293929190615891565b60405180910390a25050600161015f555050505050505050565b600061180760cb5490565b821061186a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610a43565b60cb828154811061188b57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152609960205260408120546001600160a01b031680610b1b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610a43565b600054610100900460ff168061192d575060005460ff16155b6119495760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561196b576000805461ffff19166101011790555b6119788686868686613a59565b6119868d8d8c8c8c8c613ad7565b61198f88613b61565b6101a080546001600160a01b03808d166001600160a01b0319928316179092556101a18054928c16929091169190911790558a516119d5906101a29060208e0190614e21565b506119e26000335b613bd6565b6119fa600080516020615e49833981519152336119dd565b8015611a0c576000805461ff00191690555b50505050505050505050505050565b611a33600080516020615e4983398151915233610796565b611a4f5760405162461bcd60e51b8152600401610a4390615b81565b611a5881613be0565b611a6181613c37565b50565b611a7c600080516020615e4983398151915233610796565b611a985760405162461bcd60e51b8152600401610a4390615b81565b61019e80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b038216611b265760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610a43565b506001600160a01b03166000908152609a602052604090205490565b611b5a600080516020615e4983398151915233610796565b611b765760405162461bcd60e51b8152600401610a4390615b81565b818160006001600160a01b03166101978383604051611b96929190615749565b908152604051908190036020019020546001600160a01b03161415611bcd5760405162461bcd60e51b8152600401610a4390615978565b838360006101978383604051611be4929190615749565b9081526040519081900360200190206007015460ff166002811115611c1957634e487b7160e01b600052602160045260246000fd5b14611c365760405162461bcd60e51b8152600401610a4390615acc565b600261015f541415611c5a5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5560405160009061019790611c779089908990615749565b908152604051908190036020018120546001600160a01b0316915060009061019790611ca6908a908a90615749565b90815260200160405180910390206006015490506101978888604051611ccd929190615749565b90815260405190819003602001902080546001600160a01b0319168155600060018201819055600282018190556003820181905560048201819055600582018190556006820155600701805460ff191690558015611d3c5761019654611d3c906001600160a01b031682613c8e565b6001600160a01b0382167fd0ebb0eea23bb48fde00a512003aa8e1a997969ece3a7bd7bd867b0b4fe2e698338a8a604051611d7993929190615836565b60405180910390a25050600161015f55505050505050565b600261015f541415611db55760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55868514611e1e5760405162461bcd60e51b815260206004820152603b6024820152600080516020615e8983398151915260448201527f206e6f74206d61746368206d6574616461746156657273696f6e7300000000006064820152608401610a43565b868314611e775760405162461bcd60e51b81526020600482015260336024820152600080516020615e89833981519152604482015272206e6f74206d6174636820746f6b656e49647360681b6064820152608401610a43565b868114611ece5760405162461bcd60e51b81526020600482015260316024820152600080516020615e89833981519152604482015270206e6f74206d617463682076616c75657360781b6064820152608401610a43565b60005b87811015611fe9573063bde1312d868684818110611eff57634e487b7160e01b600052603260045260246000fd5b905060200201358b8b85818110611f2657634e487b7160e01b600052603260045260246000fd5b9050602002810190611f389190615c9e565b8b8b87818110611f5857634e487b7160e01b600052603260045260246000fd5b90506020020135888888818110611f7f57634e487b7160e01b600052603260045260246000fd5b905060200201356040518663ffffffff1660e01b8152600401611fa6959493929190615c70565b600060405180830381600087803b158015611fc057600080fd5b505af1158015611fd4573d6000803e3d6000fd5b5050505080611fe290615dc8565b9050611ed1565b5050600161015f5550505050505050565b612012600080516020615e4983398151915233610796565b61202e5760405162461bcd60e51b8152600401610a4390615b81565b61019155565b61204c600080516020615e4983398151915233610796565b6120685760405162461bcd60e51b8152600401610a4390615b81565b600261015f54141561208c5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5561209d8383836135a1565b5050600161015f5550565b6120c0600080516020615e4983398151915233610796565b6120dc5760405162461bcd60e51b8152600401610a4390615b81565b611476613da7565b6120fc600080516020615e4983398151915233610796565b6121185760405162461bcd60e51b8152600401610a4390615b81565b61019980546001600160a01b0319166001600160a01b0392909216919091179055565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060988054610b8690615d93565b61217d614e95565b828260006001600160a01b0316610197838360405161219d929190615749565b908152604051908190036020019020546001600160a01b031614156121d45760405162461bcd60e51b8152600401610a4390615978565b61019785856040516121e7929190615749565b9081526040805191829003602090810183206101008401835280546001600160a01b03168452600181015491840191909152600280820154928401929092526003810154606084015260048101546080840152600581015460a0840152600681015460c08401526007810154909160e084019160ff169081111561227b57634e487b7160e01b600052602160045260246000fd5b600281111561229a57634e487b7160e01b600052602160045260246000fd5b90525095945050505050565b60405162461bcd60e51b815260206004820152604160248201527f4469726563746f72793a20736574417070726f76616c466f72416c6c206e6f7460448201527f20737570706f72746564206f6e20756e69717565747465207472616e736665726064820152607360f81b608482015260a401610a43565b8061232881612d68565b80156123425750600081815261019c602052604090205415155b61235e5760405162461bcd60e51b8152600401610a4390615b4e565b600261015f5414156123825760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55600082815261019f6020526040812080546123a290615d93565b905011806123c9575060008281526101a36020526040812080546123c590615d93565b9050115b6123e55760405162461bcd60e51b8152600401610a43906159af565b60006123f083610ff7565b60208101519091506001600160a01b03163314806124215750612421600080516020615e4983398151915233610796565b61243d5760405162461bcd60e51b8152600401610a4390615941565b61209d8160200151846124586124503390565b600086613e22565b613edc565b8061246781612d68565b80156124815750600081815261019c602052604090205415155b61249d5760405162461bcd60e51b8152600401610a4390615b4e565b600261015f5414156124c15760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55600082815261019f6020526040812080546124e190615d93565b90501180612508575060008281526101a360205260408120805461250490615d93565b9050115b6125245760405162461bcd60e51b8152600401610a43906159af565b600061252f83610ff7565b60208101519091506001600160a01b03163314806125605750612560600080516020615e4983398151915233610796565b61257c5760405162461bcd60e51b8152600401610a4390615941565b61209d816020015184613fca565b612594338361330e565b6125b05760405162461bcd60e51b8152600401610a4390615afd565b610b7184848484613ffe565b60006001600160a01b031661019785856040516125da929190615749565b908152604051908190036020019020546001600160a01b0316146126405760405162461bcd60e51b815260206004820152601b60248201527f5355424d495353494f4e532f414c52454144595f4352454154454400000000006044820152606401610a43565b61019554341461269d5760405162461bcd60e51b815260206004820152602260248201527f5355424d495353494f4e532f45584143545f4445504f5349545f524551554952604482015261115160f21b6064820152608401610a43565b610193548210156127015760405162461bcd60e51b815260206004820152602860248201527f5355424d495353494f4e532f554e535550504f525445445f4d455441444154416044820152672fab22a929a4a7a760c11b6064820152608401610a43565b336101978585604051612715929190615749565b90815260405190819003602001812080546001600160a01b03939093166001600160a01b0319909316929092179091558590610197906127589087908790615749565b908152602001604051809103902060040181905550816101978585604051612781929190615749565b9081526020016040518091039020600301819055508061019785856040516127aa929190615749565b9081526020016040518091039020600101819055503461019785856040516127d3929190615749565b908152602001604051809103902060060181905550600061019785856040516127fd929190615749565b908152604051908190036020019020600701805460ff1916600183600281111561283757634e487b7160e01b600052602160045260246000fd5b021790555084336001600160a01b03167f4d66d41804994e0b3749bf214861b72fe46575c5645646e020570c8403e7a1d68686853460405161287c94939291906158b5565b60405180910390a35050505050565b6128a3600080516020615e4983398151915233610796565b6128bf5760405162461bcd60e51b8152600401610a4390615b81565b61019355565b600081815261019f602052604090208054606091906128e390615d93565b80601f016020809104026020016040519081016040528092919081815260200182805461290f90615d93565b801561295c5780601f106129315761010080835404028352916020019161295c565b820191906000526020600020905b81548152906001019060200180831161293f57829003601f168201915b50505050509050919050565b60608161297481612d68565b801561298e5750600081815261019c602052604090205415155b6129aa5760405162461bcd60e51b8152600401610a4390615b4e565b600083815261019f6020526040902080546129c490615d93565b159050612a09576101a261019f60008581526020019081526020016000206040516020016129f3929190615775565b60405160208183030381529060405291506110b9565b6101a26101a360008581526020019081526020016000206040516020016129f3929190615775565b600082815260656020526040902060010154612a4d81336112dd565b61112a83836138ca565b612a6f600080516020615e4983398151915233610796565b612a8b5760405162461bcd60e51b8152600401610a4390615b81565b60005b8181101561112a576000838383818110612ab857634e487b7160e01b600052603260045260246000fd5b604051630852cd8d60e31b81526020909102929092013560048301819052925030916342966c689150602401600060405180830381600087803b158015612afe57600080fd5b505af1158015612b12573d6000803e3d6000fd5b505050505080612b2190615dc8565b9050612a8e565b80612b3281612d68565b8015612b4c5750600081815261019c602052604090205415155b612b685760405162461bcd60e51b8152600401610a4390615b4e565b600261015f541415612b8c5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5561019954612ba9906001600160a01b031634613c8e565b600082815261019c602052604081206002018054349290612bcb908490615ce2565b9091555050600082815261019c602052604090206001015482906001600160a01b0316336001600160a01b03167f0a7607b0b6665c6192e995edd0c765abfbeeb267a2ea3248d0b9125c3c1f420834604051612c2991815260200190565b60405180910390a45050600161015f55565b6000612c55600080516020615e498339815191528361213b565b80612c6e575061019b546001600160a01b038381169116145b80612c87575061019e546001600160a01b038381169116145b80612ca05750610199546001600160a01b038381169116145b80612cd057506001600160a01b038084166000908152609c602090815260408083209386168352929052205460ff165b9392505050565b612cef600080516020615e4983398151915233610796565b612d0b5760405162461bcd60e51b8152600401610a4390615b81565b61019b80546001600160a01b0319166001600160a01b0392909216919091179055565b612d46600080516020615e4983398151915233610796565b612d625760405162461bcd60e51b8152600401610a4390615b81565b61019455565b6000908152609960205260409020546001600160a01b0316151590565b60008060008085612d9581612d68565b8015612daf5750600081815261019c602052604090205415155b612dcb5760405162461bcd60e51b8152600401610a4390615b4e565b6001600160a01b038816612e215760405162461bcd60e51b815260206004820152601f60248201527f554e49515545545445532f434f4c4c4543545f544f5f5a45524f5f41444452006044820152606401610a43565b6000612e2c88610ff7565b90506000341180612e78575086158015612e575750886001600160a01b03168a6001600160a01b0316145b8015612e785750886001600160a01b031681602001516001600160a01b0316145b612ec45760405162461bcd60e51b815260206004820152601b60248201527f554e49515545545445532f5041594d454e545f524551554952454400000000006044820152606401610a43565b612ecf8a8a83613e22565b9550612edb8787615ce2565b94506127106101915486612eef9190615d1a565b612ef99190615cfa565b9250612f058334615d39565b935084841015612f575760405162461bcd60e51b815260206004820152601f60248201527f554e49515545545445532f4e4f545f454e4f5547485f5052494e434950414c006044820152606401610a43565b6000612f638786615d39565b905086861015612fc55760405162461bcd60e51b815260206004820152602760248201527f554e49515545545445532f554e45585045435445445f44455052454349415445604482015266445f505249434560c81b6064820152608401610a43565b348111156130255760405162461bcd60e51b815260206004820152602760248201527f554e49515545545445532f554e45585045435445445f4558434553535f434f4c6044820152661310551154905360ca1b6064820152608401610a43565b600089815261019c602052604081206002018054839290613047908490615ce2565b9091555050600089815261019c602090815260409091206003018790558201516130718c8b614031565b61308461307d8b61189d565b8c8c613408565b604080516001600160a01b038e81168252602082018b9052918101899052606081018890528b91808e1691908416907f6fdb2ff779ec4d72d0b11602f19b1511c6e1af12f133f56c677fbd3e0f252a059060800160405180910390a461019a546130f7906001600160a01b031686613c8e565b898b6001600160a01b03168d6001600160a01b03167f5d90ed55018a812d5146da57fe239c218fe08dfd6c476b2df791ecd2744d911484896040516131519291906001600160a01b03929092168252602082015260400190565b60405180910390a461316c6001600160a01b03821689613c8e565b81156131d85761019954613189906001600160a01b031683613c8e565b898b6001600160a01b03168d6001600160a01b03167f0a7607b0b6665c6192e995edd0c765abfbeeb267a2ea3248d0b9125c3c1f4208856040516131cf91815260200190565b60405180910390a45b50505050945094509450949050565b6000610b1b8261409f565b818160006001600160a01b03166101978383604051613212929190615749565b908152604051908190036020019020546001600160a01b031614156132495760405162461bcd60e51b8152600401610a4390615978565b838360016101978383604051613260929190615749565b9081526040519081900360200190206007015460ff16600281111561329557634e487b7160e01b600052602160045260246000fd5b146132b25760405162461bcd60e51b8152600401610a4390615a07565b600261019787876040516132c7929190615749565b908152604051908190036020019020600701805460ff1916600183600281111561330157634e487b7160e01b600052602160045260246000fd5b0217905550505050505050565b60008161331a81612d68565b80156133345750600081815261019c602052604090205415155b6133505760405162461bcd60e51b8152600401610a4390615b4e565b600061335b8461189d565b9050846001600160a01b031661337085610c09565b6001600160a01b031614806133ff575060405163e985e9c560e01b81526001600160a01b03808316600483015286166024820152309063e985e9c59060440160206040518083038186803b1580156133c757600080fd5b505afa1580156133db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ff9190615357565b95945050505050565b826001600160a01b031661341b8261189d565b6001600160a01b0316146134835760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610a43565b6001600160a01b0382166134e55760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a43565b6134f08383836140aa565b6134fb600082614031565b6001600160a01b0383166000908152609a60205260408120805460019290613524908490615d39565b90915550506001600160a01b0382166000908152609a60205260408120805460019290613552908490615ce2565b909155505060008181526099602052604080822080546001600160a01b0319166001600160a01b038681169182179092559151849391871691600080516020615e6983398151915291a4505050565b828260006001600160a01b031661019783836040516135c1929190615749565b908152604051908190036020019020546001600160a01b031614156135f85760405162461bcd60e51b8152600401610a4390615978565b84846000610197838360405161360f929190615749565b9081526040519081900360200190206007015460ff16600281111561364457634e487b7160e01b600052602160045260246000fd5b146136615760405162461bcd60e51b8152600401610a4390615acc565b868661019354610197838360405161367a929190615749565b90815260200160405180910390206003015410156136aa5760405162461bcd60e51b8152600401610a4390615a87565b866101978a8a6040516136be929190615749565b90815260200160405180910390206002018190555060016101978a8a6040516136e8929190615749565b908152604051908190036020019020600701805460ff1916600183600281111561372257634e487b7160e01b600052602160045260246000fd5b021790555061376689898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506140f692505050565b6101978989604051613779929190615749565b908152604051908190036020019020546001600160a01b03167f5bea5396cded2d11968478f123d99353c403ea9476cb3ef522fc1548d0cd61416137ba3390565b8b8b8b6040516137cd949392919061585b565b60405180910390a2505050505050505050565b6137ea828261213b565b61143657613802816001600160a01b03166014614217565b61380d836020614217565b60405160200161381e92919061578a565b60408051601f198184030181529082905262461bcd60e51b8252610a43916004016158dc565b61384e828261213b565b6114365760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556138863390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6138d4828261213b565b156114365760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60fb5460ff1661397a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a43565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60006139cf8261189d565b90506139dd816000846140aa565b6139e8600083614031565b6001600160a01b0381166000908152609a60205260408120805460019290613a11908490615d39565b909155505060008281526099602052604080822080546001600160a01b0319169055518391906001600160a01b03841690600080516020615e69833981519152908390a45050565b600054610100900460ff1680613a72575060005460ff16155b613a8e5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015613ab0576000805461ffff19166101011790555b613abd86868686866143f8565b8015613acf576000805461ff00191690555b505050505050565b600054610100900460ff1680613af0575060005460ff16155b613b0c5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015613b2e576000805461ffff19166101011790555b613b388787614490565b613b46878787878787614517565b8015613b58576000805461ff00191690555b50505050505050565b600054610100900460ff1680613b7a575060005460ff16155b613b965760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015613bb8576000805461ffff19166101011790555b613bc1826145d6565b8015611436576000805461ff00191690555050565b6114368282613844565b613bf8600080516020615e4983398151915233610796565b613c145760405162461bcd60e51b8152600401610a4390615b81565b61019a80546001600160a01b0319166001600160a01b0392909216919091179055565b613c4f600080516020615e4983398151915233610796565b613c6b5760405162461bcd60e51b8152600401610a4390615b81565b61019680546001600160a01b0319166001600160a01b0392909216919091179055565b80471015613cde5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610a43565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613d2b576040519150601f19603f3d011682016040523d82523d6000602084013e613d30565b606091505b505090508061112a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610a43565b60fb5460ff1615613ded5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a43565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586139a73390565b6000826001600160a01b0316846001600160a01b0316148015613e5a5750826001600160a01b031682602001516001600160a01b0316145b15613e6757506000612cd0565b816040015182606001511015613ead57612710610194548360400151613e8d9190615d1a565b613e979190615cfa565b8260400151613ea69190615ce2565b9050612cd0565b612710610194548360600151613ec39190615d1a565b613ecd9190615cfa565b8260600151613ea69190615ce2565b60006127106101915483613ef09190615d1a565b613efa9190615cfa565b61019b549091506001600160a01b0316613f138461189d565b6001600160a01b031614613f4057613f40613f2d8461189d565b61019b546001600160a01b031685613408565b61019b546001600160a01b031663113a68ed8185613f5e8587615ce2565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091526044820152606401600060405180830381600087803b158015613fac57600080fd5b505af1158015613fc0573d6000803e3d6000fd5b5050505050505050565b816001600160a01b0316613fdd8261189d565b6001600160a01b03161461143657611436613ff78261189d565b8383613408565b614009848484613408565b6140158484848461466d565b610b715760405162461bcd60e51b8152600401610a43906158ef565b6000818152609b6020526040902080546001600160a01b0319166001600160a01b03841690811790915581906140668261189d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610b1b8261477b565b61019b546001600160a01b0383811691161461112a57600081815261019c6020526040902060010180546001600160a01b0319166001600160a01b03841617905561112a8383836147a0565b6000610197826040516141099190615759565b908152602001604051809103902060040154111561412657611a61565b6001610197826040516141399190615759565b9081526040519081900360200190206007015460ff16600281111561416e57634e487b7160e01b600052602160045260246000fd5b146141c55760405162461bcd60e51b815260206004820152602160248201527f4449524543544f52592f5355424d495353494f4e5f4e4f545f415050524f56456044820152601160fa1b6064820152608401610a43565b60006141cf614812565b905080610197836040516141e39190615759565b90815260408051602092819003830190206004019290925560008381526101a3825291909120835161112a92850190614e21565b60606000614226836002615d1a565b614231906002615ce2565b6001600160401b0381111561425657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614280576020820181803683370190505b509050600360fc1b816000815181106142a957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106142e657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061430a846002615d1a565b614315906001615ce2565b90505b60018111156143a9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061435757634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061437b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936143a281615d7c565b9050614318565b508315612cd05760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a43565b600054610100900460ff1680614411575060005460ff16155b61442d5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561444f576000805461ffff19166101011790555b6101918690556101938590556101928490556101948390556101958290556144786000336119dd565b613abd600080516020615e49833981519152336119dd565b600054610100900460ff16806144a9575060005460ff16155b6144c55760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff161580156144e7576000805461ffff19166101011790555b6144ef614884565b6144f7614884565b61450183836148ef565b801561112a576000805461ff0019169055505050565b600054610100900460ff1680614530575060005460ff16155b61454c5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561456e576000805461ffff19166101011790555b61019880546001600160a01b038088166001600160a01b031992831617909255610199805487841690831617905561019a805486841690831617905561019b8054928516929091169190911790558015613b58576000805461ff001916905550505050505050565b600054610100900460ff16806145ef575060005460ff16155b61460b5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561462d576000805461ffff19166101011790555b61019680546001600160a01b0319166001600160a01b03841617905561465560006119dd3390565b613bc1600080516020615e49833981519152336119dd565b60006001600160a01b0384163b1561476f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906146b19033908990889088906004016157f9565b602060405180830381600087803b1580156146cb57600080fd5b505af19250505080156146fb575060408051601f3d908101601f191682019092526146f8918101906153cb565b60015b614755573d808015614729576040519150601f19603f3d011682016040523d82523d6000602084013e61472e565b606091505b50805161474d5760405162461bcd60e51b8152600401610a43906158ef565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050614773565b5060015b949350505050565b60006001600160e01b0319821663780e9d6360e01b1480610b1b5750610b1b82614984565b6147ab8383836149c4565b60fb5460ff161561112a5760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610a43565b600061482361019d80546001019055565b600061482f61019d5490565b6101998054600083815261019c602052604081206001810180546001600160a01b0319166001600160a01b039485161790558481556002810182905560030155905491925061487f911682614a81565b905090565b600054610100900460ff168061489d575060005460ff16155b6148b95760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff161580156148db576000805461ffff19166101011790555b8015611a61576000805461ff001916905550565b600054610100900460ff1680614908575060005460ff16155b6149245760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015614946576000805461ffff19166101011790555b8251614959906097906020860190614e21565b50815161496d906098906020850190614e21565b50801561112a576000805461ff0019169055505050565b60006001600160e01b031982166380ac58cd60e01b14806149b557506001600160e01b03198216635b5e139f60e01b145b80610b1b5750610b1b82614bae565b6001600160a01b038316614a1f57614a1a8160cb8054600083815260cc60205260408120829055600182018355919091527fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fb0155565b614a42565b816001600160a01b0316836001600160a01b031614614a4257614a428382614be3565b6001600160a01b038216614a5e57614a5981614c80565b61112a565b826001600160a01b0316826001600160a01b03161461112a5761112a8282614d59565b6001600160a01b038216614ad75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a43565b614ae081612d68565b15614b2d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a43565b614b39600083836140aa565b6001600160a01b0382166000908152609a60205260408120805460019290614b62908490615ce2565b909155505060008181526099602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020615e69833981519152908290a45050565b60006001600160e01b03198216637965db0b60e01b1480610b1b57506301ffc9a760e01b6001600160e01b0319831614610b1b565b60006001614bf084611abb565b614bfa9190615d39565b600083815260ca6020526040902054909150808214614c4d576001600160a01b038416600090815260c960209081526040808320858452825280832054848452818420819055835260ca90915290208190555b50600091825260ca602090815260408084208490556001600160a01b03909416835260c981528383209183525290812055565b60cb54600090614c9290600190615d39565b600083815260cc602052604081205460cb8054939450909284908110614cc857634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060cb8381548110614cf757634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260cc909152604080822084905585825281205560cb805480614d3d57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000614d6483611abb565b6001600160a01b03909316600090815260c960209081526040808320868452825280832085905593825260ca9052919091209190915550565b828054614da990615d93565b90600052602060002090601f016020900481019282614dcb5760008555614e11565b82601f10614de45782800160ff19823516178555614e11565b82800160010185558215614e11579182015b82811115614e11578235825591602001919060010190614df6565b50614e1d929150614f01565b5090565b828054614e2d90615d93565b90600052602060002090601f016020900481019282614e4f5760008555614e11565b82601f10614e6857805160ff1916838001178555614e11565b82800160010185558215614e11579182015b82811115614e11578251825591602001919060010190614e7a565b60405180610100016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006002811115614efc57634e487b7160e01b600052602160045260246000fd5b905290565b5b80821115614e1d5760008155600101614f02565b60006001600160401b0380841115614f3057614f30615df9565b604051601f8501601f19908116603f01168101908282118183101715614f5857614f58615df9565b81604052809350858152868686011115614f7157600080fd5b858560208301376000602087830101525050509392505050565b8035610b1e81615e0f565b60008083601f840112614fa7578182fd5b5081356001600160401b03811115614fbd578182fd5b6020830191508360208260051b8501011115614fd857600080fd5b9250929050565b60008083601f840112614ff0578182fd5b5081356001600160401b03811115615006578182fd5b602083019150836020828501011115614fd857600080fd5b600082601f83011261502e578081fd5b612cd083833560208501614f16565b60006020828403121561504e578081fd5b8135612cd081615e0f565b6000806040838503121561506b578081fd5b823561507681615e0f565b9150602083013561508681615e0f565b809150509250929050565b6000806000606084860312156150a5578081fd5b83356150b081615e0f565b925060208401356150c081615e0f565b929592945050506040919091013590565b600080600080608085870312156150e6578081fd5b84356150f181615e0f565b9350602085013561510181615e0f565b92506040850135915060608501356001600160401b03811115615122578182fd5b8501601f81018713615132578182fd5b61514187823560208401614f16565b91505092959194509250565b6000806040838503121561515f578182fd5b823561516a81615e0f565b9150602083013561508681615e24565b6000806040838503121561518c578182fd5b823561519781615e0f565b946020939093013593505050565b600080600080606085870312156151ba578384fd5b84356151c581615e0f565b93506020850135925060408501356001600160401b038111156151e6578283fd5b6151f287828801614fdf565b95989497509550505050565b60008060008060408587031215615213578384fd5b84356001600160401b0380821115615229578586fd5b61523588838901614f96565b9096509450602087013591508082111561524d578384fd5b506151f287828801614f96565b6000806000806000806000806080898b031215615275578586fd5b88356001600160401b038082111561528b578788fd5b6152978c838d01614f96565b909a50985060208b01359150808211156152af578788fd5b6152bb8c838d01614f96565b909850965060408b01359150808211156152d3578586fd5b6152df8c838d01614f96565b909650945060608b01359150808211156152f7578384fd5b506153048b828c01614f96565b999c989b5096995094979396929594505050565b6000806020838503121561532a578182fd5b82356001600160401b0381111561533f578283fd5b61534b85828601614f96565b90969095509350505050565b600060208284031215615368578081fd5b8151612cd081615e24565b600060208284031215615384578081fd5b5035919050565b6000806040838503121561539d578182fd5b82359150602083013561508681615e0f565b6000602082840312156153c0578081fd5b8135612cd081615e32565b6000602082840312156153dc578081fd5b8151612cd081615e32565b600080602083850312156153f9578182fd5b82356001600160401b0381111561540e578283fd5b61534b85828601614fdf565b60008060006040848603121561542e578081fd5b83356001600160401b03811115615443578182fd5b61544f86828701614fdf565b909790965060209590950135949350505050565b60008060008060608587031215615478578182fd5b84356001600160401b0381111561548d578283fd5b61549987828801614fdf565b90989097506020870135966040013595509350505050565b6000806000806000806000806000806000806101808d8f0312156154d3578586fd5b6001600160401b038d3511156154e7578586fd5b6154f48e8e358f0161501e565b9b506001600160401b0360208e0135111561550d578586fd5b61551d8e60208f01358f0161501e565b9a506001600160401b0360408e01351115615536578586fd5b6155468e60408f01358f0161501e565b995061555460608e01614f8b565b985061556260808e01614f8b565b975061557060a08e01614f8b565b965061557e60c08e01614f8b565b955060e08d013594506101008d013593506101208d013592506101408d013591506101608d013590509295989b509295989b509295989b565b6000806000604084860312156155cb578081fd5b8335925060208401356001600160401b038111156155e7578182fd5b6155f386828701614fdf565b9497909650939450505050565b600080600080600060808688031215615617578283fd5b8535945060208601356001600160401b03811115615633578384fd5b61563f88828901614fdf565b9699909850959660408101359660609091013595509350505050565b60008151808452615673816020860160208601615d50565b601f01601f19169290920160200192915050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b8054600090600181811c90808316806156cb57607f831692505b60208084108214156156eb57634e487b7160e01b86526022600452602486fd5b8180156156ff57600181146157105761573d565b60ff1986168952848901965061573d565b60008881526020902060005b868110156157355781548b82015290850190830161571c565b505084890196505b50505050505092915050565b6000828483379101908152919050565b6000825161576b818460208701615d50565b9190910192915050565b600061477361578483866156b1565b846156b1565b600076020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b825283516157bc816017850160208801615d50565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516157ed816028840160208801615d50565b01602801949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061582c9083018461565b565b9695505050505050565b6001600160a01b03841681526040602082018190526000906133ff9083018486615687565b6001600160a01b03851681526060602082018190526000906158809083018587615687565b905082604083015295945050505050565b6000604082526158a5604083018587615687565b9050826020830152949350505050565b6000606082526158c9606083018688615687565b6020830194909452506040015292915050565b600060208252612cd0602083018461565b565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601f908201527f4449524543544f52592f4e4f545f4f574e45525f4f525f474f5645524e4f5200604082015260600190565b6020808252601a908201527f5355424d495353494f4e532f444f45535f4e4f545f4558495354000000000000604082015260600190565b60208082526038908201527f4449524543544f52592f4e4f5f5355424d495353494f4e5f46554e4445445f4f604082015277525f415050524f5645445f464f525f554e4951554554544560401b606082015260800190565b60208082526018908201527714d550935254d4d253d394cbd393d517d054141493d5915160421b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526025908201527f5355424d495353494f4e532f4f555444415445445f4d455441444154415f56456040820152642929a4a7a760d91b606082015260800190565b6020808252601790820152765355424d495353494f4e532f4e4f545f50454e44494e4760481b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526019908201527815539254555155151154cbd113d154d7d393d517d1561254d5603a1b604082015260600190565b6020808252601a908201527f434f4d4d4f4e2f43414c4c45525f4e4f545f474f5645524e4f52000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006101008201905060018060a01b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160038110615c6357634e487b7160e01b600052602160045260246000fd5b8060e08401525092915050565b600086825260806020830152615c8a608083018688615687565b604083019490945250606001529392505050565b6000808335601e19843603018112615cb4578283fd5b8301803591506001600160401b03821115615ccd578283fd5b602001915036819003821315614fd857600080fd5b60008219821115615cf557615cf5615de3565b500190565b600082615d1557634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615d3457615d34615de3565b500290565b600082821015615d4b57615d4b615de3565b500390565b60005b83811015615d6b578181015183820152602001615d53565b83811115610b715750506000910152565b600081615d8b57615d8b615de3565b506000190190565b600181811c90821680615da757607f821691505b602082108114156110b957634e487b7160e01b600052602260045260246000fd5b6000600019821415615ddc57615ddc615de3565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611a6157600080fd5b8015158114611a6157600080fd5b6001600160e01b031981168114611a6157600080fdfe7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5375626d697373696f6e733a206e756d626572206f662068617368657320646fa2646970667358221220803f0575e90daef1399fd4b3efef7135c17ad37d7723e05b32f5b900b7ae039364736f6c63430008030033

Deployed Bytecode

0x6080604052600436106102df5760003560e01c80636a62b36211610186578063a6dfa18b116100d7578063ccc5749011610085578063ccc574901461092e578063d547741f14610950578063dc8e92ea14610970578063e65e1a1014610990578063e985e9c5146109a3578063ee499375146109c3578063ffe329d9146109e3576102df565b8063a6dfa18b1461085b578063aa066d571461087b578063b88d4fde1461089b578063bde1312d146108bb578063bf140572146108ce578063c7771a3f146108ee578063c87b56dd1461090e576102df565b806385535cc51161013457806385535cc51461075b57806391d148541461077b57806395d89b411461079b5780639b7bddb0146107b0578063a217fddf146107dd578063a22cb465146107f2578063a5ea11da14610812576102df565b80636a62b3621461069357806370a08231146106b3578063714b63dc146106d357806372491ead146106f3578063787dce3d146107065780637d36b348146107265780638456cb5914610746576102df565b80632c1da7f31161024057806342966c68116101ee57806342966c68146105bb5780634c11893c146105db5780634f6ccce7146105fb5780635c975abb1461061b5780636352211e1461063357806363ff2c26146106535780636605bfda14610673576102df565b80632c1da7f3146104e65780632f2ff15d146105065780632f745c591461052657806332f72e391461054657806336568abe146105665780633f4ba83a1461058657806342842e0e1461059b576102df565b806318160ddd1161029d57806318160ddd146103c8578063194aaa13146103e757806320cbbb0c146103fa5780632324eef01461045657806323b872dd14610476578063248a9ca31461049657806326a4e8d2146104c6576102df565b8062f1e4cb146102e457806301ffc9a7146102f957806304d7bbbb1461032e57806306fdde031461034e578063081812fc14610370578063095ea7b3146103a8575b600080fd5b6102f76102f236600461517a565b610a03565b005b34801561030557600080fd5b506103196103143660046153af565b610b10565b60405190151581526020015b60405180910390f35b34801561033a57600080fd5b506102f76103493660046155b7565b610b23565b34801561035a57600080fd5b50610363610b77565b60405161032591906158dc565b34801561037c57600080fd5b5061039061038b366004615373565b610c09565b6040516001600160a01b039091168152602001610325565b3480156103b457600080fd5b506102f76103c336600461517a565b610c91565b3480156103d457600080fd5b5060cb545b604051908152602001610325565b6102f76103f53660046151a5565b610cf9565b34801561040657600080fd5b5061041a610415366004615373565b610ff7565b6040516103259190815181526020808301516001600160a01b031690820152604080830151908201526060918201519181019190915260800190565b34801561046257600080fd5b506102f7610471366004615373565b6110bf565b34801561048257600080fd5b506102f7610491366004615091565b6110f9565b3480156104a257600080fd5b506103d96104b1366004615373565b60009081526065602052604090206001015490565b3480156104d257600080fd5b506102f76104e136600461503d565b61112f565b3480156104f257600080fd5b506102f76105013660046151fe565b611186565b34801561051257600080fd5b506102f761052136600461538b565b6112c5565b34801561053257600080fd5b506103d961054136600461517a565b6112ec565b34801561055257600080fd5b506102f7610561366004615373565b611382565b34801561057257600080fd5b506102f761058136600461538b565b6113bc565b34801561059257600080fd5b506102f761143a565b3480156105a757600080fd5b506102f76105b6366004615091565b611478565b3480156105c757600080fd5b506102f76105d6366004615373565b611493565b3480156105e757600080fd5b506102f76105f6366004615463565b611570565b34801561060757600080fd5b506103d9610616366004615373565b6117fc565b34801561062757600080fd5b5060fb5460ff16610319565b34801561063f57600080fd5b5061039061064e366004615373565b61189d565b34801561065f57600080fd5b506102f761066e3660046154b1565b611914565b34801561067f57600080fd5b506102f761068e36600461503d565b611a1b565b34801561069f57600080fd5b506102f76106ae36600461503d565b611a64565b3480156106bf57600080fd5b506103d96106ce36600461503d565b611abb565b3480156106df57600080fd5b506102f76106ee3660046153e7565b611b42565b6102f761070136600461525a565b611d91565b34801561071257600080fd5b506102f7610721366004615373565b611ffa565b34801561073257600080fd5b506102f761074136600461541a565b612034565b34801561075257600080fd5b506102f76120a8565b34801561076757600080fd5b506102f761077636600461503d565b6120e4565b34801561078757600080fd5b5061031961079636600461538b565b61213b565b3480156107a757600080fd5b50610363612166565b3480156107bc57600080fd5b506107d06107cb3660046153e7565b612175565b6040516103259190615bef565b3480156107e957600080fd5b506103d9600081565b3480156107fe57600080fd5b506102f761080d36600461514d565b6122a6565b34801561081e57600080fd5b506101915461019254610193546101945461019554604080519586526020860194909452928401919091526060830152608082015260a001610325565b34801561086757600080fd5b506102f7610876366004615373565b61231e565b34801561088757600080fd5b506102f7610896366004615373565b61245d565b3480156108a757600080fd5b506102f76108b63660046150d1565b61258a565b6102f76108c9366004615600565b6125bc565b3480156108da57600080fd5b506102f76108e9366004615373565b61288b565b3480156108fa57600080fd5b50610363610909366004615373565b6128c5565b34801561091a57600080fd5b50610363610929366004615373565b612968565b34801561093a57600080fd5b506103d9600080516020615e4983398151915281565b34801561095c57600080fd5b506102f761096b36600461538b565b612a31565b34801561097c57600080fd5b506102f761098b366004615318565b612a57565b6102f761099e366004615373565b612b28565b3480156109af57600080fd5b506103196109be366004615059565b612c3b565b3480156109cf57600080fd5b506102f76109de36600461503d565b612cd7565b3480156109ef57600080fd5b506102f76109fe366004615373565b612d2e565b80610a0d81612d68565b8015610a275750600081815261019c602052604090205415155b610a4c5760405162461bcd60e51b8152600401610a4390615b4e565b60405180910390fd5b600261015f541415610a705760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55600082815261019f602052604081208054610a9090615d93565b905011610af45760405162461bcd60e51b815260206004820152602c60248201527f4449524543544f52592f4e4f5f5355424d495353494f4e5f46554e4445445f4660448201526b4f525f554e4951554554544560a01b6064820152608401610a43565b610b013384846000612d85565b5050600161015f555050505050565b6000610b1b826131e7565b90505b919050565b610b3b600080516020615e4983398151915233610796565b610b575760405162461bcd60e51b8152600401610a4390615b81565b60008381526101a360205260409020610b71908383614d9d565b50505050565b606060978054610b8690615d93565b80601f0160208091040260200160405190810160405280929190818152602001828054610bb290615d93565b8015610bff5780601f10610bd457610100808354040283529160200191610bff565b820191906000526020600020905b815481529060010190602001808311610be257829003601f168201915b5050505050905090565b6000610c1482612d68565b610c755760405162461bcd60e51b815260206004820152602c60248201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860448201526b34b9ba32b73a103a37b5b2b760a11b6064820152608401610a43565b506000908152609b60205260409020546001600160a01b031690565b60405162461bcd60e51b815260206004820152603760248201527f4469726563746f72793a20617070726f7665206e6f7420737570706f72746564604482015276206f6e20756e69717565747465207472616e736665727360481b6064820152608401610a43565b82610d0381612d68565b8015610d1d5750600081815261019c602052604090205415155b610d395760405162461bcd60e51b8152600401610a4390615b4e565b828260006001600160a01b03166101978383604051610d59929190615749565b908152604051908190036020019020546001600160a01b03161415610d905760405162461bcd60e51b8152600401610a4390615978565b848460016101978383604051610da7929190615749565b9081526040519081900360200190206007015460ff166002811115610ddc57634e487b7160e01b600052602160045260246000fd5b14610df95760405162461bcd60e51b8152600401610a4390615a07565b8686610193546101978383604051610e12929190615749565b9081526020016040518091039020600301541015610e425760405162461bcd60e51b8152600401610a4390615a87565b600261015f541415610e665760405162461bcd60e51b8152600401610a4390615bb8565b600261015f556000610e788a8a612175565b90508a816080015114610ee05760405162461bcd60e51b815260206004820152602a60248201527f4449524543544f52592f494e56414c49445f5355424d495353494f4e5f464f526044820152695f554e4951554554544560b01b6064820152608401610a43565b60008b815261019f60205260409020610efa908b8b614d9d565b50610f058a8a6131f2565b6000610f17338e8e8560200151612d85565b50506101a054845160408087015190516340c10f1960e01b81526001600160a01b03928316600482015260248101919091529294501691506340c10f1990604401600060405180830381600087803b158015610f7257600080fd5b505af1158015610f86573d6000803e3d6000fd5b505050508b8d6001600160a01b0316610f9c3390565b6001600160a01b03167f1e0392d89fc63a5033fa3b8ccb7befb7fd00ac557728fa9518a257c0fb6e08f88e8e8634604051610fda94939291906158b5565b60405180910390a45050600161015f555050505050505050505050565b61102b60405180608001604052806000815260200160006001600160a01b0316815260200160008152602001600081525090565b8161103581612d68565b801561104f5750600081815261019c602052604090205415155b61106b5760405162461bcd60e51b8152600401610a4390615b4e565b600083815261019c602090815260409182902082516080810184528154815260018201546001600160a01b031692810192909252600281015492820192909252600390910154606082015291505b50919050565b6110d7600080516020615e4983398151915233610796565b6110f35760405162461bcd60e51b8152600401610a4390615b81565b61019255565b611103338261330e565b61111f5760405162461bcd60e51b8152600401610a4390615afd565b61112a838383613408565b505050565b611147600080516020615e4983398151915233610796565b6111635760405162461bcd60e51b8152600401610a4390615b81565b61019880546001600160a01b0319166001600160a01b0392909216919091179055565b61119e600080516020615e4983398151915233610796565b6111ba5760405162461bcd60e51b8152600401610a4390615b81565b600261015f5414156111de5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5582811461123c5760405162461bcd60e51b81526020600482015260326024820152600080516020615e89833981519152604482015271206e6f74206d61746368207265776172647360701b6064820152608401610a43565b60005b838110156112b8576112a885858381811061126a57634e487b7160e01b600052603260045260246000fd5b905060200281019061127c9190615c9e565b85858581811061129c57634e487b7160e01b600052603260045260246000fd5b905060200201356135a1565b6112b181615dc8565b905061123f565b5050600161015f55505050565b6000828152606560205260409020600101546112e281335b6137e0565b61112a8383613844565b60006112f783611abb565b82106113595760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610a43565b506001600160a01b0391909116600090815260c960209081526040808320938352929052205490565b61139a600080516020615e4983398151915233610796565b6113b65760405162461bcd60e51b8152600401610a4390615b81565b61019555565b6001600160a01b038116331461142c5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b6064820152608401610a43565b61143682826138ca565b5050565b611452600080516020615e4983398151915233610796565b61146e5760405162461bcd60e51b8152600401610a4390615b81565b611476613931565b565b61112a8383836040518060200160405280600081525061258a565b6114ab600080516020615e4983398151915233610796565b6114c75760405162461bcd60e51b8152600401610a4390615b81565b600081815261019c602090815260409182902082516080810184528154815260018201546001600160a01b03908116938201849052600283015494820194909452600390910154606082015261019954909216146115675760405162461bcd60e51b815260206004820152601d60248201527f554e49515545545445532f4e4f545f4f574e45445f42595f5641554c540000006044820152606401610a43565b611436826139c4565b838360006001600160a01b03166101978383604051611590929190615749565b908152604051908190036020019020546001600160a01b031614156115c75760405162461bcd60e51b8152600401610a4390615978565b8585600061019783836040516115de929190615749565b9081526040519081900360200190206007015460ff16600281111561161357634e487b7160e01b600052602160045260246000fd5b146116305760405162461bcd60e51b8152600401610a4390615acc565b8787610193546101978383604051611649929190615749565b90815260200160405180910390206003015410156116795760405162461bcd60e51b8152600401610a4390615a87565b600261015f54141561169d5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55336001600160a01b03166101978b8b6040516116c0929190615749565b908152604051908190036020019020546001600160a01b031614806116f857506116f8600080516020615e4983398151915233610796565b61174f5760405162461bcd60e51b815260206004820152602260248201527f5355424d495353494f4e532f4e4f545f415554484f525f4f525f474f5645524e60448201526127a960f11b6064820152608401610a43565b876101978b8b604051611763929190615749565b908152602001604051809103902060040181905550866101978b8b60405161178c929190615749565b908152604051908190036020019020600101556117a63390565b6001600160a01b03167f5d65f7cb575787e992f9f65bcde54aff4e5796220138384beb8d746b439a4aad8b8b8a6040516117e293929190615891565b60405180910390a25050600161015f555050505050505050565b600061180760cb5490565b821061186a5760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610a43565b60cb828154811061188b57634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050919050565b6000818152609960205260408120546001600160a01b031680610b1b5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460448201526832b73a103a37b5b2b760b91b6064820152608401610a43565b600054610100900460ff168061192d575060005460ff16155b6119495760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561196b576000805461ffff19166101011790555b6119788686868686613a59565b6119868d8d8c8c8c8c613ad7565b61198f88613b61565b6101a080546001600160a01b03808d166001600160a01b0319928316179092556101a18054928c16929091169190911790558a516119d5906101a29060208e0190614e21565b506119e26000335b613bd6565b6119fa600080516020615e49833981519152336119dd565b8015611a0c576000805461ff00191690555b50505050505050505050505050565b611a33600080516020615e4983398151915233610796565b611a4f5760405162461bcd60e51b8152600401610a4390615b81565b611a5881613be0565b611a6181613c37565b50565b611a7c600080516020615e4983398151915233610796565b611a985760405162461bcd60e51b8152600401610a4390615b81565b61019e80546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160a01b038216611b265760405162461bcd60e51b815260206004820152602a60248201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604482015269726f206164647265737360b01b6064820152608401610a43565b506001600160a01b03166000908152609a602052604090205490565b611b5a600080516020615e4983398151915233610796565b611b765760405162461bcd60e51b8152600401610a4390615b81565b818160006001600160a01b03166101978383604051611b96929190615749565b908152604051908190036020019020546001600160a01b03161415611bcd5760405162461bcd60e51b8152600401610a4390615978565b838360006101978383604051611be4929190615749565b9081526040519081900360200190206007015460ff166002811115611c1957634e487b7160e01b600052602160045260246000fd5b14611c365760405162461bcd60e51b8152600401610a4390615acc565b600261015f541415611c5a5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5560405160009061019790611c779089908990615749565b908152604051908190036020018120546001600160a01b0316915060009061019790611ca6908a908a90615749565b90815260200160405180910390206006015490506101978888604051611ccd929190615749565b90815260405190819003602001902080546001600160a01b0319168155600060018201819055600282018190556003820181905560048201819055600582018190556006820155600701805460ff191690558015611d3c5761019654611d3c906001600160a01b031682613c8e565b6001600160a01b0382167fd0ebb0eea23bb48fde00a512003aa8e1a997969ece3a7bd7bd867b0b4fe2e698338a8a604051611d7993929190615836565b60405180910390a25050600161015f55505050505050565b600261015f541415611db55760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55868514611e1e5760405162461bcd60e51b815260206004820152603b6024820152600080516020615e8983398151915260448201527f206e6f74206d61746368206d6574616461746156657273696f6e7300000000006064820152608401610a43565b868314611e775760405162461bcd60e51b81526020600482015260336024820152600080516020615e89833981519152604482015272206e6f74206d6174636820746f6b656e49647360681b6064820152608401610a43565b868114611ece5760405162461bcd60e51b81526020600482015260316024820152600080516020615e89833981519152604482015270206e6f74206d617463682076616c75657360781b6064820152608401610a43565b60005b87811015611fe9573063bde1312d868684818110611eff57634e487b7160e01b600052603260045260246000fd5b905060200201358b8b85818110611f2657634e487b7160e01b600052603260045260246000fd5b9050602002810190611f389190615c9e565b8b8b87818110611f5857634e487b7160e01b600052603260045260246000fd5b90506020020135888888818110611f7f57634e487b7160e01b600052603260045260246000fd5b905060200201356040518663ffffffff1660e01b8152600401611fa6959493929190615c70565b600060405180830381600087803b158015611fc057600080fd5b505af1158015611fd4573d6000803e3d6000fd5b5050505080611fe290615dc8565b9050611ed1565b5050600161015f5550505050505050565b612012600080516020615e4983398151915233610796565b61202e5760405162461bcd60e51b8152600401610a4390615b81565b61019155565b61204c600080516020615e4983398151915233610796565b6120685760405162461bcd60e51b8152600401610a4390615b81565b600261015f54141561208c5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5561209d8383836135a1565b5050600161015f5550565b6120c0600080516020615e4983398151915233610796565b6120dc5760405162461bcd60e51b8152600401610a4390615b81565b611476613da7565b6120fc600080516020615e4983398151915233610796565b6121185760405162461bcd60e51b8152600401610a4390615b81565b61019980546001600160a01b0319166001600160a01b0392909216919091179055565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060988054610b8690615d93565b61217d614e95565b828260006001600160a01b0316610197838360405161219d929190615749565b908152604051908190036020019020546001600160a01b031614156121d45760405162461bcd60e51b8152600401610a4390615978565b61019785856040516121e7929190615749565b9081526040805191829003602090810183206101008401835280546001600160a01b03168452600181015491840191909152600280820154928401929092526003810154606084015260048101546080840152600581015460a0840152600681015460c08401526007810154909160e084019160ff169081111561227b57634e487b7160e01b600052602160045260246000fd5b600281111561229a57634e487b7160e01b600052602160045260246000fd5b90525095945050505050565b60405162461bcd60e51b815260206004820152604160248201527f4469726563746f72793a20736574417070726f76616c466f72416c6c206e6f7460448201527f20737570706f72746564206f6e20756e69717565747465207472616e736665726064820152607360f81b608482015260a401610a43565b8061232881612d68565b80156123425750600081815261019c602052604090205415155b61235e5760405162461bcd60e51b8152600401610a4390615b4e565b600261015f5414156123825760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55600082815261019f6020526040812080546123a290615d93565b905011806123c9575060008281526101a36020526040812080546123c590615d93565b9050115b6123e55760405162461bcd60e51b8152600401610a43906159af565b60006123f083610ff7565b60208101519091506001600160a01b03163314806124215750612421600080516020615e4983398151915233610796565b61243d5760405162461bcd60e51b8152600401610a4390615941565b61209d8160200151846124586124503390565b600086613e22565b613edc565b8061246781612d68565b80156124815750600081815261019c602052604090205415155b61249d5760405162461bcd60e51b8152600401610a4390615b4e565b600261015f5414156124c15760405162461bcd60e51b8152600401610a4390615bb8565b600261015f55600082815261019f6020526040812080546124e190615d93565b90501180612508575060008281526101a360205260408120805461250490615d93565b9050115b6125245760405162461bcd60e51b8152600401610a43906159af565b600061252f83610ff7565b60208101519091506001600160a01b03163314806125605750612560600080516020615e4983398151915233610796565b61257c5760405162461bcd60e51b8152600401610a4390615941565b61209d816020015184613fca565b612594338361330e565b6125b05760405162461bcd60e51b8152600401610a4390615afd565b610b7184848484613ffe565b60006001600160a01b031661019785856040516125da929190615749565b908152604051908190036020019020546001600160a01b0316146126405760405162461bcd60e51b815260206004820152601b60248201527f5355424d495353494f4e532f414c52454144595f4352454154454400000000006044820152606401610a43565b61019554341461269d5760405162461bcd60e51b815260206004820152602260248201527f5355424d495353494f4e532f45584143545f4445504f5349545f524551554952604482015261115160f21b6064820152608401610a43565b610193548210156127015760405162461bcd60e51b815260206004820152602860248201527f5355424d495353494f4e532f554e535550504f525445445f4d455441444154416044820152672fab22a929a4a7a760c11b6064820152608401610a43565b336101978585604051612715929190615749565b90815260405190819003602001812080546001600160a01b03939093166001600160a01b0319909316929092179091558590610197906127589087908790615749565b908152602001604051809103902060040181905550816101978585604051612781929190615749565b9081526020016040518091039020600301819055508061019785856040516127aa929190615749565b9081526020016040518091039020600101819055503461019785856040516127d3929190615749565b908152602001604051809103902060060181905550600061019785856040516127fd929190615749565b908152604051908190036020019020600701805460ff1916600183600281111561283757634e487b7160e01b600052602160045260246000fd5b021790555084336001600160a01b03167f4d66d41804994e0b3749bf214861b72fe46575c5645646e020570c8403e7a1d68686853460405161287c94939291906158b5565b60405180910390a35050505050565b6128a3600080516020615e4983398151915233610796565b6128bf5760405162461bcd60e51b8152600401610a4390615b81565b61019355565b600081815261019f602052604090208054606091906128e390615d93565b80601f016020809104026020016040519081016040528092919081815260200182805461290f90615d93565b801561295c5780601f106129315761010080835404028352916020019161295c565b820191906000526020600020905b81548152906001019060200180831161293f57829003601f168201915b50505050509050919050565b60608161297481612d68565b801561298e5750600081815261019c602052604090205415155b6129aa5760405162461bcd60e51b8152600401610a4390615b4e565b600083815261019f6020526040902080546129c490615d93565b159050612a09576101a261019f60008581526020019081526020016000206040516020016129f3929190615775565b60405160208183030381529060405291506110b9565b6101a26101a360008581526020019081526020016000206040516020016129f3929190615775565b600082815260656020526040902060010154612a4d81336112dd565b61112a83836138ca565b612a6f600080516020615e4983398151915233610796565b612a8b5760405162461bcd60e51b8152600401610a4390615b81565b60005b8181101561112a576000838383818110612ab857634e487b7160e01b600052603260045260246000fd5b604051630852cd8d60e31b81526020909102929092013560048301819052925030916342966c689150602401600060405180830381600087803b158015612afe57600080fd5b505af1158015612b12573d6000803e3d6000fd5b505050505080612b2190615dc8565b9050612a8e565b80612b3281612d68565b8015612b4c5750600081815261019c602052604090205415155b612b685760405162461bcd60e51b8152600401610a4390615b4e565b600261015f541415612b8c5760405162461bcd60e51b8152600401610a4390615bb8565b600261015f5561019954612ba9906001600160a01b031634613c8e565b600082815261019c602052604081206002018054349290612bcb908490615ce2565b9091555050600082815261019c602052604090206001015482906001600160a01b0316336001600160a01b03167f0a7607b0b6665c6192e995edd0c765abfbeeb267a2ea3248d0b9125c3c1f420834604051612c2991815260200190565b60405180910390a45050600161015f55565b6000612c55600080516020615e498339815191528361213b565b80612c6e575061019b546001600160a01b038381169116145b80612c87575061019e546001600160a01b038381169116145b80612ca05750610199546001600160a01b038381169116145b80612cd057506001600160a01b038084166000908152609c602090815260408083209386168352929052205460ff165b9392505050565b612cef600080516020615e4983398151915233610796565b612d0b5760405162461bcd60e51b8152600401610a4390615b81565b61019b80546001600160a01b0319166001600160a01b0392909216919091179055565b612d46600080516020615e4983398151915233610796565b612d625760405162461bcd60e51b8152600401610a4390615b81565b61019455565b6000908152609960205260409020546001600160a01b0316151590565b60008060008085612d9581612d68565b8015612daf5750600081815261019c602052604090205415155b612dcb5760405162461bcd60e51b8152600401610a4390615b4e565b6001600160a01b038816612e215760405162461bcd60e51b815260206004820152601f60248201527f554e49515545545445532f434f4c4c4543545f544f5f5a45524f5f41444452006044820152606401610a43565b6000612e2c88610ff7565b90506000341180612e78575086158015612e575750886001600160a01b03168a6001600160a01b0316145b8015612e785750886001600160a01b031681602001516001600160a01b0316145b612ec45760405162461bcd60e51b815260206004820152601b60248201527f554e49515545545445532f5041594d454e545f524551554952454400000000006044820152606401610a43565b612ecf8a8a83613e22565b9550612edb8787615ce2565b94506127106101915486612eef9190615d1a565b612ef99190615cfa565b9250612f058334615d39565b935084841015612f575760405162461bcd60e51b815260206004820152601f60248201527f554e49515545545445532f4e4f545f454e4f5547485f5052494e434950414c006044820152606401610a43565b6000612f638786615d39565b905086861015612fc55760405162461bcd60e51b815260206004820152602760248201527f554e49515545545445532f554e45585045435445445f44455052454349415445604482015266445f505249434560c81b6064820152608401610a43565b348111156130255760405162461bcd60e51b815260206004820152602760248201527f554e49515545545445532f554e45585045435445445f4558434553535f434f4c6044820152661310551154905360ca1b6064820152608401610a43565b600089815261019c602052604081206002018054839290613047908490615ce2565b9091555050600089815261019c602090815260409091206003018790558201516130718c8b614031565b61308461307d8b61189d565b8c8c613408565b604080516001600160a01b038e81168252602082018b9052918101899052606081018890528b91808e1691908416907f6fdb2ff779ec4d72d0b11602f19b1511c6e1af12f133f56c677fbd3e0f252a059060800160405180910390a461019a546130f7906001600160a01b031686613c8e565b898b6001600160a01b03168d6001600160a01b03167f5d90ed55018a812d5146da57fe239c218fe08dfd6c476b2df791ecd2744d911484896040516131519291906001600160a01b03929092168252602082015260400190565b60405180910390a461316c6001600160a01b03821689613c8e565b81156131d85761019954613189906001600160a01b031683613c8e565b898b6001600160a01b03168d6001600160a01b03167f0a7607b0b6665c6192e995edd0c765abfbeeb267a2ea3248d0b9125c3c1f4208856040516131cf91815260200190565b60405180910390a45b50505050945094509450949050565b6000610b1b8261409f565b818160006001600160a01b03166101978383604051613212929190615749565b908152604051908190036020019020546001600160a01b031614156132495760405162461bcd60e51b8152600401610a4390615978565b838360016101978383604051613260929190615749565b9081526040519081900360200190206007015460ff16600281111561329557634e487b7160e01b600052602160045260246000fd5b146132b25760405162461bcd60e51b8152600401610a4390615a07565b600261019787876040516132c7929190615749565b908152604051908190036020019020600701805460ff1916600183600281111561330157634e487b7160e01b600052602160045260246000fd5b0217905550505050505050565b60008161331a81612d68565b80156133345750600081815261019c602052604090205415155b6133505760405162461bcd60e51b8152600401610a4390615b4e565b600061335b8461189d565b9050846001600160a01b031661337085610c09565b6001600160a01b031614806133ff575060405163e985e9c560e01b81526001600160a01b03808316600483015286166024820152309063e985e9c59060440160206040518083038186803b1580156133c757600080fd5b505afa1580156133db573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133ff9190615357565b95945050505050565b826001600160a01b031661341b8261189d565b6001600160a01b0316146134835760405162461bcd60e51b815260206004820152602960248201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960448201526839903737ba1037bbb760b91b6064820152608401610a43565b6001600160a01b0382166134e55760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610a43565b6134f08383836140aa565b6134fb600082614031565b6001600160a01b0383166000908152609a60205260408120805460019290613524908490615d39565b90915550506001600160a01b0382166000908152609a60205260408120805460019290613552908490615ce2565b909155505060008181526099602052604080822080546001600160a01b0319166001600160a01b038681169182179092559151849391871691600080516020615e6983398151915291a4505050565b828260006001600160a01b031661019783836040516135c1929190615749565b908152604051908190036020019020546001600160a01b031614156135f85760405162461bcd60e51b8152600401610a4390615978565b84846000610197838360405161360f929190615749565b9081526040519081900360200190206007015460ff16600281111561364457634e487b7160e01b600052602160045260246000fd5b146136615760405162461bcd60e51b8152600401610a4390615acc565b868661019354610197838360405161367a929190615749565b90815260200160405180910390206003015410156136aa5760405162461bcd60e51b8152600401610a4390615a87565b866101978a8a6040516136be929190615749565b90815260200160405180910390206002018190555060016101978a8a6040516136e8929190615749565b908152604051908190036020019020600701805460ff1916600183600281111561372257634e487b7160e01b600052602160045260246000fd5b021790555061376689898080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152506140f692505050565b6101978989604051613779929190615749565b908152604051908190036020019020546001600160a01b03167f5bea5396cded2d11968478f123d99353c403ea9476cb3ef522fc1548d0cd61416137ba3390565b8b8b8b6040516137cd949392919061585b565b60405180910390a2505050505050505050565b6137ea828261213b565b61143657613802816001600160a01b03166014614217565b61380d836020614217565b60405160200161381e92919061578a565b60408051601f198184030181529082905262461bcd60e51b8252610a43916004016158dc565b61384e828261213b565b6114365760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556138863390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6138d4828261213b565b156114365760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60fb5460ff1661397a5760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610a43565b60fb805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b60006139cf8261189d565b90506139dd816000846140aa565b6139e8600083614031565b6001600160a01b0381166000908152609a60205260408120805460019290613a11908490615d39565b909155505060008281526099602052604080822080546001600160a01b0319169055518391906001600160a01b03841690600080516020615e69833981519152908390a45050565b600054610100900460ff1680613a72575060005460ff16155b613a8e5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015613ab0576000805461ffff19166101011790555b613abd86868686866143f8565b8015613acf576000805461ff00191690555b505050505050565b600054610100900460ff1680613af0575060005460ff16155b613b0c5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015613b2e576000805461ffff19166101011790555b613b388787614490565b613b46878787878787614517565b8015613b58576000805461ff00191690555b50505050505050565b600054610100900460ff1680613b7a575060005460ff16155b613b965760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015613bb8576000805461ffff19166101011790555b613bc1826145d6565b8015611436576000805461ff00191690555050565b6114368282613844565b613bf8600080516020615e4983398151915233610796565b613c145760405162461bcd60e51b8152600401610a4390615b81565b61019a80546001600160a01b0319166001600160a01b0392909216919091179055565b613c4f600080516020615e4983398151915233610796565b613c6b5760405162461bcd60e51b8152600401610a4390615b81565b61019680546001600160a01b0319166001600160a01b0392909216919091179055565b80471015613cde5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610a43565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114613d2b576040519150601f19603f3d011682016040523d82523d6000602084013e613d30565b606091505b505090508061112a5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610a43565b60fb5460ff1615613ded5760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610a43565b60fb805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586139a73390565b6000826001600160a01b0316846001600160a01b0316148015613e5a5750826001600160a01b031682602001516001600160a01b0316145b15613e6757506000612cd0565b816040015182606001511015613ead57612710610194548360400151613e8d9190615d1a565b613e979190615cfa565b8260400151613ea69190615ce2565b9050612cd0565b612710610194548360600151613ec39190615d1a565b613ecd9190615cfa565b8260600151613ea69190615ce2565b60006127106101915483613ef09190615d1a565b613efa9190615cfa565b61019b549091506001600160a01b0316613f138461189d565b6001600160a01b031614613f4057613f40613f2d8461189d565b61019b546001600160a01b031685613408565b61019b546001600160a01b031663113a68ed8185613f5e8587615ce2565b6040516001600160e01b031960e086901b1681526001600160a01b03909316600484015260248301919091526044820152606401600060405180830381600087803b158015613fac57600080fd5b505af1158015613fc0573d6000803e3d6000fd5b5050505050505050565b816001600160a01b0316613fdd8261189d565b6001600160a01b03161461143657611436613ff78261189d565b8383613408565b614009848484613408565b6140158484848461466d565b610b715760405162461bcd60e51b8152600401610a43906158ef565b6000818152609b6020526040902080546001600160a01b0319166001600160a01b03841690811790915581906140668261189d565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610b1b8261477b565b61019b546001600160a01b0383811691161461112a57600081815261019c6020526040902060010180546001600160a01b0319166001600160a01b03841617905561112a8383836147a0565b6000610197826040516141099190615759565b908152602001604051809103902060040154111561412657611a61565b6001610197826040516141399190615759565b9081526040519081900360200190206007015460ff16600281111561416e57634e487b7160e01b600052602160045260246000fd5b146141c55760405162461bcd60e51b815260206004820152602160248201527f4449524543544f52592f5355424d495353494f4e5f4e4f545f415050524f56456044820152601160fa1b6064820152608401610a43565b60006141cf614812565b905080610197836040516141e39190615759565b90815260408051602092819003830190206004019290925560008381526101a3825291909120835161112a92850190614e21565b60606000614226836002615d1a565b614231906002615ce2565b6001600160401b0381111561425657634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015614280576020820181803683370190505b509050600360fc1b816000815181106142a957634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600f60fb1b816001815181106142e657634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350600061430a846002615d1a565b614315906001615ce2565b90505b60018111156143a9576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061435757634e487b7160e01b600052603260045260246000fd5b1a60f81b82828151811061437b57634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a90535060049490941c936143a281615d7c565b9050614318565b508315612cd05760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610a43565b600054610100900460ff1680614411575060005460ff16155b61442d5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561444f576000805461ffff19166101011790555b6101918690556101938590556101928490556101948390556101958290556144786000336119dd565b613abd600080516020615e49833981519152336119dd565b600054610100900460ff16806144a9575060005460ff16155b6144c55760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff161580156144e7576000805461ffff19166101011790555b6144ef614884565b6144f7614884565b61450183836148ef565b801561112a576000805461ff0019169055505050565b600054610100900460ff1680614530575060005460ff16155b61454c5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561456e576000805461ffff19166101011790555b61019880546001600160a01b038088166001600160a01b031992831617909255610199805487841690831617905561019a805486841690831617905561019b8054928516929091169190911790558015613b58576000805461ff001916905550505050505050565b600054610100900460ff16806145ef575060005460ff16155b61460b5760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff1615801561462d576000805461ffff19166101011790555b61019680546001600160a01b0319166001600160a01b03841617905561465560006119dd3390565b613bc1600080516020615e49833981519152336119dd565b60006001600160a01b0384163b1561476f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a02906146b19033908990889088906004016157f9565b602060405180830381600087803b1580156146cb57600080fd5b505af19250505080156146fb575060408051601f3d908101601f191682019092526146f8918101906153cb565b60015b614755573d808015614729576040519150601f19603f3d011682016040523d82523d6000602084013e61472e565b606091505b50805161474d5760405162461bcd60e51b8152600401610a43906158ef565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050614773565b5060015b949350505050565b60006001600160e01b0319821663780e9d6360e01b1480610b1b5750610b1b82614984565b6147ab8383836149c4565b60fb5460ff161561112a5760405162461bcd60e51b815260206004820152602b60248201527f4552433732315061757361626c653a20746f6b656e207472616e73666572207760448201526a1a1a5b19481c185d5cd95960aa1b6064820152608401610a43565b600061482361019d80546001019055565b600061482f61019d5490565b6101998054600083815261019c602052604081206001810180546001600160a01b0319166001600160a01b039485161790558481556002810182905560030155905491925061487f911682614a81565b905090565b600054610100900460ff168061489d575060005460ff16155b6148b95760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff161580156148db576000805461ffff19166101011790555b8015611a61576000805461ff001916905550565b600054610100900460ff1680614908575060005460ff16155b6149245760405162461bcd60e51b8152600401610a4390615a39565b600054610100900460ff16158015614946576000805461ffff19166101011790555b8251614959906097906020860190614e21565b50815161496d906098906020850190614e21565b50801561112a576000805461ff0019169055505050565b60006001600160e01b031982166380ac58cd60e01b14806149b557506001600160e01b03198216635b5e139f60e01b145b80610b1b5750610b1b82614bae565b6001600160a01b038316614a1f57614a1a8160cb8054600083815260cc60205260408120829055600182018355919091527fa7ce836d032b2bf62b7e2097a8e0a6d8aeb35405ad15271e96d3b0188a1d06fb0155565b614a42565b816001600160a01b0316836001600160a01b031614614a4257614a428382614be3565b6001600160a01b038216614a5e57614a5981614c80565b61112a565b826001600160a01b0316826001600160a01b03161461112a5761112a8282614d59565b6001600160a01b038216614ad75760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610a43565b614ae081612d68565b15614b2d5760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610a43565b614b39600083836140aa565b6001600160a01b0382166000908152609a60205260408120805460019290614b62908490615ce2565b909155505060008181526099602052604080822080546001600160a01b0319166001600160a01b0386169081179091559051839290600080516020615e69833981519152908290a45050565b60006001600160e01b03198216637965db0b60e01b1480610b1b57506301ffc9a760e01b6001600160e01b0319831614610b1b565b60006001614bf084611abb565b614bfa9190615d39565b600083815260ca6020526040902054909150808214614c4d576001600160a01b038416600090815260c960209081526040808320858452825280832054848452818420819055835260ca90915290208190555b50600091825260ca602090815260408084208490556001600160a01b03909416835260c981528383209183525290812055565b60cb54600090614c9290600190615d39565b600083815260cc602052604081205460cb8054939450909284908110614cc857634e487b7160e01b600052603260045260246000fd5b906000526020600020015490508060cb8381548110614cf757634e487b7160e01b600052603260045260246000fd5b600091825260208083209091019290925582815260cc909152604080822084905585825281205560cb805480614d3d57634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b6000614d6483611abb565b6001600160a01b03909316600090815260c960209081526040808320868452825280832085905593825260ca9052919091209190915550565b828054614da990615d93565b90600052602060002090601f016020900481019282614dcb5760008555614e11565b82601f10614de45782800160ff19823516178555614e11565b82800160010185558215614e11579182015b82811115614e11578235825591602001919060010190614df6565b50614e1d929150614f01565b5090565b828054614e2d90615d93565b90600052602060002090601f016020900481019282614e4f5760008555614e11565b82601f10614e6857805160ff1916838001178555614e11565b82800160010185558215614e11579182015b82811115614e11578251825591602001919060010190614e7a565b60405180610100016040528060006001600160a01b0316815260200160008152602001600081526020016000815260200160008152602001600081526020016000815260200160006002811115614efc57634e487b7160e01b600052602160045260246000fd5b905290565b5b80821115614e1d5760008155600101614f02565b60006001600160401b0380841115614f3057614f30615df9565b604051601f8501601f19908116603f01168101908282118183101715614f5857614f58615df9565b81604052809350858152868686011115614f7157600080fd5b858560208301376000602087830101525050509392505050565b8035610b1e81615e0f565b60008083601f840112614fa7578182fd5b5081356001600160401b03811115614fbd578182fd5b6020830191508360208260051b8501011115614fd857600080fd5b9250929050565b60008083601f840112614ff0578182fd5b5081356001600160401b03811115615006578182fd5b602083019150836020828501011115614fd857600080fd5b600082601f83011261502e578081fd5b612cd083833560208501614f16565b60006020828403121561504e578081fd5b8135612cd081615e0f565b6000806040838503121561506b578081fd5b823561507681615e0f565b9150602083013561508681615e0f565b809150509250929050565b6000806000606084860312156150a5578081fd5b83356150b081615e0f565b925060208401356150c081615e0f565b929592945050506040919091013590565b600080600080608085870312156150e6578081fd5b84356150f181615e0f565b9350602085013561510181615e0f565b92506040850135915060608501356001600160401b03811115615122578182fd5b8501601f81018713615132578182fd5b61514187823560208401614f16565b91505092959194509250565b6000806040838503121561515f578182fd5b823561516a81615e0f565b9150602083013561508681615e24565b6000806040838503121561518c578182fd5b823561519781615e0f565b946020939093013593505050565b600080600080606085870312156151ba578384fd5b84356151c581615e0f565b93506020850135925060408501356001600160401b038111156151e6578283fd5b6151f287828801614fdf565b95989497509550505050565b60008060008060408587031215615213578384fd5b84356001600160401b0380821115615229578586fd5b61523588838901614f96565b9096509450602087013591508082111561524d578384fd5b506151f287828801614f96565b6000806000806000806000806080898b031215615275578586fd5b88356001600160401b038082111561528b578788fd5b6152978c838d01614f96565b909a50985060208b01359150808211156152af578788fd5b6152bb8c838d01614f96565b909850965060408b01359150808211156152d3578586fd5b6152df8c838d01614f96565b909650945060608b01359150808211156152f7578384fd5b506153048b828c01614f96565b999c989b5096995094979396929594505050565b6000806020838503121561532a578182fd5b82356001600160401b0381111561533f578283fd5b61534b85828601614f96565b90969095509350505050565b600060208284031215615368578081fd5b8151612cd081615e24565b600060208284031215615384578081fd5b5035919050565b6000806040838503121561539d578182fd5b82359150602083013561508681615e0f565b6000602082840312156153c0578081fd5b8135612cd081615e32565b6000602082840312156153dc578081fd5b8151612cd081615e32565b600080602083850312156153f9578182fd5b82356001600160401b0381111561540e578283fd5b61534b85828601614fdf565b60008060006040848603121561542e578081fd5b83356001600160401b03811115615443578182fd5b61544f86828701614fdf565b909790965060209590950135949350505050565b60008060008060608587031215615478578182fd5b84356001600160401b0381111561548d578283fd5b61549987828801614fdf565b90989097506020870135966040013595509350505050565b6000806000806000806000806000806000806101808d8f0312156154d3578586fd5b6001600160401b038d3511156154e7578586fd5b6154f48e8e358f0161501e565b9b506001600160401b0360208e0135111561550d578586fd5b61551d8e60208f01358f0161501e565b9a506001600160401b0360408e01351115615536578586fd5b6155468e60408f01358f0161501e565b995061555460608e01614f8b565b985061556260808e01614f8b565b975061557060a08e01614f8b565b965061557e60c08e01614f8b565b955060e08d013594506101008d013593506101208d013592506101408d013591506101608d013590509295989b509295989b509295989b565b6000806000604084860312156155cb578081fd5b8335925060208401356001600160401b038111156155e7578182fd5b6155f386828701614fdf565b9497909650939450505050565b600080600080600060808688031215615617578283fd5b8535945060208601356001600160401b03811115615633578384fd5b61563f88828901614fdf565b9699909850959660408101359660609091013595509350505050565b60008151808452615673816020860160208601615d50565b601f01601f19169290920160200192915050565b60008284528282602086013780602084860101526020601f19601f85011685010190509392505050565b8054600090600181811c90808316806156cb57607f831692505b60208084108214156156eb57634e487b7160e01b86526022600452602486fd5b8180156156ff57600181146157105761573d565b60ff1986168952848901965061573d565b60008881526020902060005b868110156157355781548b82015290850190830161571c565b505084890196505b50505050505092915050565b6000828483379101908152919050565b6000825161576b818460208701615d50565b9190910192915050565b600061477361578483866156b1565b846156b1565b600076020b1b1b2b9b9a1b7b73a3937b61d1030b1b1b7bab73a1604d1b825283516157bc816017850160208801615d50565b7001034b99036b4b9b9b4b733903937b6329607d1b60179184019182015283516157ed816028840160208801615d50565b01602801949350505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061582c9083018461565b565b9695505050505050565b6001600160a01b03841681526040602082018190526000906133ff9083018486615687565b6001600160a01b03851681526060602082018190526000906158809083018587615687565b905082604083015295945050505050565b6000604082526158a5604083018587615687565b9050826020830152949350505050565b6000606082526158c9606083018688615687565b6020830194909452506040015292915050565b600060208252612cd0602083018461565b565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252601f908201527f4449524543544f52592f4e4f545f4f574e45525f4f525f474f5645524e4f5200604082015260600190565b6020808252601a908201527f5355424d495353494f4e532f444f45535f4e4f545f4558495354000000000000604082015260600190565b60208082526038908201527f4449524543544f52592f4e4f5f5355424d495353494f4e5f46554e4445445f4f604082015277525f415050524f5645445f464f525f554e4951554554544560401b606082015260800190565b60208082526018908201527714d550935254d4d253d394cbd393d517d054141493d5915160421b604082015260600190565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b60208082526025908201527f5355424d495353494f4e532f4f555444415445445f4d455441444154415f56456040820152642929a4a7a760d91b606082015260800190565b6020808252601790820152765355424d495353494f4e532f4e4f545f50454e44494e4760481b604082015260600190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b60208082526019908201527815539254555155151154cbd113d154d7d393d517d1561254d5603a1b604082015260600190565b6020808252601a908201527f434f4d4d4f4e2f43414c4c45525f4e4f545f474f5645524e4f52000000000000604082015260600190565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006101008201905060018060a01b0383511682526020830151602083015260408301516040830152606083015160608301526080830151608083015260a083015160a083015260c083015160c083015260e083015160038110615c6357634e487b7160e01b600052602160045260246000fd5b8060e08401525092915050565b600086825260806020830152615c8a608083018688615687565b604083019490945250606001529392505050565b6000808335601e19843603018112615cb4578283fd5b8301803591506001600160401b03821115615ccd578283fd5b602001915036819003821315614fd857600080fd5b60008219821115615cf557615cf5615de3565b500190565b600082615d1557634e487b7160e01b81526012600452602481fd5b500490565b6000816000190483118215151615615d3457615d34615de3565b500290565b600082821015615d4b57615d4b615de3565b500390565b60005b83811015615d6b578181015183820152602001615d53565b83811115610b715750506000910152565b600081615d8b57615d8b615de3565b506000190190565b600181811c90821680615da757607f821691505b602082108114156110b957634e487b7160e01b600052602260045260246000fd5b6000600019821415615ddc57615ddc615de3565b5060010190565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160a01b0381168114611a6157600080fd5b8015158114611a6157600080fd5b6001600160e01b031981168114611a6157600080fdfe7935bd0ae54bc31f548c14dba4d37c5c64b3f8ca900cb468fb8abd54d5894f55ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef5375626d697373696f6e733a206e756d626572206f662068617368657320646fa2646970667358221220803f0575e90daef1399fd4b3efef7135c17ad37d7723e05b32f5b900b7ae039364736f6c63430008030033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

Txn Hash Block Value Eth2 PubKey Valid
View All Deposits
[ Download: CSV Export  ]

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