ETH Price: $2,906.06 (-4.10%)
Gas: 1 Gwei

Token

PoCTicket (POCT)
 

Overview

Max Total Supply

1,323 POCT

Holders

1,004

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Filtered by Token Holder
gasistoodamnhigh.eth
Balance
1 POCT
0x6f6a4fe5b944424c115dab4302aaf26f0c7db83f
Loading...
Loading
Loading...
Loading
Loading...
Loading

Click here to update the token information / general information
# Exchange Pair Price  24H Volume % Volume

Contract Source Code Verified (Exact Match)

Contract Name:
PoCTicket

Compiler Version
v0.8.17+commit.8df45f5f

Optimization Enabled:
Yes with 5000 runs

Other Settings:
default evmVersion
File 1 of 36 : ERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721A.sol';

/**
 * @dev Interface of ERC721 token receiver.
 */
interface ERC721A__IERC721Receiver {
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

/**
 * @title ERC721A
 *
 * @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
 * Non-Fungible Token Standard, including the Metadata extension.
 * Optimized for lower gas during batch mints.
 *
 * Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
 * starting from `_startTokenId()`.
 *
 * Assumptions:
 *
 * - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
 * - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
 */
contract ERC721A is IERC721A {
    // Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
    struct TokenApprovalRef {
        address value;
    }

    // =============================================================
    //                           CONSTANTS
    // =============================================================

    // Mask of an entry in packed address data.
    uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;

    // The bit position of `numberMinted` in packed address data.
    uint256 private constant _BITPOS_NUMBER_MINTED = 64;

    // The bit position of `numberBurned` in packed address data.
    uint256 private constant _BITPOS_NUMBER_BURNED = 128;

    // The bit position of `aux` in packed address data.
    uint256 private constant _BITPOS_AUX = 192;

    // Mask of all 256 bits in packed address data except the 64 bits for `aux`.
    uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;

    // The bit position of `startTimestamp` in packed ownership.
    uint256 private constant _BITPOS_START_TIMESTAMP = 160;

    // The bit mask of the `burned` bit in packed ownership.
    uint256 private constant _BITMASK_BURNED = 1 << 224;

    // The bit position of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;

    // The bit mask of the `nextInitialized` bit in packed ownership.
    uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;

    // The bit position of `extraData` in packed ownership.
    uint256 private constant _BITPOS_EXTRA_DATA = 232;

    // Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
    uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;

    // The mask of the lower 160 bits for addresses.
    uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;

    // The maximum `quantity` that can be minted with {_mintERC2309}.
    // This limit is to prevent overflows on the address data entries.
    // For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
    // is required to cause an overflow, which is unrealistic.
    uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;

    // The `Transfer` event signature is given by:
    // `keccak256(bytes("Transfer(address,address,uint256)"))`.
    bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
        0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;

    // =============================================================
    //                            STORAGE
    // =============================================================

    // The next token ID to be minted.
    uint256 private _currentIndex;

    // The number of tokens burned.
    uint256 private _burnCounter;

    // Token name
    string private _name;

    // Token symbol
    string private _symbol;

    // Mapping from token ID to ownership details
    // An empty struct value does not necessarily mean the token is unowned.
    // See {_packedOwnershipOf} implementation for details.
    //
    // Bits Layout:
    // - [0..159]   `addr`
    // - [160..223] `startTimestamp`
    // - [224]      `burned`
    // - [225]      `nextInitialized`
    // - [232..255] `extraData`
    mapping(uint256 => uint256) private _packedOwnerships;

    // Mapping owner address to address data.
    //
    // Bits Layout:
    // - [0..63]    `balance`
    // - [64..127]  `numberMinted`
    // - [128..191] `numberBurned`
    // - [192..255] `aux`
    mapping(address => uint256) private _packedAddressData;

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

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

    // =============================================================
    //                          CONSTRUCTOR
    // =============================================================

    constructor(string memory name_, string memory symbol_) {
        _name = name_;
        _symbol = symbol_;
        _currentIndex = _startTokenId();
    }

    // =============================================================
    //                   TOKEN COUNTING OPERATIONS
    // =============================================================

    /**
     * @dev Returns the starting token ID.
     * To change the starting token ID, please override this function.
     */
    function _startTokenId() internal view virtual returns (uint256) {
        return 0;
    }

    /**
     * @dev Returns the next token ID to be minted.
     */
    function _nextTokenId() internal view virtual returns (uint256) {
        return _currentIndex;
    }

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() public view virtual override returns (uint256) {
        // Counter underflow is impossible as _burnCounter cannot be incremented
        // more than `_currentIndex - _startTokenId()` times.
        unchecked {
            return _currentIndex - _burnCounter - _startTokenId();
        }
    }

    /**
     * @dev Returns the total amount of tokens minted in the contract.
     */
    function _totalMinted() internal view virtual returns (uint256) {
        // Counter underflow is impossible as `_currentIndex` does not decrement,
        // and it is initialized to `_startTokenId()`.
        unchecked {
            return _currentIndex - _startTokenId();
        }
    }

    /**
     * @dev Returns the total number of tokens burned.
     */
    function _totalBurned() internal view virtual returns (uint256) {
        return _burnCounter;
    }

    // =============================================================
    //                    ADDRESS DATA OPERATIONS
    // =============================================================

    /**
     * @dev Returns the number of tokens in `owner`'s account.
     */
    function balanceOf(address owner) public view virtual override returns (uint256) {
        if (owner == address(0)) _revert(BalanceQueryForZeroAddress.selector);
        return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens minted by `owner`.
     */
    function _numberMinted(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the number of tokens burned by or on behalf of `owner`.
     */
    function _numberBurned(address owner) internal view returns (uint256) {
        return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
    }

    /**
     * Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     */
    function _getAux(address owner) internal view returns (uint64) {
        return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
    }

    /**
     * Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
     * If there are multiple variables, please pack them into a uint64.
     */
    function _setAux(address owner, uint64 aux) internal virtual {
        uint256 packed = _packedAddressData[owner];
        uint256 auxCasted;
        // Cast `aux` with assembly to avoid redundant masking.
        assembly {
            auxCasted := aux
        }
        packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
        _packedAddressData[owner] = packed;
    }

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        // The interface IDs are constants representing the first 4 bytes
        // of the XOR of all function selectors in the interface.
        // See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
        // (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
        return
            interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
            interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
            interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
    }

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

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

    /**
     * @dev Returns the token collection symbol.
     */
    function symbol() public view virtual override returns (string memory) {
        return _symbol;
    }

    /**
     * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
     */
    function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
        if (!_exists(tokenId)) _revert(URIQueryForNonexistentToken.selector);

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

    /**
     * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
     * token will be the concatenation of the `baseURI` and the `tokenId`. Empty
     * by default, it can be overridden in child contracts.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return '';
    }

    // =============================================================
    //                     OWNERSHIPS OPERATIONS
    // =============================================================

    /**
     * @dev Returns the owner of the `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function ownerOf(uint256 tokenId) public view virtual override returns (address) {
        return address(uint160(_packedOwnershipOf(tokenId)));
    }

    /**
     * @dev Gas spent here starts off proportional to the maximum mint batch size.
     * It gradually moves to O(1) as tokens get transferred around over time.
     */
    function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnershipOf(tokenId));
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct at `index`.
     */
    function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
        return _unpackedOwnership(_packedOwnerships[index]);
    }

    /**
     * @dev Initializes the ownership slot minted at `index` for efficiency purposes.
     */
    function _initializeOwnershipAt(uint256 index) internal virtual {
        if (_packedOwnerships[index] == 0) {
            _packedOwnerships[index] = _packedOwnershipOf(index);
        }
    }

    /**
     * Returns the packed ownership data of `tokenId`.
     */
    function _packedOwnershipOf(uint256 tokenId) private view returns (uint256 packed) {
        if (_startTokenId() <= tokenId) {
            packed = _packedOwnerships[tokenId];
            // If not burned.
            if (packed & _BITMASK_BURNED == 0) {
                // If the data at the starting slot does not exist, start the scan.
                if (packed == 0) {
                    if (tokenId >= _currentIndex) _revert(OwnerQueryForNonexistentToken.selector);
                    // Invariant:
                    // There will always be an initialized ownership slot
                    // (i.e. `ownership.addr != address(0) && ownership.burned == false`)
                    // before an unintialized ownership slot
                    // (i.e. `ownership.addr == address(0) && ownership.burned == false`)
                    // Hence, `tokenId` will not underflow.
                    //
                    // We can directly compare the packed value.
                    // If the address is zero, packed will be zero.
                    for (;;) {
                        unchecked {
                            packed = _packedOwnerships[--tokenId];
                        }
                        if (packed == 0) continue;
                        return packed;
                    }
                }
                // Otherwise, the data exists and is not burned. We can skip the scan.
                // This is possible because we have already achieved the target condition.
                // This saves 2143 gas on transfers of initialized tokens.
                return packed;
            }
        }
        _revert(OwnerQueryForNonexistentToken.selector);
    }

    /**
     * @dev Returns the unpacked `TokenOwnership` struct from `packed`.
     */
    function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
        ownership.addr = address(uint160(packed));
        ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
        ownership.burned = packed & _BITMASK_BURNED != 0;
        ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
    }

    /**
     * @dev Packs ownership data into a single uint256.
     */
    function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
            result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
        }
    }

    /**
     * @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
     */
    function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
        // For branchless setting of the `nextInitialized` flag.
        assembly {
            // `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
            result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
        }
    }

    // =============================================================
    //                      APPROVAL OPERATIONS
    // =============================================================

    /**
     * @dev Gives permission to `to` to transfer `tokenId` token to another account. See {ERC721A-_approve}.
     *
     * Requirements:
     *
     * - The caller must own the token or be an approved operator.
     */
    function approve(address to, uint256 tokenId) public payable virtual override {
        _approve(to, tokenId, true);
    }

    /**
     * @dev Returns the account approved for `tokenId` token.
     *
     * Requirements:
     *
     * - `tokenId` must exist.
     */
    function getApproved(uint256 tokenId) public view virtual override returns (address) {
        if (!_exists(tokenId)) _revert(ApprovalQueryForNonexistentToken.selector);

        return _tokenApprovals[tokenId].value;
    }

    /**
     * @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) public virtual override {
        _operatorApprovals[_msgSenderERC721A()][operator] = approved;
        emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
    }

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

    /**
     * @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. See {_mint}.
     */
    function _exists(uint256 tokenId) internal view virtual returns (bool) {
        return
            _startTokenId() <= tokenId &&
            tokenId < _currentIndex && // If within bounds,
            _packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
    }

    /**
     * @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
     */
    function _isSenderApprovedOrOwner(
        address approvedAddress,
        address owner,
        address msgSender
    ) private pure returns (bool result) {
        assembly {
            // Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
            owner := and(owner, _BITMASK_ADDRESS)
            // Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
            msgSender := and(msgSender, _BITMASK_ADDRESS)
            // `msgSender == owner || msgSender == approvedAddress`.
            result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
        }
    }

    /**
     * @dev Returns the storage slot and value for the approved address of `tokenId`.
     */
    function _getApprovedSlotAndAddress(uint256 tokenId)
        private
        view
        returns (uint256 approvedAddressSlot, address approvedAddress)
    {
        TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
        // The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
        assembly {
            approvedAddressSlot := tokenApproval.slot
            approvedAddress := sload(approvedAddressSlot)
        }
    }

    // =============================================================
    //                      TRANSFER OPERATIONS
    // =============================================================

    /**
     * @dev Transfers `tokenId` from `from` to `to`.
     *
     * 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
    ) public payable virtual override {
        uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);

        // Mask `from` to the lower 160 bits, in case the upper bits somehow aren't clean.
        from = address(uint160(uint256(uint160(from)) & _BITMASK_ADDRESS));

        if (address(uint160(prevOwnershipPacked)) != from) _revert(TransferFromIncorrectOwner.selector);

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        // The nested ifs save around 20+ gas over a compound boolean condition.
        if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
            if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector);

        _beforeTokenTransfers(from, to, tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // We can directly increment and decrement the balances.
            --_packedAddressData[from]; // Updates: `balance -= 1`.
            ++_packedAddressData[to]; // Updates: `balance += 1`.

            // Updates:
            // - `address` to the next owner.
            // - `startTimestamp` to the timestamp of transfering.
            // - `burned` to `false`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                to,
                _BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
        uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS;
        assembly {
            // Emit the `Transfer` event.
            log4(
                0, // Start of data (0, since no data).
                0, // End of data (0, since no data).
                _TRANSFER_EVENT_SIGNATURE, // Signature.
                from, // `from`.
                toMasked, // `to`.
                tokenId // `tokenId`.
            )
        }
        if (toMasked == 0) _revert(TransferToZeroAddress.selector);

        _afterTokenTransfers(from, to, tokenId, 1);
    }

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) public payable virtual override {
        safeTransferFrom(from, to, tokenId, '');
    }

    /**
     * @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 memory _data
    ) public payable virtual override {
        transferFrom(from, to, tokenId);
        if (to.code.length != 0)
            if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
                _revert(TransferToNonERC721ReceiverImplementer.selector);
            }
    }

    /**
     * @dev Hook that is called before a set of serially-ordered token IDs
     * are about to be transferred. This includes minting.
     * And also called before burning one token.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * 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, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Hook that is called after a set of serially-ordered token IDs
     * have been transferred. This includes minting.
     * And also called after one token has been burned.
     *
     * `startTokenId` - the first token ID to be transferred.
     * `quantity` - the amount to be transferred.
     *
     * Calling conditions:
     *
     * - When `from` and `to` are both non-zero, `from`'s `tokenId` has been
     * transferred to `to`.
     * - When `from` is zero, `tokenId` has been minted for `to`.
     * - When `to` is zero, `tokenId` has been burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _afterTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual {}

    /**
     * @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
     *
     * `from` - Previous owner of the given token ID.
     * `to` - Target address that will receive the token.
     * `tokenId` - Token ID to be transferred.
     * `_data` - Optional data to send along with the call.
     *
     * Returns whether the call correctly returned the expected magic value.
     */
    function _checkContractOnERC721Received(
        address from,
        address to,
        uint256 tokenId,
        bytes memory _data
    ) private returns (bool) {
        try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
            bytes4 retval
        ) {
            return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
        } catch (bytes memory reason) {
            if (reason.length == 0) {
                _revert(TransferToNonERC721ReceiverImplementer.selector);
            }
            assembly {
                revert(add(32, reason), mload(reason))
            }
        }
    }

    // =============================================================
    //                        MINT OPERATIONS
    // =============================================================

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _mint(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (quantity == 0) _revert(MintZeroQuantity.selector);

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are incredibly unrealistic.
        // `balance` and `numberMinted` have a maximum limit of 2**64.
        // `tokenId` has a maximum limit of 2**256.
        unchecked {
            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
            uint256 toMasked = uint256(uint160(to)) & _BITMASK_ADDRESS;

            if (toMasked == 0) _revert(MintToZeroAddress.selector);

            uint256 end = startTokenId + quantity;
            uint256 tokenId = startTokenId;

            do {
                assembly {
                    // Emit the `Transfer` event.
                    log4(
                        0, // Start of data (0, since no data).
                        0, // End of data (0, since no data).
                        _TRANSFER_EVENT_SIGNATURE, // Signature.
                        0, // `address(0)`.
                        toMasked, // `to`.
                        tokenId // `tokenId`.
                    )
                }
                // The `!=` check ensures that large values of `quantity`
                // that overflows uint256 will make the loop run out of gas.
            } while (++tokenId != end);

            _currentIndex = end;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Mints `quantity` tokens and transfers them to `to`.
     *
     * This function is intended for efficient minting only during contract creation.
     *
     * It emits only one {ConsecutiveTransfer} as defined in
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
     * instead of a sequence of {Transfer} event(s).
     *
     * Calling this function outside of contract creation WILL make your contract
     * non-compliant with the ERC721 standard.
     * For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
     * {ConsecutiveTransfer} event is only permissible during contract creation.
     *
     * Requirements:
     *
     * - `to` cannot be the zero address.
     * - `quantity` must be greater than 0.
     *
     * Emits a {ConsecutiveTransfer} event.
     */
    function _mintERC2309(address to, uint256 quantity) internal virtual {
        uint256 startTokenId = _currentIndex;
        if (to == address(0)) _revert(MintToZeroAddress.selector);
        if (quantity == 0) _revert(MintZeroQuantity.selector);
        if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) _revert(MintERC2309QuantityExceedsLimit.selector);

        _beforeTokenTransfers(address(0), to, startTokenId, quantity);

        // Overflows are unrealistic due to the above check for `quantity` to be below the limit.
        unchecked {
            // Updates:
            // - `balance += quantity`.
            // - `numberMinted += quantity`.
            //
            // We can directly add to the `balance` and `numberMinted`.
            _packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);

            // Updates:
            // - `address` to the owner.
            // - `startTimestamp` to the timestamp of minting.
            // - `burned` to `false`.
            // - `nextInitialized` to `quantity == 1`.
            _packedOwnerships[startTokenId] = _packOwnershipData(
                to,
                _nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
            );

            emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);

            _currentIndex = startTokenId + quantity;
        }
        _afterTokenTransfers(address(0), to, startTokenId, quantity);
    }

    /**
     * @dev Safely mints `quantity` tokens and transfers them to `to`.
     *
     * Requirements:
     *
     * - If `to` refers to a smart contract, it must implement
     * {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
     * - `quantity` must be greater than 0.
     *
     * See {_mint}.
     *
     * Emits a {Transfer} event for each mint.
     */
    function _safeMint(
        address to,
        uint256 quantity,
        bytes memory _data
    ) internal virtual {
        _mint(to, quantity);

        unchecked {
            if (to.code.length != 0) {
                uint256 end = _currentIndex;
                uint256 index = end - quantity;
                do {
                    if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
                        _revert(TransferToNonERC721ReceiverImplementer.selector);
                    }
                } while (index < end);
                // Reentrancy protection.
                if (_currentIndex != end) _revert(bytes4(0));
            }
        }
    }

    /**
     * @dev Equivalent to `_safeMint(to, quantity, '')`.
     */
    function _safeMint(address to, uint256 quantity) internal virtual {
        _safeMint(to, quantity, '');
    }

    // =============================================================
    //                       APPROVAL OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_approve(to, tokenId, false)`.
     */
    function _approve(address to, uint256 tokenId) internal virtual {
        _approve(to, tokenId, false);
    }

    /**
     * @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:
     *
     * - `tokenId` must exist.
     *
     * Emits an {Approval} event.
     */
    function _approve(
        address to,
        uint256 tokenId,
        bool approvalCheck
    ) internal virtual {
        address owner = ownerOf(tokenId);

        if (approvalCheck && _msgSenderERC721A() != owner)
            if (!isApprovedForAll(owner, _msgSenderERC721A())) {
                _revert(ApprovalCallerNotOwnerNorApproved.selector);
            }

        _tokenApprovals[tokenId].value = to;
        emit Approval(owner, to, tokenId);
    }

    // =============================================================
    //                        BURN OPERATIONS
    // =============================================================

    /**
     * @dev Equivalent to `_burn(tokenId, false)`.
     */
    function _burn(uint256 tokenId) internal virtual {
        _burn(tokenId, false);
    }

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

        address from = address(uint160(prevOwnershipPacked));

        (uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);

        if (approvalCheck) {
            // The nested ifs save around 20+ gas over a compound boolean condition.
            if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
                if (!isApprovedForAll(from, _msgSenderERC721A())) _revert(TransferCallerNotOwnerNorApproved.selector);
        }

        _beforeTokenTransfers(from, address(0), tokenId, 1);

        // Clear approvals from the previous owner.
        assembly {
            if approvedAddress {
                // This is equivalent to `delete _tokenApprovals[tokenId]`.
                sstore(approvedAddressSlot, 0)
            }
        }

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        // Counter overflow is incredibly unrealistic as `tokenId` would have to be 2**256.
        unchecked {
            // Updates:
            // - `balance -= 1`.
            // - `numberBurned += 1`.
            //
            // We can directly decrement the balance, and increment the number burned.
            // This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
            _packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;

            // Updates:
            // - `address` to the last owner.
            // - `startTimestamp` to the timestamp of burning.
            // - `burned` to `true`.
            // - `nextInitialized` to `true`.
            _packedOwnerships[tokenId] = _packOwnershipData(
                from,
                (_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
            );

            // If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
            if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
                uint256 nextTokenId = tokenId + 1;
                // If the next slot's address is zero and not burned (i.e. packed value is zero).
                if (_packedOwnerships[nextTokenId] == 0) {
                    // If the next slot is within bounds.
                    if (nextTokenId != _currentIndex) {
                        // Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
                        _packedOwnerships[nextTokenId] = prevOwnershipPacked;
                    }
                }
            }
        }

        emit Transfer(from, address(0), tokenId);
        _afterTokenTransfers(from, address(0), tokenId, 1);

        // Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
        unchecked {
            _burnCounter++;
        }
    }

    // =============================================================
    //                     EXTRA DATA OPERATIONS
    // =============================================================

    /**
     * @dev Directly sets the extra data for the ownership data `index`.
     */
    function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
        uint256 packed = _packedOwnerships[index];
        if (packed == 0) _revert(OwnershipNotInitializedForExtraData.selector);
        uint256 extraDataCasted;
        // Cast `extraData` with assembly to avoid redundant masking.
        assembly {
            extraDataCasted := extraData
        }
        packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
        _packedOwnerships[index] = packed;
    }

    /**
     * @dev Called during each token transfer to set the 24bit `extraData` field.
     * Intended to be overridden by the cosumer contract.
     *
     * `previousExtraData` - the value of `extraData` before transfer.
     *
     * 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, `tokenId` will be burned by `from`.
     * - `from` and `to` are never both zero.
     */
    function _extraData(
        address from,
        address to,
        uint24 previousExtraData
    ) internal view virtual returns (uint24) {}

    /**
     * @dev Returns the next extra data for the packed ownership data.
     * The returned result is shifted into position.
     */
    function _nextExtraData(
        address from,
        address to,
        uint256 prevOwnershipPacked
    ) private view returns (uint256) {
        uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
        return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
    }

    // =============================================================
    //                       OTHER OPERATIONS
    // =============================================================

    /**
     * @dev Returns the message sender (defaults to `msg.sender`).
     *
     * If you are writing GSN compatible contracts, you need to override this function.
     */
    function _msgSenderERC721A() internal view virtual returns (address) {
        return msg.sender;
    }

    /**
     * @dev Converts a uint256 to its ASCII string decimal representation.
     */
    function _toString(uint256 value) internal pure virtual returns (string memory str) {
        assembly {
            // The maximum value of a uint256 contains 78 digits (1 byte per digit), but
            // we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
            // We will need 1 word for the trailing zeros padding, 1 word for the length,
            // and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
            let m := add(mload(0x40), 0xa0)
            // Update the free memory pointer to allocate.
            mstore(0x40, m)
            // Assign the `str` to the end.
            str := sub(m, 0x20)
            // Zeroize the slot after the string.
            mstore(str, 0)

            // Cache the end of the memory to calculate the length later.
            let end := str

            // We write the string from rightmost digit to leftmost digit.
            // The following is essentially a do-while loop that also handles the zero case.
            // prettier-ignore
            for { let temp := value } 1 {} {
                str := sub(str, 1)
                // Write the character to the pointer.
                // The ASCII index of the '0' character is 48.
                mstore8(str, add(48, mod(temp, 10)))
                // Keep dividing `temp` until zero.
                temp := div(temp, 10)
                // prettier-ignore
                if iszero(temp) { break }
            }

            let length := sub(end, str)
            // Move the pointer 32 bytes leftwards to make room for the length.
            str := sub(str, 0x20)
            // Store the length.
            mstore(str, length)
        }
    }

    /**
     * @dev For more efficient reverts.
     */
    function _revert(bytes4 errorSelector) internal pure {
        assembly {
            mstore(0x00, errorSelector)
            revert(0x00, 0x04)
        }
    }
}

File 2 of 36 : IERC721A.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

/**
 * @dev Interface of ERC721A.
 */
interface IERC721A {
    /**
     * The caller must own the token or be an approved operator.
     */
    error ApprovalCallerNotOwnerNorApproved();

    /**
     * The token does not exist.
     */
    error ApprovalQueryForNonexistentToken();

    /**
     * Cannot query the balance for the zero address.
     */
    error BalanceQueryForZeroAddress();

    /**
     * Cannot mint to the zero address.
     */
    error MintToZeroAddress();

    /**
     * The quantity of tokens minted must be more than zero.
     */
    error MintZeroQuantity();

    /**
     * The token does not exist.
     */
    error OwnerQueryForNonexistentToken();

    /**
     * The caller must own the token or be an approved operator.
     */
    error TransferCallerNotOwnerNorApproved();

    /**
     * The token must be owned by `from`.
     */
    error TransferFromIncorrectOwner();

    /**
     * Cannot safely transfer to a contract that does not implement the
     * ERC721Receiver interface.
     */
    error TransferToNonERC721ReceiverImplementer();

    /**
     * Cannot transfer to the zero address.
     */
    error TransferToZeroAddress();

    /**
     * The token does not exist.
     */
    error URIQueryForNonexistentToken();

    /**
     * The `quantity` minted with ERC2309 exceeds the safety limit.
     */
    error MintERC2309QuantityExceedsLimit();

    /**
     * The `extraData` cannot be set on an unintialized ownership slot.
     */
    error OwnershipNotInitializedForExtraData();

    // =============================================================
    //                            STRUCTS
    // =============================================================

    struct TokenOwnership {
        // The address of the owner.
        address addr;
        // Stores the start time of ownership with minimal overhead for tokenomics.
        uint64 startTimestamp;
        // Whether the token has been burned.
        bool burned;
        // Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
        uint24 extraData;
    }

    // =============================================================
    //                         TOKEN COUNTERS
    // =============================================================

    /**
     * @dev Returns the total number of tokens in existence.
     * Burned tokens will reduce the count.
     * To get the total number of tokens minted, please see {_totalMinted}.
     */
    function totalSupply() external view returns (uint256);

    // =============================================================
    //                            IERC165
    // =============================================================

    /**
     * @dev Returns true if this contract implements the interface defined by
     * `interfaceId`. See the corresponding
     * [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
     * to learn more about how these ids are created.
     *
     * This function call must use less than 30000 gas.
     */
    function supportsInterface(bytes4 interfaceId) external view returns (bool);

    // =============================================================
    //                            IERC721
    // =============================================================

    /**
     * @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,
        bytes calldata data
    ) external payable;

    /**
     * @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
     */
    function safeTransferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external payable;

    /**
     * @dev Transfers `tokenId` 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 payable;

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

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

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

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

    // =============================================================
    //                        IERC721Metadata
    // =============================================================

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

    // =============================================================
    //                           IERC2309
    // =============================================================

    /**
     * @dev Emitted when tokens in `fromTokenId` to `toTokenId`
     * (inclusive) is transferred from `from` to `to`, as defined in the
     * [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
     *
     * See {_mintERC2309} for more details.
     */
    event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}

File 3 of 36 : IDelegationRegistry.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.17;

/**
 * @title An immutable registry contract to be deployed as a standalone primitive
 * @dev See EIP-5639, new project launches can read previous cold wallet -> hot wallet delegations
 * from here and integrate those permissions into their flow
 */
interface IDelegationRegistry {
    /// @notice Delegation type
    enum DelegationType {
        NONE,
        ALL,
        CONTRACT,
        TOKEN
    }

    /// @notice Info about a single delegation, used for onchain enumeration
    struct DelegationInfo {
        DelegationType type_;
        address vault;
        address delegate;
        address contract_;
        uint256 tokenId;
    }

    /// @notice Info about a single contract-level delegation
    struct ContractDelegation {
        address contract_;
        address delegate;
    }

    /// @notice Info about a single token-level delegation
    struct TokenDelegation {
        address contract_;
        uint256 tokenId;
        address delegate;
    }

    /// @notice Emitted when a user delegates their entire wallet
    event DelegateForAll(address vault, address delegate, bool value);

    /// @notice Emitted when a user delegates a specific contract
    event DelegateForContract(address vault, address delegate, address contract_, bool value);

    /// @notice Emitted when a user delegates a specific token
    event DelegateForToken(address vault, address delegate, address contract_, uint256 tokenId, bool value);

    /// @notice Emitted when a user revokes all delegations
    event RevokeAllDelegates(address vault);

    /// @notice Emitted when a user revoes all delegations for a given delegate
    event RevokeDelegate(address vault, address delegate);

    /**
     * -----------  WRITE -----------
     */

    /**
     * @notice Allow the delegate to act on your behalf for all contracts
     * @param delegate The hotwallet to act on your behalf
     * @param value Whether to enable or disable delegation for this address, true for setting and false for revoking
     */
    function delegateForAll(address delegate, bool value) external;

    /**
     * @notice Allow the delegate to act on your behalf for a specific contract
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param value Whether to enable or disable delegation for this address, true for setting and false for revoking
     */
    function delegateForContract(address delegate, address contract_, bool value) external;

    /**
     * @notice Allow the delegate to act on your behalf for a specific token
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param tokenId The token id for the token you're delegating
     * @param value Whether to enable or disable delegation for this address, true for setting and false for revoking
     */
    function delegateForToken(address delegate, address contract_, uint256 tokenId, bool value) external;

    /**
     * @notice Revoke all delegates
     */
    function revokeAllDelegates() external;

    /**
     * @notice Revoke a specific delegate for all their permissions
     * @param delegate The hotwallet to revoke
     */
    function revokeDelegate(address delegate) external;

    /**
     * @notice Remove yourself as a delegate for a specific vault
     * @param vault The vault which delegated to the msg.sender, and should be removed
     */
    function revokeSelf(address vault) external;

    /**
     * -----------  READ -----------
     */

    /**
     * @notice Returns all active delegations a given delegate is able to claim on behalf of
     * @param delegate The delegate that you would like to retrieve delegations for
     * @return info Array of DelegationInfo structs
     */
    function getDelegationsByDelegate(address delegate) external view returns (DelegationInfo[] memory);

    /**
     * @notice Returns an array of wallet-level delegates for a given vault
     * @param vault The cold wallet who issued the delegation
     * @return addresses Array of wallet-level delegates for a given vault
     */
    function getDelegatesForAll(address vault) external view returns (address[] memory);

    /**
     * @notice Returns an array of contract-level delegates for a given vault and contract
     * @param vault The cold wallet who issued the delegation
     * @param contract_ The address for the contract you're delegating
     * @return addresses Array of contract-level delegates for a given vault and contract
     */
    function getDelegatesForContract(address vault, address contract_) external view returns (address[] memory);

    /**
     * @notice Returns an array of contract-level delegates for a given vault's token
     * @param vault The cold wallet who issued the delegation
     * @param contract_ The address for the contract holding the token
     * @param tokenId The token id for the token you're delegating
     * @return addresses Array of contract-level delegates for a given vault's token
     */
    function getDelegatesForToken(address vault, address contract_, uint256 tokenId)
        external
        view
        returns (address[] memory);

    /**
     * @notice Returns all contract-level delegations for a given vault
     * @param vault The cold wallet who issued the delegations
     * @return delegations Array of ContractDelegation structs
     */
    function getContractLevelDelegations(address vault)
        external
        view
        returns (ContractDelegation[] memory delegations);

    /**
     * @notice Returns all token-level delegations for a given vault
     * @param vault The cold wallet who issued the delegations
     * @return delegations Array of TokenDelegation structs
     */
    function getTokenLevelDelegations(address vault) external view returns (TokenDelegation[] memory delegations);

    /**
     * @notice Returns true if the address is delegated to act on the entire vault
     * @param delegate The hotwallet to act on your behalf
     * @param vault The cold wallet who issued the delegation
     */
    function checkDelegateForAll(address delegate, address vault) external view returns (bool);

    /**
     * @notice Returns true if the address is delegated to act on your behalf for a token contract or an entire vault
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param vault The cold wallet who issued the delegation
     */
    function checkDelegateForContract(address delegate, address vault, address contract_)
        external
        view
        returns (bool);

    /**
     * @notice Returns true if the address is delegated to act on your behalf for a specific token, the token's contract or an entire vault
     * @param delegate The hotwallet to act on your behalf
     * @param contract_ The address for the contract you're delegating
     * @param tokenId The token id for the token you're delegating
     * @param vault The cold wallet who issued the delegation
     */
    function checkDelegateForToken(address delegate, address vault, address contract_, uint256 tokenId)
        external
        view
        returns (bool);
}

File 4 of 36 : BaseTokenURI.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import {AccessControlEnumerable} from "../utils/AccessControlEnumerable.sol";

/**
@notice ERC721 extension that overrides the OpenZeppelin _baseURI() function to
return a prefix that can be set by the contract owner.
 */
contract BaseTokenURI is AccessControlEnumerable {
    /// @notice Base token URI used as a prefix by tokenURI().
    string public baseTokenURI;

    constructor(string memory _baseTokenURI) {
        _setBaseTokenURI(_baseTokenURI);
    }

    /// @notice Sets the base token URI prefix.
    /// @dev Only callable by the contract steerer.
    function setBaseTokenURI(string memory _baseTokenURI)
        public
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        _setBaseTokenURI(_baseTokenURI);
    }

    /// @notice Sets the base token URI prefix.
    function _setBaseTokenURI(string memory _baseTokenURI) internal virtual {
        baseTokenURI = _baseTokenURI;
    }

    /**
    @notice Concatenates and returns the base token URI and the token ID without
    any additional characters (e.g. a slash).
    @dev This requires that an inheriting contract that also inherits from OZ's
    ERC721 will have to override both contracts; although we could simply
    require that users implement their own _baseURI() as here, this can easily
    be forgotten and the current approach guides them with compiler errors. This
    favours the latter half of "APIs should be easy to use and hard to misuse"
    from https://www.infoq.com/articles/API-Design-Joshua-Bloch/.
     */
    function _baseURI() internal view virtual returns (string memory) {
        return baseTokenURI;
    }
}

File 5 of 36 : ERC4906.sol
// SPDX-License-Identifier: CC0-1.0
pragma solidity ^0.8.0;

import {IERC165, ERC165} from "@openzeppelin/contracts/utils/introspection/ERC165.sol";

interface IERC4906Events {
    /// @dev This event emits when the metadata of a token is changed.
    /// So that the third-party platforms such as NFT market could
    /// timely update the images and related attributes of the NFT.
    event MetadataUpdate(uint256 _tokenId);

    /// @dev This event emits when the metadata of a range of tokens is changed.
    /// So that the third-party platforms such as NFT market could
    /// timely update the images and related attributes of the NFTs.
    event BatchMetadataUpdate(uint256 _fromTokenId, uint256 _toTokenId);
}

/// @title EIP-721 Metadata Update Extension
// solhint-disable-next-line no-empty-blocks
interface IERC4906 is IERC165, IERC4906Events {

}

contract ERC4906 is IERC4906, ERC165 {
    function _refreshMetadata(uint256 tokenId) internal {
        emit MetadataUpdate(tokenId);
    }

    function _refreshMetadata(uint256 fromTokenId, uint256 toTokenId) internal {
        emit BatchMetadataUpdate(fromTokenId, toTokenId);
    }

    /// @dev See {IERC165-supportsInterface}.
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ERC165, IERC165)
        returns (bool)
    {
        return
            interfaceId == bytes4(0x49064906) ||
            ERC165.supportsInterface(interfaceId);
    }
}

File 6 of 36 : ERC721ACommon.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2022 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import {ERC721A} from "erc721a/contracts/ERC721A.sol";
import {ERC2981} from "@openzeppelin/contracts/token/common/ERC2981.sol";
import {AccessControlEnumerable} from "../utils/AccessControlEnumerable.sol";
import {AccessControlPausable} from "../utils/AccessControlPausable.sol";
import {ERC4906} from "./ERC4906.sol";

/**
@notice An ERC721A contract with common functionality:
 - Pausable with toggling functions exposed to Owner only
 - ERC2981 royalties
 */
contract ERC721ACommon is ERC721A, AccessControlPausable, ERC2981, ERC4906 {
    constructor(
        address admin,
        address steerer,
        string memory name,
        string memory symbol,
        address payable royaltyReciever,
        uint96 royaltyBasisPoints
    ) ERC721A(name, symbol) {
        _setDefaultRoyalty(royaltyReciever, royaltyBasisPoints);
        _grantRole(DEFAULT_ADMIN_ROLE, admin);
        _grantRole(DEFAULT_STEERING_ROLE, steerer);
    }

    /// @notice Requires that the token exists.
    modifier tokenExists(uint256 tokenId) {
        require(ERC721A._exists(tokenId), "ERC721ACommon: Token doesn't exist");
        _;
    }

    /// @notice Requires that msg.sender owns or is approved for the token.
    modifier onlyApprovedOrOwner(uint256 tokenId) {
        require(
            _ownershipOf(tokenId).addr == _msgSender() ||
                getApproved(tokenId) == _msgSender(),
            "ERC721ACommon: Not approved nor owner"
        );
        _;
    }

    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual override {
        require(!paused(), "ERC721ACommon: paused");
        super._beforeTokenTransfers(from, to, startTokenId, quantity);
    }

    /// @notice Overrides supportsInterface as required by inheritance.
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ERC721A, AccessControlEnumerable, ERC2981, ERC4906)
        returns (bool)
    {
        return
            ERC721A.supportsInterface(interfaceId) ||
            ERC2981.supportsInterface(interfaceId) ||
            AccessControlEnumerable.supportsInterface(interfaceId) ||
            ERC4906.supportsInterface(interfaceId);
    }

    /// @notice Sets the royalty receiver and percentage (in units of basis
    /// points = 0.01%).
    function setDefaultRoyalty(address receiver, uint96 basisPoints)
        public
        virtual
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        _setDefaultRoyalty(receiver, basisPoints);
    }

    function emitMetadataUpdateForAll()
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        // EIP4906 is unfortunately quite vague on whether the `toTokenId` in
        // the following event is included or not. We hence use `totalSupply()`
        // to ensure that the last actual `tokenId` is included in any case.
        _refreshMetadata(0, totalSupply());
    }
}

File 7 of 36 : AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2023 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import {AccessControlEnumerable as ACE} from "@openzeppelin/contracts/access/AccessControlEnumerable.sol";

contract AccessControlEnumerable is ACE {
    /// @notice The default role intended to perform access-restricted actions.
    /// @dev We are using this instead of DEFAULT_ADMIN_ROLE because the latter
    /// is intended to grant/revoke roles and will be secured differently.
    bytes32 public constant DEFAULT_STEERING_ROLE =
        keccak256("DEFAULT_STEERING_ROLE");

    /// @dev Overrides supportsInterface so that inheriting contracts can
    /// reference this contract instead of OZ's version for further overrides.
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ACE)
        returns (bool)
    {
        return ACE.supportsInterface(interfaceId);
    }
}

File 8 of 36 : AccessControlPausable.sol
// SPDX-License-Identifier: MIT
// Copyright (c) 2021 the ethier authors (github.com/divergencetech/ethier)
pragma solidity >=0.8.0 <0.9.0;

import {Pausable} from "@openzeppelin/contracts/security/Pausable.sol";
import {AccessControlEnumerable} from "./AccessControlEnumerable.sol";

/// @notice A Pausable contract that can only be toggled by a member of the
/// STEERING role.
contract AccessControlPausable is AccessControlEnumerable, Pausable {
    /// @notice Pauses the contract.
    function pause() public onlyRole(DEFAULT_STEERING_ROLE) {
        Pausable._pause();
    }

    /// @notice Unpauses the contract.
    function unpause() public onlyRole(DEFAULT_STEERING_ROLE) {
        Pausable._unpause();
    }
}

File 9 of 36 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../utils/introspection/ERC165.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms. This is a lightweight version that doesn't allow enumerating role
 * members except through off-chain means by accessing the contract event logs. Some
 * applications may benefit from on-chain enumerability, for those cases see
 * {AccessControlEnumerable}.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract 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 Modifier that checks that an account has a specific role. Reverts
     * with a standardized message including the required role.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     *
     * _Available since v4.1._
     */
    modifier onlyRole(bytes32 role) {
        _checkRole(role);
        _;
    }

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

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

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

    /**
     * @dev Revert with a standard message if `account` is missing `role`.
     *
     * The format of the revert reason is given by the following regular expression:
     *
     *  /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
     */
    function _checkRole(bytes32 role, address account) internal view virtual {
        if (!hasRole(role, account)) {
            revert(
                string(
                    abi.encodePacked(
                        "AccessControl: account ",
                        Strings.toHexString(account),
                        " 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 virtual override returns (bytes32) {
        return _roles[role].adminRole;
    }

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

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

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

        _revokeRole(role, account);
    }

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

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

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

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

File 10 of 36 : AccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (access/AccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlEnumerable.sol";
import "./AccessControl.sol";
import "../utils/structs/EnumerableSet.sol";

/**
 * @dev Extension of {AccessControl} that allows enumerating the members of each role.
 */
abstract contract AccessControlEnumerable is IAccessControlEnumerable, AccessControl {
    using EnumerableSet for EnumerableSet.AddressSet;

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

    /**
     * @dev See {IERC165-supportsInterface}.
     */
    function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
        return interfaceId == type(IAccessControlEnumerable).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 virtual 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 virtual override returns (uint256) {
        return _roleMembers[role].length();
    }

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

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

File 11 of 36 : IAccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 12 of 36 : IAccessControlEnumerable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControl.sol";

/**
 * @dev External interface of AccessControlEnumerable declared to support ERC165 detection.
 */
interface IAccessControlEnumerable is IAccessControl {
    /**
     * @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) external view returns (address);

    /**
     * @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) external view returns (uint256);
}

File 13 of 36 : IERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)

pragma solidity ^0.8.0;

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

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

File 14 of 36 : Pausable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.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 Pausable is Context {
    /**
     * @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.
     */
    constructor() {
        _paused = false;
    }

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

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

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

    /**
     * @dev Throws if the contract is paused.
     */
    function _requireNotPaused() internal view virtual {
        require(!paused(), "Pausable: paused");
    }

    /**
     * @dev Throws if the contract is not paused.
     */
    function _requirePaused() internal view virtual {
        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());
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

File 16 of 36 : ERC2981.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/common/ERC2981.sol)

pragma solidity ^0.8.0;

import "../../interfaces/IERC2981.sol";
import "../../utils/introspection/ERC165.sol";

/**
 * @dev Implementation of the NFT Royalty Standard, a standardized way to retrieve royalty payment information.
 *
 * Royalty information can be specified globally for all token ids via {_setDefaultRoyalty}, and/or individually for
 * specific token ids via {_setTokenRoyalty}. The latter takes precedence over the first.
 *
 * Royalty is specified as a fraction of sale price. {_feeDenominator} is overridable but defaults to 10000, meaning the
 * fee is specified in basis points by default.
 *
 * IMPORTANT: ERC-2981 only specifies a way to signal royalty information and does not enforce its payment. See
 * https://eips.ethereum.org/EIPS/eip-2981#optional-royalty-payments[Rationale] in the EIP. Marketplaces are expected to
 * voluntarily pay royalties together with sales, but note that this standard is not yet widely supported.
 *
 * _Available since v4.5._
 */
abstract contract ERC2981 is IERC2981, ERC165 {
    struct RoyaltyInfo {
        address receiver;
        uint96 royaltyFraction;
    }

    RoyaltyInfo private _defaultRoyaltyInfo;
    mapping(uint256 => RoyaltyInfo) private _tokenRoyaltyInfo;

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

    /**
     * @inheritdoc IERC2981
     */
    function royaltyInfo(uint256 tokenId, uint256 salePrice) public view virtual override returns (address, uint256) {
        RoyaltyInfo memory royalty = _tokenRoyaltyInfo[tokenId];

        if (royalty.receiver == address(0)) {
            royalty = _defaultRoyaltyInfo;
        }

        uint256 royaltyAmount = (salePrice * royalty.royaltyFraction) / _feeDenominator();

        return (royalty.receiver, royaltyAmount);
    }

    /**
     * @dev The denominator with which to interpret the fee set in {_setTokenRoyalty} and {_setDefaultRoyalty} as a
     * fraction of the sale price. Defaults to 10000 so fees are expressed in basis points, but may be customized by an
     * override.
     */
    function _feeDenominator() internal pure virtual returns (uint96) {
        return 10000;
    }

    /**
     * @dev Sets the royalty information that all ids in this contract will default to.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setDefaultRoyalty(address receiver, uint96 feeNumerator) internal virtual {
        require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
        require(receiver != address(0), "ERC2981: invalid receiver");

        _defaultRoyaltyInfo = RoyaltyInfo(receiver, feeNumerator);
    }

    /**
     * @dev Removes default royalty information.
     */
    function _deleteDefaultRoyalty() internal virtual {
        delete _defaultRoyaltyInfo;
    }

    /**
     * @dev Sets the royalty information for a specific token id, overriding the global default.
     *
     * Requirements:
     *
     * - `receiver` cannot be the zero address.
     * - `feeNumerator` cannot be greater than the fee denominator.
     */
    function _setTokenRoyalty(uint256 tokenId, address receiver, uint96 feeNumerator) internal virtual {
        require(feeNumerator <= _feeDenominator(), "ERC2981: royalty fee will exceed salePrice");
        require(receiver != address(0), "ERC2981: Invalid parameters");

        _tokenRoyaltyInfo[tokenId] = RoyaltyInfo(receiver, feeNumerator);
    }

    /**
     * @dev Resets royalty information for the token id back to the global default.
     */
    function _resetTokenRoyalty(uint256 tokenId) internal virtual {
        delete _tokenRoyaltyInfo[tokenId];
    }
}

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

pragma solidity ^0.8.1;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @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
     *
     * Furthermore, `isContract` will also return true if the target contract within
     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,
     * which only has an effect at the end of a transaction.
     * ====
     *
     * [IMPORTANT]
     * ====
     * You shouldn't rely on `isContract` to protect against flash loan attacks!
     *
     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
     * constructor.
     * ====
     */
    function isContract(address account) internal view returns (bool) {
        // This method relies on extcodesize/address.code.length, which returns 0
        // for contracts in construction, since the code is only stored at the end
        // of the constructor execution.

        return account.code.length > 0;
    }

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

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

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

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

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

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

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

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

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

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

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

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

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

File 18 of 36 : Context.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

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 19 of 36 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/Strings.sol)

pragma solidity ^0.8.0;

import "./math/Math.sol";
import "./math/SignedMath.sol";

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

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

    /**
     * @dev Converts a `int256` to its ASCII `string` decimal representation.
     */
    function toString(int256 value) internal pure returns (string memory) {
        return string(abi.encodePacked(value < 0 ? "-" : "", toString(SignedMath.abs(value))));
    }

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

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

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

    /**
     * @dev Returns true if the two strings are equal.
     */
    function equal(string memory a, string memory b) internal pure returns (bool) {
        return keccak256(bytes(a)) == keccak256(bytes(b));
    }
}

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

pragma solidity ^0.8.0;

import "../Strings.sol";

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

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

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

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

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

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

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

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

        return (signer, RecoverError.NoError);
    }

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

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

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

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

File 21 of 36 : ERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)

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 22 of 36 : IERC165.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)

pragma solidity ^0.8.0;

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

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

            // Make sure the result is less than 2^256. Also prevents denominator == 0.
            require(denominator > prod1, "Math: mulDiv overflow");

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

File 24 of 36 : SignedMath.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/math/SignedMath.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard signed math utilities missing in the Solidity language.
 */
library SignedMath {
    /**
     * @dev Returns the largest of two signed numbers.
     */
    function max(int256 a, int256 b) internal pure returns (int256) {
        return a > b ? a : b;
    }

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

    /**
     * @dev Returns the average of two signed numbers without overflow.
     * The result is rounded towards zero.
     */
    function average(int256 a, int256 b) internal pure returns (int256) {
        // Formula from the book "Hacker's Delight"
        int256 x = (a & b) + ((a ^ b) >> 1);
        return x + (int256(uint256(x) >> 255) & (a ^ b));
    }

    /**
     * @dev Returns the absolute unsigned value of a signed value.
     */
    function abs(int256 n) internal pure returns (uint256) {
        unchecked {
            // must be unchecked in order to support `n = type(int256).min`
            return uint256(n >= 0 ? n : -n);
        }
    }
}

File 25 of 36 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.8.0) (utils/structs/EnumerableSet.sol)
// This file was procedurally generated from scripts/generate/templates/EnumerableSet.js.

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.
 *
 * [WARNING]
 * ====
 * Trying to delete such a structure from storage will likely result in data corruption, rendering the structure
 * unusable.
 * See https://github.com/ethereum/solidity/pull/11843[ethereum/solidity#11843] for more info.
 *
 * In order to clean an EnumerableSet, you can either remove all elements one by one or create a fresh instance using an
 * array of EnumerableSet.
 * ====
 */
library EnumerableSet {
    // 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;

            if (lastIndex != toDeleteIndex) {
                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) {
        return set._values[index];
    }

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function _values(Set storage set) private view returns (bytes32[] memory) {
        return set._values;
    }

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {
        bytes32[] memory store = _values(set._inner);
        bytes32[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(AddressSet storage set) internal view returns (address[] memory) {
        bytes32[] memory store = _values(set._inner);
        address[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }

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

    /**
     * @dev Return the entire set in an array
     *
     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed
     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that
     * this function has an unbounded cost, and using it as part of a state-changing function may render the function
     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.
     */
    function values(UintSet storage set) internal view returns (uint256[] memory) {
        bytes32[] memory store = _values(set._inner);
        uint256[] memory result;

        /// @solidity memory-safe-assembly
        assembly {
            result := store
        }

        return result;
    }
}

File 26 of 36 : Airdropper.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {AccessControlEnumerable} from "ethier/utils/AccessControlEnumerable.sol";

/**
 * @title Proof of Conference Tickets - Airdrop module
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
abstract contract Airdropper is AccessControlEnumerable {
    // =========================================================================
    //                          Errors
    // =========================================================================

    error ExceedingAirdropLimit();

    // =========================================================================
    //                          Constants
    // =========================================================================

    /**
     * @notice The role allowed to perform airdrops.
     */
    bytes32 public constant AIRDROPPER_ROLE = keccak256("AIRDROPPER_ROLE");

    // =========================================================================
    //                          Storage
    // =========================================================================

    /**
     * @notice The number of tokens that have already been airdropped.
     */
    uint16 private _numAirdropped;

    /**
     * @notice The maximum number of airdrops.
     */
    uint16 private _maxAirdrops = 250;

    // =========================================================================
    //                          Getter/Setter
    // =========================================================================

    /**
     * @notice Returns the maximum number of airdroppable tickets.
     * @dev For testing.
     */
    function _maxNumAirdrops() internal view returns (uint16) {
        return _maxAirdrops;
    }

    /**
     * @notice Sets the maximum number of airdroppable tickets.
     */
    function setMaxNumAirdrops(uint16 maxNumAirdrops)
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        _maxAirdrops = maxNumAirdrops;
    }

    // =========================================================================
    //                          Airdrops
    // =========================================================================

    /**
     * @notice Airdrops a number of tickets to a given address.
     */
    function _doAirdrop(address to, uint256 num)
        internal
        onlyRole(AIRDROPPER_ROLE)
    {
        if (_numAirdropped + num > _maxAirdrops) {
            revert ExceedingAirdropLimit();
        }
        _numAirdropped += uint16(num);
        _mintAirdrop(to, num);
    }

    /**
     * @notice Callback that mints the airdropped tokens.
     * @dev Will be provided by `Minter`.
     */
    function _mintAirdrop(address to, uint256 num) internal virtual;
}

File 27 of 36 : DelegationChecker.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {IERC721} from "openzeppelin-contracts/token/ERC721/IERC721.sol";
import {IDelegationRegistry} from
    "delegatecash/delegation-registry/IDelegationRegistry.sol";
import {TokenRedemption} from "poc-ticket/TokenRedemption.sol";
import {PROOFTokens} from "poc-ticket/PROOFTokens.sol";

/**
 * @title Proof of Conference Tickets - PROOF NFT delegation verification module
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
contract DelegationChecker {
    // =========================================================================
    //                           Errors
    // =========================================================================

    error InvalidTokenDelegation(IERC721 token, uint256 tokenId);
    error InvalidContractDelegation(IERC721 token);
    error InvalidDelegation();
    error NoDelegation();

    // =========================================================================
    //                           Constants
    // =========================================================================

    /**
     * @notice The PROOF Collective token.
     */
    IERC721 private immutable _proof;

    /**
     * @notice The Moonbirds token.
     */
    IERC721 private immutable _moonbirds;

    /**
     * @notice The Oddities token.
     */
    IERC721 private immutable _oddities;

    /**
     * @notice The delegate.cash delegation registry.
     */
    IDelegationRegistry private immutable _delegationRegistry;

    // =========================================================================
    //                           Construction
    // =========================================================================

    constructor(
        PROOFTokens memory tokens,
        IDelegationRegistry delegationRegistry
    ) {
        _proof = tokens.proof;
        _moonbirds = tokens.moonbirds;
        _oddities = tokens.oddities;
        _delegationRegistry = delegationRegistry;
    }

    // =========================================================================
    //                           Checks
    // =========================================================================

    /**
     * @notice Checks if the delegate has sufficient delegations to redeem PoC
     * tickets using the supplied tokens.
     * @dev Reverts otherwise.
     */
    function _checkDelegation(
        address delegate,
        address delegator,
        IDelegationRegistry.DelegationType delegationType,
        TokenRedemption[] calldata pcRedemptions,
        TokenRedemption[] calldata mbRedemptions,
        TokenRedemption[] calldata oddRedemptions
    ) internal view {
        if (delegationType == IDelegationRegistry.DelegationType.ALL) {
            if (_delegationRegistry.checkDelegateForAll(delegate, delegator)) {
                return;
            }
            revert InvalidDelegation();
        }

        if (delegationType == IDelegationRegistry.DelegationType.CONTRACT) {
            if (pcRedemptions.length > 0) {
                _checkContractDelegation(delegate, delegator, _proof);
            }
            if (mbRedemptions.length > 0) {
                _checkContractDelegation(delegate, delegator, _moonbirds);
            }
            if (oddRedemptions.length > 0) {
                _checkContractDelegation(delegate, delegator, _oddities);
            }
            return;
        }

        if (delegationType == IDelegationRegistry.DelegationType.TOKEN) {
            _checkTokenDelegation(delegate, delegator, _proof, pcRedemptions);
            _checkTokenDelegation(
                delegate, delegator, _moonbirds, mbRedemptions
            );
            _checkTokenDelegation(
                delegate, delegator, _oddities, oddRedemptions
            );
            return;
        }

        revert NoDelegation();
    }

    /**
     * @notice Checks if the delegate has a contract-wide delegation for the
     * specified token if the list of redemptions is not empty.
     * @dev Reverts otherwise.
     */
    function _checkContractDelegation(
        address delegate,
        address delegator,
        IERC721 token
    ) private view {
        if (
            !_delegationRegistry.checkDelegateForContract(
                delegate, delegator, address(token)
            )
        ) {
            revert InvalidContractDelegation(token);
        }
    }

    /**
     * @notice Checks if the delegate has a token-specific delegation for the
     * redeeming tokens
     * @dev Reverts otherwise.
     */
    function _checkTokenDelegation(
        address delegate,
        address delegator,
        IERC721 token,
        TokenRedemption[] calldata redemptions
    ) private view {
        for (uint256 i; i < redemptions.length; ++i) {
            if (
                !_delegationRegistry.checkDelegateForToken(
                    delegate, delegator, address(token), redemptions[i].tokenId
                )
            ) {
                revert InvalidTokenDelegation(token, redemptions[i].tokenId);
            }
        }
    }
}

File 28 of 36 : Minter.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {ERC721ATransferRestricted} from
    "poc-ticket/TransferRestriction/ERC721ATransferRestricted.sol";

/**
 * @title Proof of Conference Tickets - Minter module
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
abstract contract Minter is ERC721ATransferRestricted {
    error UnavailableForAirdroppedTokens(uint256);

    /**
     * @dev We use this to reduce the storage requirements for the block number
     * in which the tickets have been minted.
     */
    uint256 private immutable _blockNumberOffset;

    /**
     * @notice The mixHashes at a given block number.
     * @dev Set during purchases.
     */
    mapping(uint256 => uint256) private _mixHashes;

    constructor() {
        // Subtracting 1 guarantees that `block.number - _blockNumberOffset` can
        // never be zero. Hence we can use a zero value to distingish airdropped
        // tokens.
        _blockNumberOffset = block.number - 1;
    }

    /**
     * @notice Callback to mint tokens for a purchase.
     * @dev Store the current `block.number` and `mixHash`, unlike
     * `mintAirdrop`.
     */
    function _mintPurchase(address to, uint256 num) internal {
        uint256 startTokenId = _nextTokenId();
        _mint(to, num);

        // This applies to the entire batch of `num` tokens as per ERC721A
        // default.
        _setExtraDataAt(startTokenId, uint24(block.number - _blockNumberOffset));
        _mixHashes[block.number] = block.difficulty;
    }

    /**
     * @notice Callback to mint tokens during airdrops.
     * @dev Note the difference compared to `_mintPurchase()` as `block.number`
     * and `mixHash` aren't stored.
     */
    function _mintAirdrop(address to, uint256 num) internal virtual {
        _mint(to, num);
    }

    /**
     * @notice ECR721A override to propagate the storage-hitchhiking token info
     * during transfers.
     */
    function _extraData(address, address, uint24 previousExtraData)
        internal
        view
        virtual
        override
        returns (uint24)
    {
        return previousExtraData;
    }

    /**
     * @notice Checks if a given ticket was airdropped.
     * @dev False for purchased tickets.
     */
    function _airdropped(uint256 ticketId)
        internal
        view
        virtual
        returns (bool)
    {
        return _ownershipOf(ticketId).extraData == 0;
    }

    /**
     * @notice Returns the block in which a purchased ticket has been minted.
     * @dev Reverts for airdropped tokens.
     */
    function _mintBlockNumber(uint256 ticketId)
        internal
        view
        virtual
        returns (uint256)
    {
        if (_airdropped(ticketId)) {
            revert UnavailableForAirdroppedTokens(ticketId);
        }

        return uint256(_ownershipOf(ticketId).extraData) + _blockNumberOffset;
    }

    /**
     * @notice Returns the mixHash for a given token.
     * @dev Reverts for airdropped tokens.
     */
    function _mixHashOfTicket(uint256 ticketId)
        internal
        view
        virtual
        returns (uint256)
    {
        return _mixHashes[_mintBlockNumber(ticketId)];
    }
}

File 29 of 36 : PROOFTokens.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {IERC721} from "openzeppelin-contracts/token/ERC721/IERC721.sol";

/**
 * @notice Bundle of PROOF ecosystem token addresses.
 */
struct PROOFTokens {
    IERC721 proof;
    IERC721 moonbirds;
    IERC721 oddities;
}

File 30 of 36 : PoCTicket.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {Address} from "openzeppelin-contracts/utils/Address.sol";
import {IERC721} from "openzeppelin-contracts/token/ERC721/IERC721.sol";

import {IDelegationRegistry} from
    "delegatecash/delegation-registry/IDelegationRegistry.sol";

import {ERC721ACommon, ERC721A} from "ethier/erc721/ERC721ACommon.sol";
import {BaseTokenURI} from "ethier/erc721/BaseTokenURI.sol";

import {PROOFTokens} from "poc-ticket/PROOFTokens.sol";
import {
    TokenRedemption, TokenRedemptionLib
} from "poc-ticket/TokenRedemption.sol";

import {PurchaseLimiter} from "poc-ticket/PurchaseLimiter.sol";
import {Upgrader, AccessControlEnumerable} from "poc-ticket/Upgrader.sol";
import {DelegationChecker} from "poc-ticket/DelegationChecker.sol";
import {Minter} from "poc-ticket/Minter.sol";
import {Airdropper} from "poc-ticket/Airdropper.sol";
import {UsageTracker} from "poc-ticket/UsageTracker.sol";
import {TransferRestriction} from
    "poc-ticket/TransferRestriction/ERC721ATransferRestricted.sol";

/**
 * @title Proof of Conference Tickets
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
contract PoCTicket is
    Minter,
    Airdropper,
    UsageTracker,
    PurchaseLimiter,
    Upgrader,
    DelegationChecker,
    BaseTokenURI
{
    using Address for address payable;
    using TokenRedemptionLib for TokenRedemption[];

    // =========================================================================
    //                          Errors
    // =========================================================================

    error DisallowedByCurrentStage();
    error TooManyPurchasesRequestedFromToken(
        IERC721 token, uint256 tokenId, uint256 numMax
    );
    error TokenNotOwnedByOrDelegatedToCaller(IERC721, uint256);
    error InvalidPayment(uint256 want);

    error TokenNotOwnedByVault(IERC721 token, uint256 tokenId);

    // =========================================================================
    //                           Types
    // =========================================================================

    /**
     * @notice The different stages of the ticket sale.
     * @dev Some methods are only accessible for some stages. See also the
     * `Steering` section for more information.
     * @dev The ordering is very important as each stage's permissions are a
     * strict sub set of the next stage and this is assumed when checking.
     */
    enum Stage {
        Closed,
        ProofCollective,
        Moonbirds,
        Oddities,
        GeneralAdmission
    }

    /**
     * @notice Information about a given ticket.
     * @dev Intended to interact with the dApp frontend.
     */
    struct TokenInfo {
        bool upgraded;
        bool airdropped;
        bool upgradable;
        bool upgradedFreeOfCharge;
        uint256 revealBlockNumber;
    }

    /**
     * @notice Helper struct to initialise the contract.
     * @
     */
    struct ERC721MetadataSetup {
        string name;
        string symbol;
        string baseTokenURI;
    }

    // =========================================================================
    //                           Constants
    // =========================================================================

    /**
     * @notice The PROOF Collective token.
     */
    IERC721 private immutable _proof;

    /**
     * @notice The Moonbirds token.
     */
    IERC721 private immutable _moonbirds;

    /**
     * @notice The Oddities token.
     */
    IERC721 private immutable _oddities;

    // =========================================================================
    //                           Storage
    // =========================================================================

    /**
     * @notice The current stage of the contract.
     * @dev Some methods are only accessible for some stages. See also the
     * `Steering` section for more information.
     */
    Stage public stage;

    /**
     * @notice The receiver of primary sales funds.
     */
    address payable internal _salesReceiver;

    /**
     * @notice The reduced price of a ticket for PROOF-ecosystem NFT holders.
     */
    uint128 public reducedTicketPrice;

    /**
     * @notice The price of a ticket during the general admission sale.
     */
    uint128 public fullTicketPrice;

    // =========================================================================
    //                           Constructor
    // =========================================================================

    constructor(
        address admin,
        address steerer,
        ERC721MetadataSetup memory setup,
        PROOFTokens memory tokens,
        IDelegationRegistry delegationRegistry,
        address payable salesReceiver,
        address bnSigner
    )
        ERC721ACommon(
            admin,
            steerer,
            setup.name,
            setup.symbol,
            payable(address(0xdeadface)),
            0
        )
        BaseTokenURI(setup.baseTokenURI)
        Upgrader(125, bnSigner) // 1.25 %
        DelegationChecker(tokens, delegationRegistry)
    {
        _proof = tokens.proof;
        _moonbirds = tokens.moonbirds;
        _oddities = tokens.oddities;

        fullTicketPrice = 1.5 ether;
        reducedTicketPrice = 0.75 ether;

        _salesReceiver = salesReceiver;

        _grantRole(AIRDROPPER_ROLE, steerer);
        _grantRole(PURCHASE_LIMIT_SETTER_ROLE, steerer);
        _grantRole(UPGRADER_ROLE, steerer);

        _setTransferRestriction(TransferRestriction.OnlyMint);
    }

    // =========================================================================
    //                           Metadata
    // =========================================================================

    /**
     * @notice Returns information about a given ticket.
     * @dev Intended to interact with the dApp frontend.
     */
    function tokenInfos(uint256[] calldata tokenIds)
        external
        view
        returns (TokenInfo[] memory infos)
    {
        infos = new TokenInfo[](tokenIds.length);
        for (uint256 i; i < tokenIds.length; ++i) {
            uint256 ticketId = tokenIds[i];
            bool airdropped = _airdropped(ticketId);
            infos[i] = TokenInfo({
                upgraded: upgraded(ticketId),
                airdropped: airdropped,
                upgradable: _upgradable(ticketId),
                upgradedFreeOfCharge: _upgradedFreeOfCharge(ticketId),
                revealBlockNumber: airdropped ? 0 : _revealBlockNumber(ticketId)
            });
        }
    }

    // =========================================================================
    //                           Mint
    // =========================================================================

    /**
     * @notice Interface to purchase a Proof of Conference ticket.
     * @param vault The vault address if delegation is used. Otherwise has to be
     * the caller.
     * @param delegationType The finest-grained type of delegation that is
     * applicable to all tokens that will be used for redemption.
     * @param pcRedemptions The redemptions via Proof Collective tokens
     * @param mbRedemptions The redemptions via Moonbird tokens
     * @param oddRedemptions The redemptions via Oddity tokens
     * @param numGA The number of general admission purchases.
     */
    function purchase(
        address vault,
        IDelegationRegistry.DelegationType delegationType,
        TokenRedemption[] calldata pcRedemptions,
        TokenRedemption[] calldata mbRedemptions,
        TokenRedemption[] calldata oddRedemptions,
        uint256 numGA
    ) external payable {
        // Checks

        // Checking this first to revert as early as possible in the case of a
        // race for tickets.
        uint256 num = pcRedemptions.totalNum() + mbRedemptions.totalNum()
            + oddRedemptions.totalNum() + numGA;
        _checkAndTrackPurchaseLimits(vault, num, numGA);

        _checkOwnership(vault, pcRedemptions, mbRedemptions, oddRedemptions);
        if (vault != msg.sender) {
            _checkDelegation(
                msg.sender,
                vault,
                delegationType,
                pcRedemptions,
                mbRedemptions,
                oddRedemptions
            );
        }
        if (numGA > 0 && stage != Stage.GeneralAdmission) {
            revert DisallowedByCurrentStage();
        }
        // Not checking other stages here since they are implicitly checked in
        // `purchaseCost`.

        uint256 cost =
            purchaseCost(pcRedemptions, mbRedemptions, oddRedemptions, numGA);
        if (msg.value != cost) {
            revert InvalidPayment(cost);
        }

        // Effects
        _trackTokenUsage(_proof, pcRedemptions);
        _trackTokenUsage(_moonbirds, mbRedemptions);
        _trackTokenUsage(_oddities, oddRedemptions);

        // Interactions
        _salesReceiver.sendValue(msg.value);
        _mintPurchase(msg.sender, num);
    }

    /**
     * @notice The cost for a ticket purchase.
     * @param pcRedemptions The redemptions via Proof Collective tokens
     * @param mbRedemptions The redemptions via Moonbird tokens
     * @param oddRedemptions The redemptions via Oddity tokens
     * @param numGA The number of general admission purchases.
     */
    function purchaseCost(
        TokenRedemption[] calldata pcRedemptions,
        TokenRedemption[] calldata mbRedemptions,
        TokenRedemption[] calldata oddRedemptions,
        uint256 numGA
    ) public view returns (uint256) {
        (
            uint256[] memory pcCosts,
            uint256[] memory mbCosts,
            uint256[] memory oddCosts
        ) = _costsPerTokenRedemption();

        uint256 totalCost = 0;
        totalCost += _redemptionCost(_proof, pcCosts, pcRedemptions);
        totalCost += _redemptionCost(_moonbirds, mbCosts, mbRedemptions);
        totalCost += _redemptionCost(_oddities, oddCosts, oddRedemptions);
        totalCost += numGA * fullTicketPrice;

        return totalCost;
    }

    /**
     * @notice Returns the costs for the n-th ticket purchase using a PROOF
     * ecosystem token.
     * @dev The length of the individual arrays tell how often a token can be
     * used.
     */
    function _costsPerTokenRedemption()
        internal
        view
        returns (
            uint256[] memory pcCosts,
            uint256[] memory mbCosts,
            uint256[] memory oddCosts
        )
    {
        uint256 rPrice = reducedTicketPrice;
        if (stage == Stage.ProofCollective) {
            pcCosts = new uint[](1);
            // pcCosts[0] deliberately left as 0
        }
        if (stage >= Stage.Moonbirds) {
            pcCosts = new uint[](2);
            // pcCosts[0] deliberately left as 0
            pcCosts[1] = rPrice;

            pcCosts = new uint[](2);
            pcCosts[1] = reducedTicketPrice;

            mbCosts = new uint[](2);
            mbCosts[0] = rPrice;
            mbCosts[1] = rPrice;
        }
        if (stage >= Stage.Oddities) {
            oddCosts = new uint[](1);
            oddCosts[0] = rPrice;
        }
    }

    /**
     * @notice Frontend interface to get the number of tickets that can be
     * purchased per token.
     */
    function numTicketsPerToken()
        external
        view
        returns (uint256, uint256, uint256)
    {
        (
            uint256[] memory pcCosts,
            uint256[] memory mbCosts,
            uint256[] memory oddCosts
        ) = _costsPerTokenRedemption();
        return (pcCosts.length, mbCosts.length, oddCosts.length);
    }

    /**
     * @notice Computes the cost for ticket purchases via token redemptions.
     * @param token The token contract.
     * @param costs A list of costs indexed by token usage, e.g. if purchasing
     * via a token costs 10 for the first time and 20 for second time, the list
     * would be `[10,20]`.
     * @param redemptions the list of redeeming tokens and number of
     * redemptions.
     */
    function _redemptionCost(
        IERC721 token,
        uint256[] memory costs,
        TokenRedemption[] calldata redemptions
    ) internal view returns (uint256) {
        if (redemptions.length == 0) {
            return 0;
        }

        // Validating that the tokenIDs are strictly monotonically increasing
        // guarantees that no token is supplied twice, which allows us to write
        // the rest of the view function more efficiently because we don't have
        // to track usage.
        redemptions.checkStrictlyMonotonicallyIncreasing();

        uint256 totalCost;
        for (uint256 i; i < redemptions.length; ++i) {
            uint256 costStart = numTokenUsed(token, redemptions[i].tokenId);
            uint256 costEnd = costStart + redemptions[i].num;

            if (costEnd > costs.length) {
                revert TooManyPurchasesRequestedFromToken(
                    token, redemptions[i].tokenId, costs.length
                );
            }

            for (uint256 usage = costStart; usage < costEnd; ++usage) {
                totalCost += costs[usage];
            }
        }

        return totalCost;
    }

    // =========================================================================
    //                           Steering
    // =========================================================================

    /**
     * @notice Sets the stage of the contract.
     * @dev Only callable by an admin.
     */
    function setStage(Stage stage_) external onlyRole(DEFAULT_STEERING_ROLE) {
        stage = stage_;
    }

    /**
     * @notice Sets the ticket purchase prices.
     */
    function setPurchasePrices(
        uint128 reducedTicketPrice_,
        uint128 fullTicketPrice_
    ) external onlyRole(DEFAULT_STEERING_ROLE) {
        reducedTicketPrice = reducedTicketPrice_;
        fullTicketPrice = fullTicketPrice_;
    }

    /**
     * @notice Sets the receiver of funds.
     */

    function setSalesReceiver(address payable salesReceiver)
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        _salesReceiver = salesReceiver;
    }

    /**
     * @notice Airdrops a number of tickets to a given address.
     */
    function airdrop(address to, uint256 num)
        external
        bypassTransferRestriction
    {
        _doAirdrop(to, num);
    }

    // =========================================================================
    //                           Ownership verification
    // =========================================================================

    /**
     * @notice Convenience overload to check that the given address owns the
     * tokens for all redemptions.
     */
    function _checkOwnership(
        address vault,
        TokenRedemption[] calldata pcRedemptions,
        TokenRedemption[] calldata mbRedemptions,
        TokenRedemption[] calldata oddRedemptions
    ) internal view {
        _checkOwnership(vault, _proof, pcRedemptions);
        _checkOwnership(vault, _moonbirds, mbRedemptions);
        _checkOwnership(vault, _oddities, oddRedemptions);
    }

    /**
     * @notice Checks that a given address own the redeeming tokens of a certain
     * kind.
     */
    function _checkOwnership(
        address vault,
        IERC721 token,
        TokenRedemption[] calldata redemptions
    ) internal view {
        for (uint256 i; i < redemptions.length; ++i) {
            if (token.ownerOf(redemptions[i].tokenId) != vault) {
                revert TokenNotOwnedByVault(token, redemptions[i].tokenId);
            }
        }
    }

    // =========================================================================
    //                           Upgrader Upgrades
    // =========================================================================

    /**
     * @notice Returns the receiver of the upgade sales.
     * @dev Callback required by the `Upgrader`.
     */
    function _upgradeSalesReceiver()
        internal
        view
        virtual
        override(Upgrader)
        returns (address payable)
    {
        return _salesReceiver;
    }

    /**
     * @notice Returns the maximum number of upgradable tokens.
     */
    function _maxUpgradesSellable()
        internal
        view
        virtual
        override
        returns (uint256)
    {
        if (stage == Stage.ProofCollective) {
            return 400;
        }
        if (stage == Stage.Moonbirds) {
            return 700;
        }
        if (stage == Stage.Oddities || stage == Stage.GeneralAdmission) {
            return 800;
        }

        return 0;
    }

    /**
     * @notice Returns the number of the block that is used to derive the
     * salt for the randomised upgrade of a given ticket.
     */
    function _revealBlockNumber(uint256 ticketId)
        internal
        view
        override
        returns (uint256)
    {
        return _mintBlockNumber(ticketId) + 1;
    }

    // =========================================================================
    //                           Internals
    // =========================================================================

    /**
     * @dev Inheritance resolution.
     */
    function _baseURI()
        internal
        view
        virtual
        override(ERC721A, BaseTokenURI)
        returns (string memory)
    {
        return BaseTokenURI._baseURI();
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(ERC721ACommon, AccessControlEnumerable, Upgrader)
        returns (bool)
    {
        return ERC721ACommon.supportsInterface(interfaceId);
        // Deliberately ignoring AccessControlEnumerable and Upgrader here to
        // safe contract bytecode since they wont add any information.
    }

    function _airdropped(uint256 ticketId)
        internal
        view
        override(Minter, Upgrader)
        returns (bool)
    {
        return Minter._airdropped(ticketId);
    }

    function _mixHashOfTicket(uint256 ticketId)
        internal
        view
        override(Minter, Upgrader)
        returns (uint256)
    {
        return Minter._mixHashOfTicket(ticketId);
    }

    function _exists(uint256 tokenId)
        internal
        view
        virtual
        override(ERC721A, Upgrader)
        returns (bool)
    {
        return ERC721A._exists(tokenId);
    }

    function _mintAirdrop(address to, uint256 num)
        internal
        virtual
        override(Minter, Airdropper)
    {
        Minter._mintAirdrop(to, num);
    }
}

File 31 of 36 : PurchaseLimiter.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {AccessControlEnumerable} from "ethier/utils/AccessControlEnumerable.sol";

struct PurchaseCountsAndLimits {
    uint16 total;
    uint16 totalLimit;
    uint16 generalAdmission;
    uint16 generalAdmissionLimit;
}

/**
 * @title Proof of Conference Tickets - Purchase limit by wallet module
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
contract PurchaseLimiter is AccessControlEnumerable {
    // =========================================================================
    //                           Errors
    // =========================================================================

    error ExceedingAvailableTokens();
    error ExceedingPurchaseLimit();
    error ExceedingGeneralAdmissionPurchaseLimit();

    // =========================================================================
    //                           Constants
    // =========================================================================

    /**
     * @notice The role allowed to change the purchase limits for a given
     * wallet.
     */
    bytes32 public constant PURCHASE_LIMIT_SETTER_ROLE =
        keccak256("PURCHASE_LIMIT_SETTER_ROLE");

    // =========================================================================
    //                           Storage
    // =========================================================================

    /**
     * @notice The number of tickets sold.
     */
    uint16 private _numTicketsSold;

    /**
     * @notice The the number of sellable tickets.
     */
    uint16 private _numTicketsSellable = 4000;

    /**
     * @notice The default total purchase limit for each wallet.
     */
    uint16 private _defaultTotalPurchaseLimit = 10;

    /**
     * @notice The default purchase limit through the general admission sale.
     */
    uint16 private _defaultGeneralAdmissionPurchaseLimit = 2;

    /**
     * @notice Purchase counts and explicit purchase limits by wallet.
     */
    mapping(address => PurchaseCountsAndLimits) private _countsAndLimits;

    // =========================================================================
    //                           Getters
    // =========================================================================

    /**
     * @notice Returns the current number of purchases and limits for a given
     * wallet.
     */
    function purchaseCountsAndLimits(address wallet)
        public
        view
        returns (PurchaseCountsAndLimits memory)
    {
        PurchaseCountsAndLimits memory cl = _countsAndLimits[wallet];
        if (cl.totalLimit == 0) {
            cl.totalLimit = _defaultTotalPurchaseLimit;
        }
        if (cl.generalAdmissionLimit == 0) {
            cl.generalAdmissionLimit = _defaultGeneralAdmissionPurchaseLimit;
        }
        return cl;
    }

    /**
     * @notice The number of tickets that have already been sold.
     */
    function numTicketsSold() external view returns (uint256) {
        return _numTicketsSold;
    }

    /**
     * @notice The total number of tickets that can been sold.
     */
    function numTicketsSellable() external view returns (uint256) {
        return _numTicketsSellable;
    }

    /**
     * @notice Returns the total purchase limit used as default if explicit no
     * limit was set for a given wallet.
     */
    function _defaultTotalLimit() internal view returns (uint16) {
        return _defaultTotalPurchaseLimit;
    }

    /**
     * @notice Returns the general admission purchase limit used as default if
     * no explicit limit was set for a given wallet.
     */
    function _defaultGeneralAdmissionLimit() internal view returns (uint16) {
        return _defaultGeneralAdmissionPurchaseLimit;
    }

    // =========================================================================
    //                           Steering
    // =========================================================================

    /**
     * @notice Sets the number of sellable tickets.
     */
    function setNumTicketsSellable(uint16 numSellable)
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        _numTicketsSellable = numSellable;
    }

    /**
     * @notice Sets the default purchase limits.
     */
    function setDefaultPurchaseLimits(
        uint16 totalLimit,
        uint16 generalAdmissionLimit
    ) external onlyRole(DEFAULT_STEERING_ROLE) {
        _defaultTotalPurchaseLimit = totalLimit;
        _defaultGeneralAdmissionPurchaseLimit = generalAdmissionLimit;
    }

    /**
     * @notice Sets explicit purchase limits for a given wallet.
     */
    function setPurchaseLimits(
        address wallet,
        uint16 totalLimit,
        uint16 generalAdmissionLimit
    ) external onlyRole(PURCHASE_LIMIT_SETTER_ROLE) {
        PurchaseCountsAndLimits storage cl = _countsAndLimits[wallet];
        cl.totalLimit = totalLimit;
        cl.generalAdmissionLimit = generalAdmissionLimit;
    }

    // =========================================================================
    //                           Internals
    // =========================================================================

    /**
     * @notice Checks if a given buyer is allowed to purchase a given number of
     * tokens and tracks them.
     */
    function _checkAndTrackPurchaseLimits(
        address buyer,
        uint256 numTotal,
        uint256 numGA
    ) internal virtual {
        if (_numTicketsSold + numTotal > _numTicketsSellable) {
            revert ExceedingAvailableTokens();
        }

        PurchaseCountsAndLimits memory countsAndLimits =
            purchaseCountsAndLimits(buyer);
        if (countsAndLimits.total + numTotal > countsAndLimits.totalLimit) {
            revert ExceedingPurchaseLimit();
        }
        if (
            countsAndLimits.generalAdmission + numGA
                > countsAndLimits.generalAdmissionLimit
        ) {
            revert ExceedingGeneralAdmissionPurchaseLimit();
        }

        _numTicketsSold += uint16(numTotal);
        _countsAndLimits[buyer].total += uint16(numTotal);
        _countsAndLimits[buyer].generalAdmission += uint16(numGA);
    }
}

File 32 of 36 : TokenRedemption.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

/**
 * @notice Encoding a redemption via a token.
 */
struct TokenRedemption {
    // The tokenId used for purchasing a ticket
    uint256 tokenId;
    // The number of tickets requested.
    uint256 num;
}

/**
 * @notice Utility library to work with `TokenRedemption`s.
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
library TokenRedemptionLib {
    error InvalidTokenOrder();

    /**
     * @notice Computes the total number of redemptions from a list of
     * `TokenRedemptions`.
     */
    function totalNum(TokenRedemption[] calldata redemptions)
        internal
        pure
        returns (uint256)
    {
        uint256 num;
        for (uint256 j; j < redemptions.length; ++j) {
            num += redemptions[j].num;
        }
        return num;
    }

    /**
     * @notice Checks if the tokenIds in a list of `TokenRedemptions` is
     * strictly monotonically increasing.
     * @dev Reverts otherwise
     */

    function checkStrictlyMonotonicallyIncreasing(
        TokenRedemption[] calldata redemptions
    ) internal pure {
        if (redemptions.length < 2) {
            return;
        }

        for (uint256 i = 0; i < redemptions.length - 1; ++i) {
            if (redemptions[i].tokenId >= redemptions[i + 1].tokenId) {
                revert InvalidTokenOrder();
            }
        }
    }
}

File 33 of 36 : ERC721ATransferRestricted.sol
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.16 <0.9.0;

import {
    ERC721ATransferRestrictedBase,
    TransferRestriction
} from "./ERC721ATransferRestrictedBase.sol";

/**
 * @notice Extension of ERC721 transfer restrictions with manual restriction
 * setter.
 */
abstract contract ERC721ATransferRestricted is ERC721ATransferRestrictedBase {
    // =========================================================================
    //                           Error
    // =========================================================================

    error TransferRestrictionLocked();
    error TransferRestrictionCheckFailed(TransferRestriction want);

    // =========================================================================
    //                           Storage
    // =========================================================================

    /**
     * @notice The current restrictions.
     */
    TransferRestriction private _transferRestriction;

    /**
     * @notice Flag to lock in the current transfer restriction.
     */
    bool private _locked;

    // =========================================================================
    //                           Steering
    // =========================================================================

    /**
     * @notice Sets the transfer restrictions.
     */
    function _setTransferRestriction(TransferRestriction restriction)
        internal
        virtual
    {
        _transferRestriction = restriction;
    }

    /**
     * @notice Sets the transfer restrictions.
     * @dev Only callable by a contract steerer.
     */
    function setTransferRestriction(TransferRestriction restriction)
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        if (_locked) {
            revert TransferRestrictionLocked();
        }

        _setTransferRestriction(restriction);
    }

    /**
     * @notice Locks the current transfer restrictions.
     * @dev Only callable by a contract steerer.
     * @param restriction must match the current transfer restriction as
     * additional security measure.
     */
    function lockTransferRestriction(TransferRestriction restriction)
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        if (restriction != _transferRestriction) {
            revert TransferRestrictionCheckFailed(_transferRestriction);
        }

        _locked = true;
    }

    /**
     * @notice Returns the stored transfer restrictions.
     */
    function transferRestriction()
        public
        view
        virtual
        override
        returns (TransferRestriction)
    {
        return _transferRestriction;
    }
}

File 34 of 36 : ERC721ATransferRestrictedBase.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {ERC721ACommon} from "ethier/contracts/erc721/ERC721ACommon.sol";

/**
 * @notice Possible transfer restrictions.
 */
enum TransferRestriction {
    None,
    OnlyMint,
    OnlyBurn,
    Frozen
}

/**
 * @notice Implements restrictions for ERC721 transfers.
 * @dev This is intended to facilitate a soft expiry for voucher tokens, having
 * an intermediate stage that still allows voucher to be redeemed but not traded
 * before closing all activity indefinitely.
 * @dev The activation of restrictions is left to the extending contract.
 */
abstract contract ERC721ATransferRestrictedBase is ERC721ACommon {
    // =========================================================================
    //                           Errors
    // =========================================================================

    /**
     * @notice Thrown if an action is disallowed by the current transfer
     * restriction.
     */
    error DisallowedByTransferRestriction();

    // =========================================================================
    //                           Errors
    // =========================================================================

    /**
     * @notice Flag to bypass the current transfer restriction.
     */
    bool private _bypass;

    // =========================================================================
    //                           Transfer Restriction
    // =========================================================================

    /**
     * @notice Returns the current transfer restriction.
     * @dev Hook to be implemented by the consuming contract (e.g. manual
     * setter, time based, etc.)
     */
    function transferRestriction()
        public
        view
        virtual
        returns (TransferRestriction);

    /**
     * @notice Modifier that allows functions to bypass the transfer
     * restriction.
     */
    modifier bypassTransferRestriction() {
        _bypass = true;
        _;
        _bypass = false;
    }

    // =========================================================================
    //                           Internals
    // =========================================================================

    /**
     * @notice Blocks transfers depending on the current restrictions.
     */
    function _beforeTokenTransfers(
        address from,
        address to,
        uint256 startTokenId,
        uint256 quantity
    ) internal virtual override {
        super._beforeTokenTransfers(from, to, startTokenId, quantity);

        if (_bypass) {
            return;
        }

        TransferRestriction restriction = transferRestriction();
        if (restriction == TransferRestriction.None) {
            return;
        }
        if (restriction == TransferRestriction.OnlyMint && from == address(0)) {
            return;
        }
        if (restriction == TransferRestriction.OnlyBurn && to == address(0)) {
            return;
        }

        revert DisallowedByTransferRestriction();
    }

    // =========================================================================
    //                           Approvals
    // =========================================================================

    /**
     * @dev This returns false if all transfers are disabled to indicate to
     * marketplaces that these tokens cannot be sold and should therefore not be
     * listed.
     */
    function isApprovedForAll(address owner_, address operator)
        public
        view
        virtual
        override
        returns (bool)
    {
        if (!_bypass && transferRestriction() != TransferRestriction.None) {
            return false;
        }

        return super.isApprovedForAll(owner_, operator);
    }

    /**
     * @notice Reverts if all transfers are disabled to prevent users from
     * approving marketplaces even though the tokens can't be traded.
     */
    function setApprovalForAll(address operator, bool toggle)
        public
        virtual
        override
    {
        if (!_bypass && transferRestriction() != TransferRestriction.None) {
            revert DisallowedByTransferRestriction();
        }

        return super.setApprovalForAll(operator, toggle);
    }

    /**
     * @notice Reverts if all transfers are disabled to prevent users from
     * approving marketplaces even though the tokens can't be traded.
     */
    function approve(address operator, uint256 tokenId)
        public
        payable
        virtual
        override
    {
        if (!_bypass && transferRestriction() != TransferRestriction.None) {
            revert DisallowedByTransferRestriction();
        }

        return super.approve(operator, tokenId);
    }
}

File 35 of 36 : Upgrader.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {Address} from "openzeppelin-contracts/utils/Address.sol";
import {ECDSA} from "openzeppelin-contracts/utils/cryptography/ECDSA.sol";
import {AccessControlEnumerable} from "ethier/utils/AccessControlEnumerable.sol";
import {ERC4906} from "ethier/erc721/ERC4906.sol";

/**
 * @notice PROOF-issued signatures of block numbers.
 */
struct SignedBlockNumber {
    uint256 blockNumber;
    bytes signature;
}

interface UpgraderEvents {
    event TicketUpgraded(address indexed by, uint256 indexed ticketId);
}

/**
 * @title Proof of Conference Tickets - VIP Upgrades module.
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
abstract contract Upgrader is
    UpgraderEvents,
    AccessControlEnumerable,
    ERC4906
{
    using Address for address payable;
    using ECDSA for bytes;
    using ECDSA for bytes32;

    // =========================================================================
    //                           Errors
    // =========================================================================

    error ExceedingAvailableUpgrades();
    error InvalidPaymentForUpgrade(uint256 want);
    error TicketNotEligibleForUpgrade(uint256);
    error TicketAlreadyUpgraded(uint256);
    error TicketDoesNotExist(uint256);
    error IncorrectSigner();
    error CurrentlyDisabled();

    // =========================================================================
    //                           Constants
    // =========================================================================

    /**
     * @notice The role allowed to perform manual upgrades.
     */
    bytes32 public constant UPGRADER_ROLE = keccak256("UPGRADER_ROLE");

    /**
     * @notice Unity in fixed-point arithmetic with a 64bit decimal point.
     */
    uint256 private constant _ONE = 1 << 64;

    /**
     * @notice The probability for a free upgrade to VIP.
     * @dev Given as a 256x64bit fixed-point number.
     */
    uint256 private immutable _freeUpgradeProbability;

    // =========================================================================
    //                           Storage
    // =========================================================================

    /**
     * @notice Flag to enable the upgrades purchase.
     */
    bool private _upgradesPurchaseOpen;

    /**
     * @notice Flag to enable the publishing of block salts to lock in random
     * upgrades.
     */
    bool private _blockSaltPublishingOpen;

    /**
     * @notice The number of upgrades sold.
     */
    uint16 private _numUpgradesSold;

    /**
     * @notice The price to purchase a VIP upgrade.
     */
    uint128 private _upgradePrice;

    /**
     * @notice The address of the PROOF-owned backend to provide salt for the
     * free upgrades randomisation.
     */
    address private _bnSigner;

    /**
     * @notice Stores purchased upgrades.
     */
    mapping(uint256 => bool) private _upgraded;

    /**
     * @notice Stores PROOF-issued salt for the free upgrades randomisation.
     */
    mapping(uint256 => bytes32) private _salts;

    // =========================================================================
    //                           Constructor
    // =========================================================================

    /**
     * @param freeUpgradeProbabilityBasePoints_ the probability to randomly get
     * a free VIP upgrade in basis points (i.e. 1/10k).
     */
    constructor(uint256 freeUpgradeProbabilityBasePoints_, address bnSigner_) {
        _upgradesPurchaseOpen = true;
        _blockSaltPublishingOpen = true;

        _upgradePrice = 0.5 ether;

        _freeUpgradeProbability =
            (freeUpgradeProbabilityBasePoints_ * _ONE) / 10_000;
        _bnSigner = bnSigner_;
    }

    // =========================================================================
    //                           Metadata
    // =========================================================================

    /**
     * @notice Returns if a ticket is upgraded to VIP.
     * @dev Includes both bought and randomly won upgrades.
     */
    function upgraded(uint256 ticketId) public view returns (bool) {
        return _upgraded[ticketId] || _hasFreeUpgrade(ticketId);
    }

    /**
     * @notice Returns if a ticket is upgradable to VIP.
     * @dev Excludes already upgraded, airdropped and inexistant tickets.
     */
    function _upgradable(uint256 ticketId) internal view returns (bool) {
        return !upgraded(ticketId) && !_airdropped(ticketId);
    }

    // =========================================================================
    //                           Purchase Upgrades
    // =========================================================================

    /**
     * @notice Purchases VIP upgrades for a list of tickets.
     * @dev Ticket ownership is not verified. Reverts if a ticket was already
     * upgraded.
     */
    function purchaseUpgrade(uint256[] calldata ticketIds)
        external
        payable
        onlyIf(_upgradesPurchaseOpen)
    {
        uint256 numUpgrades = ticketIds.length;
        // Checking this first to revert as early as possible in the case of a
        // race for tickets.
        if (_numUpgradesSold + numUpgrades > _maxUpgradesSellable()) {
            revert ExceedingAvailableUpgrades();
        }

        uint256 wantValue = numUpgrades * _upgradePrice;
        if (msg.value != wantValue) {
            revert InvalidPaymentForUpgrade(wantValue);
        }

        for (uint256 i; i < numUpgrades; ++i) {
            _doPurchaseUpgrade(ticketIds[i]);
        }
        _numUpgradesSold += uint16(numUpgrades);

        _upgradeSalesReceiver().sendValue(msg.value);
    }

    /**
     * @notice Performs the purchase of an upgrade for a given ticket.
     * @dev Reverts if the given ticket is not eligible for an upgrade according
     * to `_upgradable`.
     */
    function _doPurchaseUpgrade(uint256 ticketId) private {
        // We deliberately don't use `_upgradable` here to provide more context
        // by reverting with different errors depening on the violation.
        if (_airdropped(ticketId)) {
            revert TicketNotEligibleForUpgrade(ticketId);
        }
        _doUpgrade(ticketId);
    }

    /**
     * @notice Returns the price to purchase an upgrade.
     */
    function upgradePrice() external view returns (uint128) {
        return _upgradePrice;
    }

    /**
     * @notice Returns the number of sold VIP upgrades.
     */
    function numUpgradesSold() external view returns (uint256) {
        return _numUpgradesSold;
    }

    /**
     * @notice Returns the maximum number of upgrades that will be sold.
     */
    function maxUpgradesSellable() external view returns (uint256) {
        return _maxUpgradesSellable();
    }

    /**
     * @notice Returns flag to indicate if the upgrades purchase is enabled.
     */
    function upgradesPurchaseOpen() external view returns (bool) {
        return _upgradesPurchaseOpen;
    }

    // =========================================================================
    //                           Owner Upgrades
    // =========================================================================

    /**
     * @notice Manually upgrades a list of tickets to VIP.
     * @dev This bypasses the number of upgradable tickets.
     */
    function upgrade(uint256[] calldata ticketIds)
        external
        onlyRole(UPGRADER_ROLE)
    {
        for (uint256 i; i < ticketIds.length; ++i) {
            _doUpgrade(ticketIds[i]);
        }
    }

    /**
     * @notice Upgrades a ticket to VIP.
     * @dev Reverts if the ticket was already upgraded or does not exist.
     */
    function _doUpgrade(uint256 ticketId) private {
        if (upgraded(ticketId)) {
            revert TicketAlreadyUpgraded(ticketId);
        }
        if (!_exists(ticketId)) {
            revert TicketDoesNotExist(ticketId);
        }

        _upgraded[ticketId] = true;
        emit TicketUpgraded(msg.sender, ticketId);
        emit MetadataUpdate(ticketId);
    }

    // =========================================================================
    //                           Publishing block salts
    // =========================================================================

    /**
     * @notice Stores PROOF-issued block number signatures and locks in randomly
     * assigned free upgrades in the process.
     */
    function publishBlockSalts(SignedBlockNumber[] calldata bns)
        external
        onlyIf(_blockSaltPublishingOpen)
    {
        for (uint256 i; i < bns.length; ++i) {
            _publishBlockSalt(bns[i].blockNumber, bns[i].signature);
        }

        // Publishing block salts locks in randomised upgrades for certain
        // tickets. Since we do not keep book over the tokens that will be
        // affected we would need to trigger a collection-wide metadata refresh
        // to inform marketplaces. This can be abused because one can call this
        // method by only paying gas, which might result in rate limiting. So we
        // refrain from emitting a corresponding ERC4906 event here and emit
        // it manually on a daily basis.
    }

    /**
     * @notice Stores a PROOF-issued block number signature and locks in
     * randomly assigned free upgrades in the process.
     * @dev Reverts if the message or signer is incorrect.
     */
    function _publishBlockSalt(uint256 blockNumber, bytes calldata signature)
        private
    {
        // Already published. Reverting early in the case of multiple user
        // submissions.
        if (_salts[blockNumber] != 0) {
            return;
        }

        if (
            abi.encode(blockNumber, block.chainid).toEthSignedMessageHash()
                .recover(signature) != _bnSigner
        ) {
            revert IncorrectSigner();
        }

        _salts[blockNumber] = keccak256(signature);
    }

    /**
     * @notice Returns the salt for a given block number.
     * @dev Returns zero if nothing has been stored yet.
     */
    function _salt(uint256 blockNumber)
        internal
        view
        virtual
        returns (bytes32)
    {
        return _salts[blockNumber];
    }

    /**
     * @notice Returns flag to indicate if the interface to publish block salts
     * is enabled.
     */
    function blockSaltPublishingOpen() external view returns (bool) {
        return _blockSaltPublishingOpen;
    }

    // =========================================================================
    //                           Random Free Upgrades
    // =========================================================================

    /**
     * @notice Checks if a ticket is upgradable free of charge using a given
     * signature.
     * @dev This method is external because we will exclusively use it to inform
     * the frontend that a given signature unlocks the free upgrade for a token.
     * The eligibility does not need to be verified on the contract because the
     * upgrades are derived on-the-fly from the stored salts, effectively
     * reproducing what is checked here.
     * Once the salt for a revealBlockNumber of a given ticket was stored, this
     * function will return false since the ticket was already upgraded.
     * @param signature The signature of the revealing block number associated
     * to the ticket issued by PROOF.
     */
    function upgradableFreeOfCharge(uint256 ticketId, bytes calldata signature)
        external
        view
        returns (bool)
    {
        if (
            abi.encode(_revealBlockNumber(ticketId), block.chainid)
                .toEthSignedMessageHash().recover(signature) != _bnSigner
        ) {
            revert IncorrectSigner();
        }

        return !_upgraded[ticketId]
            && _isRandomlyUpgradedBy(ticketId, keccak256(signature))
            && _salts[_revealBlockNumber(ticketId)] == 0;
    }

    /**
     * @notice Checks if a given ticket was upgraded via the random lottery.
     */
    function _upgradedFreeOfCharge(uint256 ticketId)
        internal
        view
        returns (bool)
    {
        return !_upgraded[ticketId] && !_airdropped(ticketId)
            && _hasFreeUpgrade(ticketId);
    }

    /**
     * @notice Checks if a ticket is randomly upgraded using a provided salt.
     */
    function _isRandomlyUpgradedBy(uint256 ticketId, bytes32 salt)
        private
        view
        returns (bool)
    {
        bytes32 rand = keccak256(
            abi.encodePacked(salt, _mixHashOfTicket(ticketId), ticketId)
        );
        return uint256(rand) % _ONE < _freeUpgradeProbability;
    }

    /**
     * @notice Checks if a ticket is randomly upgraded using the stored salt.
     */
    function _hasFreeUpgrade(uint256 ticketId) internal view returns (bool) {
        if (_airdropped(ticketId)) {
            return false;
        }

        bytes32 salt = _salts[_revealBlockNumber(ticketId)];
        if (salt == 0) {
            return false;
        }

        return _isRandomlyUpgradedBy(ticketId, salt);
    }

    // =========================================================================
    //                           Steering
    // =========================================================================

    /**
     * @notice Sets the PROOF-owned blocknumber signer.
     */
    function setBNSigner(address signer)
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        _bnSigner = signer;
    }

    /**
     * @notice Sets the price to purchase a VIP upgrade.
     */
    function setUpgradePrice(uint128 price)
        external
        onlyRole(DEFAULT_STEERING_ROLE)
    {
        _upgradePrice = price;
    }

    /**
     * @notice Enables or disables the upgrades purchase and salt publishing
     * functions.
     */
    function setUpgradesOpen(
        bool upgradesPurchaseOpen_,
        bool blockSaltPublishingOpen_
    ) external onlyRole(DEFAULT_STEERING_ROLE) {
        _upgradesPurchaseOpen = upgradesPurchaseOpen_;
        _blockSaltPublishingOpen = blockSaltPublishingOpen_;
    }

    // =========================================================================
    //                           Internal
    // =========================================================================

    /**
     * @notice Makes a function only executable if a given flag is true.
     */
    modifier onlyIf(bool activationFlag) {
        if (!activationFlag) {
            revert CurrentlyDisabled();
        }
        _;
    }

    /// @notice Overrides supportsInterface as required by inheritance.
    function supportsInterface(bytes4 interfaceId)
        public
        view
        virtual
        override(AccessControlEnumerable, ERC4906)
        returns (bool)
    {
        return AccessControlEnumerable.supportsInterface(interfaceId)
            || ERC4906.supportsInterface(interfaceId);
    }

    // =========================================================================
    //                           Interfacing
    // =========================================================================

    /**
     * @notice Returns the mixHash for a given block number.
     * @dev Will be provided by `Minter`.
     */
    function _mixHashOfTicket(uint256 ticketId)
        internal
        view
        virtual
        returns (uint256);

    /**
     * @notice Returns if the given ticket was airdropped.
     * @dev Will be provided by `Minter`.
     */
    function _airdropped(uint256 ticketId)
        internal
        view
        virtual
        returns (bool);

    /**
     * @notice Returns the block number that is used to derive the salt.
     * @dev Will be provided by `PoCTicket`.
     */
    function _revealBlockNumber(uint256 ticketId)
        internal
        view
        virtual
        returns (uint256);

    /**
     * @notice Returns the reveicer of the upgrades proceeds.
     * @dev Will be provided by `PoCTicket`.
     */
    function _upgradeSalesReceiver()
        internal
        view
        virtual
        returns (address payable);

    /**
     * @notice Returns the maximum number of sellable upgrades.
     * @dev Depends on stage. Will be provided by `PoCTicket`.
     */
    function _maxUpgradesSellable() internal view virtual returns (uint256);

    /**
     * @notice Returns if the given ticket exists.
     */
    function _exists(uint256 ticketId) internal view virtual returns (bool);
}

File 36 of 36 : UsageTracker.sol
// SPDX-License-Identifier: MIT
// Copyright 2023 PROOF Holdings Inc
pragma solidity >=0.8.16 <0.9.0;

import {Address} from "openzeppelin-contracts/utils/Address.sol";
import {IERC721} from "openzeppelin-contracts/token/ERC721/IERC721.sol";
import {TokenRedemption} from "poc-ticket/TokenRedemption.sol";

/**
 * @title Proof of Conference Tickets - PROOF token usage tracker (for ticket
 * purchases)
 * @author Dave (@cxkoda)
 * @author KRO's kid
 * @custom:reviewer Arran (@divergencearran)
 */
contract UsageTracker {
    mapping(IERC721 => mapping(uint256 => uint256)) private _numTokenUsed;

    function _trackTokenUsage(
        IERC721 token,
        TokenRedemption[] calldata redemptions
    ) internal {
        for (uint256 i; i < redemptions.length; ++i) {
            _numTokenUsed[token][redemptions[i].tokenId] += redemptions[i].num;
        }
    }

    /**
     * @notice Checks how often a given token was used to redeem a ticket.
     */
    function numTokenUsed(IERC721 token, uint256 tokenId)
        public
        view
        returns (uint256)
    {
        return _numTokenUsed[token][tokenId];
    }
}

Settings
{
  "remappings": [
    "@divergencetech/ethier/=lib/ethier/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "ERC721A/=lib/ERC721A/contracts/",
    "delegatecash/delegation-registry/=lib/delegation-registry/src/",
    "delegation-registry/=lib/delegation-registry/src/",
    "ds-test/=lib/forge-std/lib/ds-test/src/",
    "erc4626-tests/=lib/openzeppelin-contracts/lib/erc4626-tests/",
    "erc721a/=lib/ERC721A/",
    "ethier/=lib/ethier/contracts/",
    "ethier/contracts/=lib/ethier/contracts/",
    "forge-std/=lib/forge-std/src/",
    "grails/season-03/test/=../grails/season-03/test/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/contracts/",
    "openzeppelin-contracts/contracts/=lib/openzeppelin-contracts/contracts/",
    "poc-ticket/=src/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 5000
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"address","name":"admin","type":"address"},{"internalType":"address","name":"steerer","type":"address"},{"components":[{"internalType":"string","name":"name","type":"string"},{"internalType":"string","name":"symbol","type":"string"},{"internalType":"string","name":"baseTokenURI","type":"string"}],"internalType":"struct PoCTicket.ERC721MetadataSetup","name":"setup","type":"tuple"},{"components":[{"internalType":"contract IERC721","name":"proof","type":"address"},{"internalType":"contract IERC721","name":"moonbirds","type":"address"},{"internalType":"contract IERC721","name":"oddities","type":"address"}],"internalType":"struct PROOFTokens","name":"tokens","type":"tuple"},{"internalType":"contract IDelegationRegistry","name":"delegationRegistry","type":"address"},{"internalType":"address payable","name":"salesReceiver","type":"address"},{"internalType":"address","name":"bnSigner","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"CurrentlyDisabled","type":"error"},{"inputs":[],"name":"DisallowedByCurrentStage","type":"error"},{"inputs":[],"name":"DisallowedByTransferRestriction","type":"error"},{"inputs":[],"name":"ExceedingAirdropLimit","type":"error"},{"inputs":[],"name":"ExceedingAvailableTokens","type":"error"},{"inputs":[],"name":"ExceedingAvailableUpgrades","type":"error"},{"inputs":[],"name":"ExceedingGeneralAdmissionPurchaseLimit","type":"error"},{"inputs":[],"name":"ExceedingPurchaseLimit","type":"error"},{"inputs":[],"name":"IncorrectSigner","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"}],"name":"InvalidContractDelegation","type":"error"},{"inputs":[],"name":"InvalidDelegation","type":"error"},{"inputs":[{"internalType":"uint256","name":"want","type":"uint256"}],"name":"InvalidPayment","type":"error"},{"inputs":[{"internalType":"uint256","name":"want","type":"uint256"}],"name":"InvalidPaymentForUpgrade","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"InvalidTokenDelegation","type":"error"},{"inputs":[],"name":"InvalidTokenOrder","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"NoDelegation","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"TicketAlreadyUpgraded","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"TicketDoesNotExist","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"TicketNotEligibleForUpgrade","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"}],"name":"TokenNotOwnedByOrDelegatedToCaller","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"TokenNotOwnedByVault","type":"error"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"numMax","type":"uint256"}],"name":"TooManyPurchasesRequestedFromToken","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[{"internalType":"enum TransferRestriction","name":"want","type":"uint8"}],"name":"TransferRestrictionCheckFailed","type":"error"},{"inputs":[],"name":"TransferRestrictionLocked","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[{"internalType":"uint256","name":"","type":"uint256"}],"name":"UnavailableForAirdroppedTokens","type":"error"},{"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":"uint256","name":"_fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"_toTokenId","type":"uint256"}],"name":"BatchMetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"fromTokenId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"toTokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"}],"name":"ConsecutiveTransfer","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint256","name":"_tokenId","type":"uint256"}],"name":"MetadataUpdate","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"account","type":"address"}],"name":"Paused","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"by","type":"address"},{"indexed":true,"internalType":"uint256","name":"ticketId","type":"uint256"}],"name":"TicketUpgraded","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":false,"internalType":"address","name":"account","type":"address"}],"name":"Unpaused","type":"event"},{"inputs":[],"name":"AIRDROPPER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_STEERING_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"PURCHASE_LIMIT_SETTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"UPGRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256","name":"num","type":"uint256"}],"name":"airdrop","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"approve","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"balanceOf","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"baseTokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"blockSaltPublishingOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"emitMetadataUpdateForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"fullTicketPrice","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"getApproved","outputs":[{"internalType":"address","name":"","type":"address"}],"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":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner_","type":"address"},{"internalType":"address","name":"operator","type":"address"}],"name":"isApprovedForAll","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"enum TransferRestriction","name":"restriction","type":"uint8"}],"name":"lockTransferRestriction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"maxUpgradesSellable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numTicketsPerToken","outputs":[{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numTicketsSellable","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numTicketsSold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"contract IERC721","name":"token","type":"address"},{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"numTokenUsed","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"numUpgradesSold","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"components":[{"internalType":"uint256","name":"blockNumber","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"internalType":"struct SignedBlockNumber[]","name":"bns","type":"tuple[]"}],"name":"publishBlockSalts","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"vault","type":"address"},{"internalType":"enum IDelegationRegistry.DelegationType","name":"delegationType","type":"uint8"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"num","type":"uint256"}],"internalType":"struct TokenRedemption[]","name":"pcRedemptions","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"num","type":"uint256"}],"internalType":"struct TokenRedemption[]","name":"mbRedemptions","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"num","type":"uint256"}],"internalType":"struct TokenRedemption[]","name":"oddRedemptions","type":"tuple[]"},{"internalType":"uint256","name":"numGA","type":"uint256"}],"name":"purchase","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"num","type":"uint256"}],"internalType":"struct TokenRedemption[]","name":"pcRedemptions","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"num","type":"uint256"}],"internalType":"struct TokenRedemption[]","name":"mbRedemptions","type":"tuple[]"},{"components":[{"internalType":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"num","type":"uint256"}],"internalType":"struct TokenRedemption[]","name":"oddRedemptions","type":"tuple[]"},{"internalType":"uint256","name":"numGA","type":"uint256"}],"name":"purchaseCost","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"}],"name":"purchaseCountsAndLimits","outputs":[{"components":[{"internalType":"uint16","name":"total","type":"uint16"},{"internalType":"uint16","name":"totalLimit","type":"uint16"},{"internalType":"uint16","name":"generalAdmission","type":"uint16"},{"internalType":"uint16","name":"generalAdmissionLimit","type":"uint16"}],"internalType":"struct PurchaseCountsAndLimits","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ticketIds","type":"uint256[]"}],"name":"purchaseUpgrade","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"reducedTicketPrice","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"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":"uint256","name":"tokenId","type":"uint256"},{"internalType":"uint256","name":"salePrice","type":"uint256"}],"name":"royaltyInfo","outputs":[{"internalType":"address","name":"","type":"address"},{"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":"safeTransferFrom","outputs":[],"stateMutability":"payable","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":"payable","type":"function"},{"inputs":[{"internalType":"address","name":"operator","type":"address"},{"internalType":"bool","name":"toggle","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"signer","type":"address"}],"name":"setBNSigner","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"_baseTokenURI","type":"string"}],"name":"setBaseTokenURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"totalLimit","type":"uint16"},{"internalType":"uint16","name":"generalAdmissionLimit","type":"uint16"}],"name":"setDefaultPurchaseLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"receiver","type":"address"},{"internalType":"uint96","name":"basisPoints","type":"uint96"}],"name":"setDefaultRoyalty","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"maxNumAirdrops","type":"uint16"}],"name":"setMaxNumAirdrops","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint16","name":"numSellable","type":"uint16"}],"name":"setNumTicketsSellable","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"wallet","type":"address"},{"internalType":"uint16","name":"totalLimit","type":"uint16"},{"internalType":"uint16","name":"generalAdmissionLimit","type":"uint16"}],"name":"setPurchaseLimits","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"reducedTicketPrice_","type":"uint128"},{"internalType":"uint128","name":"fullTicketPrice_","type":"uint128"}],"name":"setPurchasePrices","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address payable","name":"salesReceiver","type":"address"}],"name":"setSalesReceiver","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum PoCTicket.Stage","name":"stage_","type":"uint8"}],"name":"setStage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"enum TransferRestriction","name":"restriction","type":"uint8"}],"name":"setTransferRestriction","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint128","name":"price","type":"uint128"}],"name":"setUpgradePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"upgradesPurchaseOpen_","type":"bool"},{"internalType":"bool","name":"blockSaltPublishingOpen_","type":"bool"}],"name":"setUpgradesOpen","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"stage","outputs":[{"internalType":"enum PoCTicket.Stage","name":"","type":"uint8"}],"stateMutability":"view","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":"tokenIds","type":"uint256[]"}],"name":"tokenInfos","outputs":[{"components":[{"internalType":"bool","name":"upgraded","type":"bool"},{"internalType":"bool","name":"airdropped","type":"bool"},{"internalType":"bool","name":"upgradable","type":"bool"},{"internalType":"bool","name":"upgradedFreeOfCharge","type":"bool"},{"internalType":"uint256","name":"revealBlockNumber","type":"uint256"}],"internalType":"struct PoCTicket.TokenInfo[]","name":"infos","type":"tuple[]"}],"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":"payable","type":"function"},{"inputs":[],"name":"transferRestriction","outputs":[{"internalType":"enum TransferRestriction","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"ticketId","type":"uint256"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"upgradableFreeOfCharge","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"ticketIds","type":"uint256[]"}],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"upgradePrice","outputs":[{"internalType":"uint128","name":"","type":"uint128"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"ticketId","type":"uint256"}],"name":"upgraded","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"upgradesPurchaseOpen","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"}]

6101a0604052600f805463ffff0000191662fa00001790556011805467ffffffffffff000019166602000a0fa000001790553480156200003e57600080fd5b5060405162006a2638038062006a268339810160408190526200006191620006c5565b84604001518484607d848b8b8b600001518c6020015163deadface60008383816002908162000091919062000890565b506003620000a0828262000890565b50600080555050600a805460ff19169055620000bd82826200029f565b620000ca600087620003a4565b620000f67f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7686620003a4565b5050505050506001436200010b919062000972565b6080526013805463ffff0001600160a01b0319166b06f05b59d3b200000000010117905561271062000147680100000000000000008462000988565b620001539190620009a2565b60a052601480546001600160a01b0319166001600160a01b039283161790558351811660c0526020840151811660e052604090930151831661010052501661012052620001a081620003e7565b5083516001600160a01b0390811661014052602085015181166101605260408501518116610180527714d1120d7b16000000000000000000000a688906bd8b00006019556018805491841661010002610100600160a81b03199092169190911790556200022e7ff9091c9c3be31b80afbe6fb18ac7f65afc7ae70116c905e33ea83c890fdda92487620003a4565b6200025a7f969ece9ab893f1b9423c66d92a591ca9bffd655f6928f66c4f520ffe5e28ba9f87620003a4565b620002867f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e387620003a4565b620002926001620003f9565b50505050505050620009db565b6127106001600160601b0382161115620003135760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c206578636565646044820152692073616c65507269636560b01b60648201526084015b60405180910390fd5b6001600160a01b0382166200036b5760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c69642072656365697665720000000000000060448201526064016200030a565b604080518082019091526001600160a01b039092168083526001600160601b039091166020909201829052600160a01b90910217600b55565b620003bb82826200042560201b6200268e1760201c565b6000828152600960209081526040909120620003e291839062002730620004c9821b17901c565b505050565b6017620003f5828262000890565b5050565b600d805482919061ff0019166101008360038111156200041d576200041d620009c5565b021790555050565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff16620003f55760008281526008602090815260408083206001600160a01b03851684529091529020805460ff19166001179055620004853390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000620004e0836001600160a01b038416620004e9565b90505b92915050565b60008181526001830160205260408120546200053257508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155620004e3565b506000620004e3565b6001600160a01b03811681146200055157600080fd5b50565b805162000561816200053b565b919050565b634e487b7160e01b600052604160045260246000fd5b604051606081016001600160401b0381118282101715620005a157620005a162000566565b60405290565b604051601f8201601f191681016001600160401b0381118282101715620005d257620005d262000566565b604052919050565b600082601f830112620005ec57600080fd5b81516001600160401b0381111562000608576200060862000566565b60206200061e601f8301601f19168201620005a7565b82815285828487010111156200063357600080fd5b60005b838110156200065357858101830151828201840152820162000636565b506000928101909101919091529392505050565b6000606082840312156200067a57600080fd5b620006846200057c565b9050815162000693816200053b565b81526020820151620006a5816200053b565b60208201526040820151620006ba816200053b565b604082015292915050565b6000806000806000806000610120888a031215620006e257600080fd5b8751620006ef816200053b565b602089015190975062000702816200053b565b60408901519096506001600160401b03808211156200072057600080fd5b908901906060828c0312156200073557600080fd5b6200073f6200057c565b8251828111156200074f57600080fd5b6200075d8d828601620005da565b8252506020830151828111156200077357600080fd5b620007818d828601620005da565b6020830152506040830151828111156200079a57600080fd5b620007a88d828601620005da565b604083015250809750505050620007c38960608a0162000667565b9350620007d360c0890162000554565b9250620007e360e0890162000554565b9150620007f4610100890162000554565b905092959891949750929550565b600181811c908216806200081757607f821691505b6020821081036200083857634e487b7160e01b600052602260045260246000fd5b50919050565b601f821115620003e257600081815260208120601f850160051c81016020861015620008675750805b601f850160051c820191505b81811015620008885782815560010162000873565b505050505050565b81516001600160401b03811115620008ac57620008ac62000566565b620008c481620008bd845462000802565b846200083e565b602080601f831160018114620008fc5760008415620008e35750858301515b600019600386901b1c1916600185901b17855562000888565b600085815260208120601f198616915b828110156200092d578886015182559484019460019091019084016200090c565b50858210156200094c5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b81810381811115620004e357620004e36200095c565b8082028115828204841417620004e357620004e36200095c565b600082620009c057634e487b7160e01b600052601260045260246000fd5b500490565b634e487b7160e01b600052602160045260246000fd5b60805160a05160c05160e0516101005161012051610140516101605161018051615f8662000aa060003960008181611c3e01528181611d2101526132a8015260008181611c1301528181611ce9015261327c015260008181611be801528181611cb10152613250015260008181613327015281816146b7015261477001526000818161345001526134f301526000818161341f01526134c60152600081816133ee015261349901526000612fee01526000818161360901526142c70152615f866000f3fe60806040526004361061044a5760003560e01c80635cd8068f11610243578063a22cb46511610143578063d1ca914e116100bb578063e985e9c51161008a578063f72c0d8b1161006f578063f72c0d8b14610d7a578063f7ea244e14610dae578063f9b202cb14610dce57600080fd5b8063e985e9c514610d3b578063f12937bc14610d5b57600080fd5b8063d1ca914e14610cc6578063d547741f14610ce6578063d547cfb714610d06578063e359457114610d1b57600080fd5b8063c040e6b811610112578063ca15c873116100f7578063ca15c87314610c66578063ce3cd99714610c86578063d06dae0a14610ca657600080fd5b8063c040e6b814610c1f578063c87b56dd14610c4657600080fd5b8063a22cb46514610bac578063ae85115314610bcc578063b88d4fde14610bec578063bff0438414610bff57600080fd5b80638456cb59116101d657806391d14854116101a557806395d89b411161018a57806395d89b4114610b3f578063989ce84e14610b54578063a217fddf14610b9757600080fd5b806391d1485414610ae1578063926837b914610b2757600080fd5b80638456cb5914610a6f57806387b1372014610a845780638ba4cc3c14610aa15780639010d07c14610ac157600080fd5b806370a082311161021257806370a08231146109b357806372c16d09146109d35780637853d06214610a315780638222b7d714610a5a57600080fd5b80635cd8068f146109165780636352211e146109365780636c36c19c146109565780636d147a6d1461098657600080fd5b806330176e131161034e5780633f4ba83a116102e157806346d192ef116102b0578063579ba2c511610295578063579ba2c5146108cb57806357beeb12146108eb5780635c975abb146108fe57600080fd5b806346d192ef1461088b5780634b58fdb8146108ab57600080fd5b80633f4ba83a1461080a57806342842e0e1461081f57806345ffc3f114610832578063461d338c1461086657600080fd5b80633906d7701161031d5780633906d770146107715780633b79276c146107845780633ced37dc146107b85780633ed92533146107f557600080fd5b806330176e13146106e457806331c23d201461070457806333fceb6d1461073857806336568abe1461075157600080fd5b806318160ddd116103e157806323b872dd116103b0578063287ad39f11610395578063287ad39f146106395780632a55205a146106855780632f2ff15d146106c457600080fd5b806323b872dd146105f6578063248a9ca31461060957600080fd5b806318160ddd146105735780631b38388e1461059657806321a77b9b146105b657806322d4e89b146105d657600080fd5b8063081812fc1161041d578063081812fc146104e8578063095ea7b3146105205780630f80035614610533578063117ad57a1461055357600080fd5b806301d5790c1461044f57806301ffc9a71461047157806304634d8d146104a657806306fdde03146104c6575b600080fd5b34801561045b57600080fd5b5061046f61046a36600461522f565b610ded565b005b34801561047d57600080fd5b5061049161048c366004615296565b610e76565b60405190151581526020015b60405180910390f35b3480156104b257600080fd5b5061046f6104c13660046152c8565b610e87565b3480156104d257600080fd5b506104db610ec0565b60405161049d9190615357565b3480156104f457600080fd5b5061050861050336600461536a565b610f52565b6040516001600160a01b03909116815260200161049d565b61046f61052e366004615383565b610fa6565b34801561053f57600080fd5b5061046f61054e3660046153f4565b61101a565b34801561055f57600080fd5b5061046f61056e366004615443565b611086565b34801561057f57600080fd5b50600154600054035b60405190815260200161049d565b3480156105a257600080fd5b5061046f6105b1366004615443565b6110fc565b3480156105c257600080fd5b5061046f6105d1366004615480565b6111d1565b3480156105e257600080fd5b5061046f6105f13660046153f4565b61122b565b61046f6106043660046154b3565b6112e7565b34801561061557600080fd5b5061058861062436600461536a565b60009081526008602052604090206001015490565b34801561064557600080fd5b5060135464010000000090046fffffffffffffffffffffffffffffffff165b6040516fffffffffffffffffffffffffffffffff909116815260200161049d565b34801561069157600080fd5b506106a56106a03660046154f4565b6114fb565b604080516001600160a01b03909316835260208301919091520161049d565b3480156106d057600080fd5b5061046f6106df366004615516565b6115da565b3480156106f057600080fd5b5061046f6106ff3660046155c7565b6115ff565b34801561071057600080fd5b506105887f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7681565b34801561074457600080fd5b5060115461ffff16610588565b34801561075d57600080fd5b5061046f61076c366004615516565b611632565b61046f61077f3660046153f4565b6116ba565b34801561079057600080fd5b506105887ff9091c9c3be31b80afbe6fb18ac7f65afc7ae70116c905e33ea83c890fdda92481565b3480156107c457600080fd5b506019546106649070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b34801561080157600080fd5b50610588611860565b34801561081657600080fd5b5061046f61186f565b61046f61082d3660046154b3565b6118a4565b34801561083e57600080fd5b506105887f969ece9ab893f1b9423c66d92a591ca9bffd655f6928f66c4f520ffe5e28ba9f81565b34801561087257600080fd5b50600d54610100900460ff1660405161049d9190615626565b34801561089757600080fd5b5061046f6108a6366004615652565b6118bf565b3480156108b757600080fd5b5061046f6108c636600461566d565b611925565b3480156108d757600080fd5b506104916108e636600461568a565b61198a565b61046f6108f936600461574b565b611aba565b34801561090a57600080fd5b50600a5460ff16610491565b34801561092257600080fd5b50610588610931366004615812565b611c96565b34801561094257600080fd5b5061050861095136600461536a565b611da2565b34801561096257600080fd5b5061096b611dad565b6040805193845260208401929092529082015260600161049d565b34801561099257600080fd5b506109a66109a13660046153f4565b611dd2565b60405161049d91906158b5565b3480156109bf57600080fd5b506105886109ce36600461566d565b611f11565b3480156109df57600080fd5b506109f36109ee36600461566d565b611f70565b60405161049d9190815161ffff9081168252602080840151821690830152604080840151821690830152606092830151169181019190915260800190565b348015610a3d57600080fd5b50601954610664906fffffffffffffffffffffffffffffffff1681565b348015610a6657600080fd5b5061046f612039565b348015610a7b57600080fd5b5061046f61207a565b348015610a9057600080fd5b50601354610100900460ff16610491565b348015610aad57600080fd5b5061046f610abc366004615383565b6120ac565b348015610acd57600080fd5b50610508610adc3660046154f4565b6120d1565b348015610aed57600080fd5b50610491610afc366004615516565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b348015610b3357600080fd5b5060135460ff16610491565b348015610b4b57600080fd5b506104db6120f0565b348015610b6057600080fd5b50610588610b6f366004615383565b6001600160a01b03919091166000908152601060209081526040808320938352929052205490565b348015610ba357600080fd5b50610588600081565b348015610bb857600080fd5b5061046f610bc736600461592b565b6120ff565b348015610bd857600080fd5b5061046f610be7366004615949565b61216f565b61046f610bfa366004615964565b6121e5565b348015610c0b57600080fd5b5061046f610c1a3660046159e4565b612239565b348015610c2b57600080fd5b50601854610c399060ff1681565b60405161049d9190615a0e565b348015610c5257600080fd5b506104db610c6136600461536a565b6122d2565b348015610c7257600080fd5b50610588610c8136600461536a565b612365565b348015610c9257600080fd5b5061046f610ca1366004615a22565b61237c565b348015610cb257600080fd5b5061046f610cc1366004615a43565b6123ce565b348015610cd257600080fd5b5061046f610ce136600461566d565b61247d565b348015610cf257600080fd5b5061046f610d01366004615516565b6124e7565b348015610d1257600080fd5b506104db61250c565b348015610d2757600080fd5b5061046f610d36366004615652565b61259a565b348015610d4757600080fd5b50610491610d56366004615a88565b612600565b348015610d6757600080fd5b5060115462010000900461ffff16610588565b348015610d8657600080fd5b506105887f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b348015610dba57600080fd5b50610491610dc936600461536a565b61266d565b348015610dda57600080fd5b5060135462010000900461ffff16610588565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf76610e1781612745565b50601380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000169215157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169290921761010091151591909102179055565b6000610e818261274f565b92915050565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf76610eb181612745565b610ebb8383612787565b505050565b606060028054610ecf90615ab6565b80601f0160208091040260200160405190810160405280929190818152602001828054610efb90615ab6565b8015610f485780601f10610f1d57610100808354040283529160200191610f48565b820191906000526020600020905b815481529060010190602001808311610f2b57829003601f168201915b5050505050905090565b6000610f5d826128b2565b610f8a57610f8a7fcf4700e4000000000000000000000000000000000000000000000000000000006128bd565b506000908152600660205260409020546001600160a01b031690565b600d5460ff16158015610fd557506000600d54610100900460ff166003811115610fd257610fd2615610565b14155b1561100c576040517f0a774ec400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61101682826128c7565b5050565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e361104481612745565b60005b828110156110805761107084848381811061106457611064615af0565b905060200201356128d3565b61107981615b1c565b9050611047565b50505050565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766110b081612745565b600d5462010000900460ff16156110f3576040517fc5dbcbf100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611016826129d1565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661112681612745565b600d54610100900460ff16600381111561114257611142615610565b82600381111561115457611154615610565b146111a057600d546040517f6e7074f200000000000000000000000000000000000000000000000000000000815261119791610100900460ff1690600401615626565b60405180910390fd5b5050600d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff1662010000179055565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766111fb81612745565b506fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002911617601955565b601354610100900460ff168061126d576040517f9eda1ca200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82811015611080576112d784848381811061128d5761128d615af0565b905060200281019061129f9190615b36565b358585848181106112b2576112b2615af0565b90506020028101906112c49190615b36565b6112d2906020810190615b74565b612a17565b6112e081615b1c565b9050611270565b60006112f282612b05565b6001600160a01b039485169490915081168414611332576113327fa1148100000000000000000000000000000000000000000000000000000000006128bd565b60008281526006602052604090208054338082146001600160a01b0388169091141761138f576113628633612600565b61138f5761138f7f59c896be000000000000000000000000000000000000000000000000000000006128bd565b61139c8686866001612bbf565b80156113a757600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b7fffffff0000000000000000000000000000000000000000000000000000000000851617177c0200000000000000000000000000000000000000000000000000000000176000858152600460205260408120919091557c02000000000000000000000000000000000000000000000000000000008416900361148f5760018401600081815260046020526040812054900361148d57600054811461148d5760008181526004602052604090208490555b505b6001600160a01b0385168481887fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4806000036114f2576114f27fea553b34000000000000000000000000000000000000000000000000000000006128bd565b50505050505050565b6000828152600c602090815260408083208151808301909252546001600160a01b038116808352740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff1692820192909252829161159c575060408051808201909152600b546001600160a01b03811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1660208201525b6020810151600090612710906115c0906bffffffffffffffffffffffff1687615bd9565b6115ca9190615c06565b91519350909150505b9250929050565b6000828152600860205260409020600101546115f581612745565b610ebb8383612c97565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661162981612745565b61101682612cb9565b6001600160a01b03811633146116b05760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401611197565b6110168282612cc5565b60135460ff16806116f7576040517f9eda1ca200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81611700612ce7565b60135461171890839062010000900461ffff16615c1a565b1115611750576040517fba0c5c5d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60135460009061177a9064010000000090046fffffffffffffffffffffffffffffffff1683615bd9565b90508034146117b8576040517f8324d5b400000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b60005b828110156117f4576117e48686838181106117d8576117d8615af0565b90506020020135612d80565b6117ed81615b1c565b90506117bb565b5081601360028282829054906101000a900461ffff166118149190615c2d565b92506101000a81548161ffff021916908361ffff1602179055506118593461184a6018546001600160a01b036101009091041690565b6001600160a01b031690612dcc565b5050505050565b600061186a612ce7565b905090565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661189981612745565b6118a1612ee5565b50565b610ebb838383604051806020016040528060008152506121e5565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766118e981612745565b506011805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661194f81612745565b50601480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b601454604080516020601f85018190048102820181019092528381526000926001600160a01b031691611a1091908690869081908401838280828437600092019190915250611a0a92506119e19150899050612f37565b60408051602081019290925246908201526060015b604051602081830303815290604052612f4d565b90612f88565b6001600160a01b031614611a50576040517ff4f119c100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008481526015602052604090205460ff16158015611a8b5750611a8b848484604051611a7e929190615c48565b6040518091039020612fac565b8015611ab2575060166000611a9f86612f37565b8152602081019190915260400160002054155b949350505050565b600081611ac78585613029565b611ad18888613029565b611adb8b8b613029565b611ae59190615c1a565b611aef9190615c1a565b611af99190615c1a565b9050611b068a8284613070565b611b158a89898989898961324a565b6001600160a01b038a163314611b3657611b36338b8b8b8b8b8b8b8b6132ce565b600082118015611b5d5750600460185460ff166004811115611b5a57611b5a615610565b14155b15611b94576040517fa5fc3c5a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611ba589898989898989611c96565b9050803414611be3576040517f0e2e092600000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b611c0e7f00000000000000000000000000000000000000000000000000000000000000008a8a613556565b611c397f00000000000000000000000000000000000000000000000000000000000000008888613556565b611c647f00000000000000000000000000000000000000000000000000000000000000008686613556565b601854611c7f9061010090046001600160a01b031634612dcc565b611c8933836135f3565b5050505050505050505050565b600080600080611ca461364a565b9250925092506000611cd87f0000000000000000000000000000000000000000000000000000000000000000858e8e613824565b611ce29082615c1a565b9050611d107f0000000000000000000000000000000000000000000000000000000000000000848c8c613824565b611d1a9082615c1a565b9050611d487f0000000000000000000000000000000000000000000000000000000000000000838a8a613824565b611d529082615c1a565b601954909150611d889070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1687615bd9565b611d929082615c1a565b9c9b505050505050505050505050565b6000610e8182612b05565b600080600080600080611dbe61364a565b915190519151909891975095509350505050565b60608167ffffffffffffffff811115611ded57611ded61553b565b604051908082528060200260200182016040528015611e4657816020015b6040805160a081018252600080825260208083018290529282018190526060820181905260808201528252600019909201910181611e0b5790505b50905060005b82811015611f0a576000848483818110611e6857611e68615af0565b9050602002013590506000611e7c82613991565b90506040518060a00160405280611e928461266d565b151581526020018215158152602001611eaa8461399c565b15158152602001611eba846139bf565b1515815260200182611ed457611ecf84612f37565b611ed7565b60005b815250848481518110611eec57611eec615af0565b6020026020010181905250505080611f0390615b1c565b9050611e4c565b5092915050565b60006001600160a01b038216611f4a57611f4a7f8f4eb604000000000000000000000000000000000000000000000000000000006128bd565b506001600160a01b031660009081526005602052604090205467ffffffffffffffff1690565b6040805160808101825260008082526020820181905291810182905260608101919091526001600160a01b03821660009081526012602090815260408083208151608081018352905461ffff808216835262010000820481169483018590526401000000008204811693830193909352660100000000000090049091166060820152910361200d57601154640100000000900461ffff1660208201525b806060015161ffff16600003610e81576011546601000000000000900461ffff16606082015292915050565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661206381612745565b6118a160006120756001546000540390565b6139f4565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766120a481612745565b6118a1613a31565b600d805460ff191660011790556120c38282613a6e565b5050600d805460ff19169055565b60008281526009602052604081206120e99083613b28565b9392505050565b606060038054610ecf90615ab6565b600d5460ff1615801561212e57506000600d54610100900460ff16600381111561212b5761212b615610565b14155b15612165576040517f0a774ec400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110168282613b34565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661219981612745565b50601380546fffffffffffffffffffffffffffffffff909216640100000000027fffffffffffffffffffffffff00000000000000000000000000000000ffffffff909216919091179055565b6121f08484846112e7565b6001600160a01b0383163b156110805761220c84848484613ba0565b611080576110807fd1a57ed6000000000000000000000000000000000000000000000000000000006128bd565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661226381612745565b50601180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff1664010000000061ffff948516027fffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffff161766010000000000009290931691909102919091179055565b60606122dd826128b2565b61230a5761230a7fa14c4b50000000000000000000000000000000000000000000000000000000006128bd565b6000612314613ce2565b9050805160000361233457604051806020016040528060008152506120e9565b8061233e84613cec565b60405160200161234f929190615c58565b6040516020818303038152906040529392505050565b6000818152600960205260408120610e8190613d30565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766123a681612745565b6018805483919060ff191660018360048111156123c5576123c5615610565b02179055505050565b7f969ece9ab893f1b9423c66d92a591ca9bffd655f6928f66c4f520ffe5e28ba9f6123f881612745565b506001600160a01b0392909216600090815260126020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff0000ffff0000ffff166201000061ffff938416027fffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffff161766010000000000009290931691909102919091179055565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766124a781612745565b50601880546001600160a01b03909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b60008281526008602052604090206001015461250281612745565b610ebb8383612cc5565b6017805461251990615ab6565b80601f016020809104026020016040519081016040528092919081815260200182805461254590615ab6565b80156125925780601f1061256757610100808354040283529160200191612592565b820191906000526020600020905b81548152906001019060200180831161257557829003601f168201915b505050505081565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766125c481612745565b50600f805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b600d5460009060ff1615801561263257506000600d54610100900460ff16600381111561262f5761262f615610565b14155b1561263f57506000610e81565b6001600160a01b0380841660009081526007602090815260408083209386168352929052205460ff166120e9565b60008181526015602052604081205460ff1680610e815750610e8182613d3a565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff166110165760008281526008602090815260408083206001600160a01b03851684529091529020805460ff191660011790556126ec3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006120e9836001600160a01b038416613d8f565b6118a18133613dde565b600061275a82613e53565b80612769575061276982613f34565b80612778575061277882613f86565b80610e815750610e8182613f91565b6127106bffffffffffffffffffffffff8216111561280d5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c2065786365656460448201527f2073616c655072696365000000000000000000000000000000000000000000006064820152608401611197565b6001600160a01b0382166128635760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401611197565b604080518082019091526001600160a01b039092168083526bffffffffffffffffffffffff90911660209092018290527401000000000000000000000000000000000000000090910217600b55565b6000610e8182614028565b8060005260046000fd5b61101682826001614068565b6128dc8161266d565b15612916576040517f2f0f6ecc00000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b61291f816128b2565b612958576040517f4d52937600000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b600081815260156020526040808220805460ff1916600117905551829133917fc36b1c4ce94b1b578439d523d5fd60e3c4a38beaef0242377e4595d4cc045d9f9190a36040518181527ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce79060200160405180910390a150565b600d80548291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100836003811115612a0f57612a0f615610565b021790555050565b60008381526016602052604090205415612a3057505050565b601454604080516020601f85018190048102820181019092528381526001600160a01b0390921691612a9691859085908190840183828082843760009201919091525050604051611a0a92506119f6915088904690602001918252602082015260400190565b6001600160a01b031614612ad6576040517ff4f119c100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8181604051612ae6929190615c48565b6040805191829003909120600094855260166020529320929092555050565b600081815260046020526040812054907c010000000000000000000000000000000000000000000000000000000082169003612b965780600003612b91576000548210612b7557612b757fdf2d9b42000000000000000000000000000000000000000000000000000000006128bd565b5b50600019016000818152600460205260409020548015612b76575b919050565b612b917fdf2d9b42000000000000000000000000000000000000000000000000000000006128bd565b612bcb8484848461413c565b600d5460ff1661108057600d54610100900460ff166000816003811115612bf457612bf4615610565b03612bff5750611080565b6001816003811115612c1357612c13615610565b148015612c2757506001600160a01b038516155b15612c325750611080565b6002816003811115612c4657612c46615610565b148015612c5a57506001600160a01b038416155b15612c655750611080565b6040517f0a774ec400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612ca1828261268e565b6000828152600960205260409020610ebb9082612730565b60176110168282615ccd565b612ccf8282614194565b6000828152600960205260409020610ebb9082614217565b6000600160185460ff166004811115612d0257612d02615610565b03612d0e575061019090565b600260185460ff166004811115612d2757612d27615610565b03612d3357506102bc90565b600360185460ff166004811115612d4c57612d4c615610565b1480612d6e5750600460185460ff166004811115612d6c57612d6c615610565b145b15612d7a575061032090565b50600090565b612d8981613991565b15612dc3576040517fe20cd84a00000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b6118a1816128d3565b80471015612e1c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611197565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612e69576040519150601f19603f3d011682016040523d82523d6000602084013e612e6e565b606091505b5050905080610ebb5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401611197565b612eed61422c565b600a805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000612f4282614280565b610e81906001615c1a565b6000612f598251614302565b82604051602001612f6b929190615d8d565b604051602081830303815290604052805190602001209050919050565b6000806000612f9785856143a2565b91509150612fa4816143e4565b509392505050565b60008082612fb985614549565b6040805160208101939093528201526060810185905260800160408051601f19818403018152919052805160209091012090507f00000000000000000000000000000000000000000000000000000000000000006130206801000000000000000083615de8565b10949350505050565b60008060005b83811015612fa45784848281811061304957613049615af0565b905060400201602001358261305e9190615c1a565b915061306981615b1c565b905061302f565b60115461ffff62010000820481169161308b91859116615c1a565b11156130c3576040517f057a185000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006130ce84611f70565b9050806020015161ffff1683826000015161ffff166130ed9190615c1a565b1115613125576040517fef08f72400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806060015161ffff1682826040015161ffff166131429190615c1a565b111561317a576040517f53aa9be600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6011805484919060009061319390849061ffff16615c2d565b82546101009290920a61ffff8181021990931691831602179091556001600160a01b0386166000908152601260205260408120805487945090926131d991859116615c2d565b82546101009290920a61ffff8181021990931691831602179091556001600160a01b03861660009081526012602052604090208054859350909160049161322a918591640100000000900416615c2d565b92506101000a81548161ffff021916908361ffff16021790555050505050565b613276877f00000000000000000000000000000000000000000000000000000000000000008888614554565b6132a2877f00000000000000000000000000000000000000000000000000000000000000008686614554565b6114f2877f00000000000000000000000000000000000000000000000000000000000000008484614554565b60018760038111156132e2576132e2615610565b036133c8576040517f9c395bc20000000000000000000000000000000000000000000000000000000081526001600160a01b038a8116600483015289811660248301527f00000000000000000000000000000000000000000000000000000000000000001690639c395bc290604401602060405180830381865afa15801561336e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133929190615dfc565b61354b576040517fa9e649e900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028760038111156133dc576133dc615610565b036134795784156134125761341289897f000000000000000000000000000000000000000000000000000000000000000061466f565b82156134435761344389897f000000000000000000000000000000000000000000000000000000000000000061466f565b80156134745761347489897f000000000000000000000000000000000000000000000000000000000000000061466f565b61354b565b600387600381111561348d5761348d615610565b03613519576134bf89897f00000000000000000000000000000000000000000000000000000000000000008989614763565b6134ec89897f00000000000000000000000000000000000000000000000000000000000000008787614763565b61347489897f00000000000000000000000000000000000000000000000000000000000000008585614763565b6040517fe1e4e59b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050505050565b60005b818110156110805782828281811061357357613573615af0565b9050604002016020013560106000866001600160a01b03166001600160a01b0316815260200190815260200160002060008585858181106135b6576135b6615af0565b90506040020160000135815260200190815260200160002060008282546135dd9190615c1a565b909155506135ec905081615b1c565b9050613559565b60005461360083836148ca565b6136338161362e7f000000000000000000000000000000000000000000000000000000000000000043615e19565b6149c9565b5050436000908152600e6020526040902044905550565b601954606090819081906fffffffffffffffffffffffffffffffff16600160185460ff16600481111561367f5761367f615610565b036136a55760408051600180825281830190925290602080830190803683370190505093505b600260185460ff1660048111156136be576136be615610565b106137bf57604080516002808252606082018352909160208301908036833701905050935080846001815181106136f7576136f7615af0565b60209081029190910101526040805160028082526060820190925290816020016020820280368337505060195482519296506fffffffffffffffffffffffffffffffff1691869150600190811061375057613750615af0565b60209081029190910101526040805160028082526060820190925290816020016020820280368337019050509250808360008151811061379257613792615af0565b60200260200101818152505080836001815181106137b2576137b2615af0565b6020026020010181815250505b600360185460ff1660048111156137d8576137d8615610565b1061381e576040805160018082528183019092529060208083019080368337019050509150808260008151811061381157613811615af0565b6020026020010181815250505b50909192565b600081810361383557506000611ab2565b61383f8383614a44565b6000805b838110156139875760006138958887878581811061386357613863615af0565b905060400201600001356001600160a01b03919091166000908152601060209081526040808320938352929052205490565b905060008686848181106138ab576138ab615af0565b90506040020160200135826138c09190615c1a565b9050875181111561393257888787858181106138de576138de615af0565b8b51604080517f2845e8310000000000000000000000000000000000000000000000000000000081526001600160a01b03909616600487015290910292909201356024840152506044820152606401611197565b815b818110156139735788818151811061394e5761394e615af0565b6020026020010151856139619190615c1a565b945061396c81615b1c565b9050613934565b5050508061398090615b1c565b9050613843565b5095945050505050565b6000610e8182614aef565b60006139a78261266d565b158015610e8157506139b882613991565b1592915050565b60008181526015602052604081205460ff161580156139e457506139e282613991565b155b8015610e815750610e8182613d3a565b60408051838152602081018390527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c910160405180910390a15050565b613a39614b0a565b600a805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612f1a3390565b7ff9091c9c3be31b80afbe6fb18ac7f65afc7ae70116c905e33ea83c890fdda924613a9881612745565b600f5461ffff620100008204811691613ab391859116615c1a565b1115613aeb576040517ffd9ee03a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600f8054839190600090613b0490849061ffff16615c2d565b92506101000a81548161ffff021916908361ffff160217905550610ebb8383614b5d565b60006120e98383614b67565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6040517f150b7a020000000000000000000000000000000000000000000000000000000081526000906001600160a01b0385169063150b7a0290613bee903390899088908890600401615e2c565b6020604051808303816000875af1925050508015613c29575060408051601f3d908101601f19168201909252613c2691810190615e68565b60015b613c97573d808015613c57576040519150601f19603f3d011682016040523d82523d6000602084013e613c5c565b606091505b508051600003613c8f57613c8f7fd1a57ed6000000000000000000000000000000000000000000000000000000006128bd565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050611ab2565b606061186a614b91565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a900480613d065750819003601f19909101908152919050565b6000610e81825490565b6000613d4582613991565b15613d5257506000919050565b600060166000613d6185612f37565b8152602001908152602001600020549050806000801b03613d855750600092915050565b6120e98382612fac565b6000818152600183016020526040812054613dd657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610e81565b506000610e81565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff1661101657613e1181614ba0565b613e1c836020614bb2565b604051602001613e2d929190615e85565b60408051601f198184030181529082905262461bcd60e51b825261119791600401615357565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161480613ee657507f80ac58cd000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b80610e815750507fffffffff00000000000000000000000000000000000000000000000000000000167f5b5e139f000000000000000000000000000000000000000000000000000000001490565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a000000000000000000000000000000000000000000000000000000001480610e815750610e81825b6000610e8182614ddb565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f49064906000000000000000000000000000000000000000000000000000000001480610e8157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610e81565b6000805482108015610e815750506000908152600460205260409020547c0100000000000000000000000000000000000000000000000000000000161590565b600061407383611da2565b905081801561408b5750336001600160a01b03821614155b156140c75761409a8133612600565b6140c7576140c77fcfb3b942000000000000000000000000000000000000000000000000000000006128bd565b60008381526006602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0388811691821790925591518693918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a450505050565b600a5460ff161561418f5760405162461bcd60e51b815260206004820152601560248201527f45524337323141436f6d6d6f6e3a2070617573656400000000000000000000006044820152606401611197565b611080565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff16156110165760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006120e9836001600160a01b038416614e31565b600a5460ff1661427e5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611197565b565b600061428b82613991565b156142c5576040517f6c51535a00000000000000000000000000000000000000000000000000000000815260048101839052602401611197565b7f00000000000000000000000000000000000000000000000000000000000000006142ef83614f24565b6060015162ffffff16610e819190615c1a565b6060600061430f83614fb5565b600101905060008167ffffffffffffffff81111561432f5761432f61553b565b6040519080825280601f01601f191660200182016040528015614359576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461436357509392505050565b60008082516041036143d85760208301516040840151606085015160001a6143cc87828585615097565b945094505050506115d3565b506000905060026115d3565b60008160048111156143f8576143f8615610565b036144005750565b600181600481111561441457614414615610565b036144615760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611197565b600281600481111561447557614475615610565b036144c25760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611197565b60038160048111156144d6576144d6615610565b036118a15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401611197565b6000610e818261515b565b60005b8181101561185957846001600160a01b0316846001600160a01b0316636352211e85858581811061458a5761458a615af0565b905060400201600001356040518263ffffffff1660e01b81526004016145b291815260200190565b602060405180830381865afa1580156145cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145f39190615f06565b6001600160a01b03161461465f578383838381811061461457614614615af0565b604080517f82ab15820000000000000000000000000000000000000000000000000000000081526001600160a01b039095166004860152029190910135602483015250604401611197565b61466881615b1c565b9050614557565b6040517f90c9a2d00000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152838116602483015282811660448301527f000000000000000000000000000000000000000000000000000000000000000016906390c9a2d090606401602060405180830381865afa1580156146fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147229190615dfc565b610ebb576040517ffa9418740000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611197565b60005b818110156148c2577f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663aba69cf88787878787878181106147b2576147b2615af0565b6040805160e089901b7fffffffff000000000000000000000000000000000000000000000000000000001681526001600160a01b0397881660048201529587166024870152939095166044850152509202909101356064820152608401602060405180830381865afa15801561482c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148509190615dfc565b6148b2578383838381811061486757614867615af0565b604080517f523b57b60000000000000000000000000000000000000000000000000000000081526001600160a01b039095166004860152029190910135602483015250604401611197565b6148bb81615b1c565b9050614766565b505050505050565b60008054908290036148ff576148ff7fb562e8dd000000000000000000000000000000000000000000000000000000006128bd565b61490c6000848385612bbf565b60008181526004602090815260408083206001600160a01b0387164260a01b6001881460e11b17811790915580845260059092528220805468010000000000000001860201905590819003614984576149847f2e076300000000000000000000000000000000000000000000000000000000006128bd565b818301825b808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4818160010191508103614989575060005550505050565b60008281526004602052604081205490819003614a0857614a087ed58153000000000000000000000000000000000000000000000000000000006128bd565b6000928352600460205260409092207cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9290921660e89190911b179055565b6002811015614a51575050565b60005b614a5f600183615e19565b811015610ebb578282614a73836001615c1a565b818110614a8257614a82615af0565b90506040020160000135838383818110614a9e57614a9e615af0565b9050604002016000013510614adf576040517f3f06bf8100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b614ae881615b1c565b9050614a54565b6000614afa82614f24565b6060015162ffffff161592915050565b600a5460ff161561427e5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611197565b6110168282615180565b6000826000018281548110614b7e57614b7e615af0565b9060005260206000200154905092915050565b606060178054610ecf90615ab6565b6060610e816001600160a01b03831660145b60606000614bc1836002615bd9565b614bcc906002615c1a565b67ffffffffffffffff811115614be457614be461553b565b6040519080825280601f01601f191660200182016040528015614c0e576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110614c4557614c45615af0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110614ca857614ca8615af0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000614ce4846002615bd9565b614cef906001615c1a565b90505b6001811115614d8c577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110614d3057614d30615af0565b1a60f81b828281518110614d4657614d46615af0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93614d8581615f23565b9050614cf2565b5083156120e95760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611197565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f000000000000000000000000000000000000000000000000000000001480610e815750610e818261518a565b60008181526001830160205260408120548015614f1a576000614e55600183615e19565b8554909150600090614e6990600190615e19565b9050818114614ece576000866000018281548110614e8957614e89615af0565b9060005260206000200154905080876000018481548110614eac57614eac615af0565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080614edf57614edf615f3a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610e81565b6000915050610e81565b604080516080810182526000808252602082018190529181018290526060810191909152610e81614f5483612b05565b604080516080810182526001600160a01b038316815260a083901c67ffffffffffffffff1660208201527c0100000000000000000000000000000000000000000000000000000000831615159181019190915260e89190911c606082015290565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310614ffe577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef8100000000831061502a576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061504857662386f26fc10000830492506010015b6305f5e1008310615060576305f5e100830492506008015b612710831061507457612710830492506004015b60648310615086576064830492506002015b600a8310610e815760010192915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156150ce5750600090506003615152565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015615122573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661514b57600060019250925050615152565b9150600090505b94509492505050565b6000600e600061516a84614280565b8152602001908152602001600020549050919050565b61101682826148ca565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610e8157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610e81565b80151581146118a157600080fd5b6000806040838503121561524257600080fd5b823561524d81615221565b9150602083013561525d81615221565b809150509250929050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146118a157600080fd5b6000602082840312156152a857600080fd5b81356120e981615268565b6001600160a01b03811681146118a157600080fd5b600080604083850312156152db57600080fd5b82356152e6816152b3565b915060208301356bffffffffffffffffffffffff8116811461525d57600080fd5b60005b8381101561532257818101518382015260200161530a565b50506000910152565b60008151808452615343816020860160208601615307565b601f01601f19169290920160200192915050565b6020815260006120e9602083018461532b565b60006020828403121561537c57600080fd5b5035919050565b6000806040838503121561539657600080fd5b82356153a1816152b3565b946020939093013593505050565b60008083601f8401126153c157600080fd5b50813567ffffffffffffffff8111156153d957600080fd5b6020830191508360208260051b85010111156115d357600080fd5b6000806020838503121561540757600080fd5b823567ffffffffffffffff81111561541e57600080fd5b61542a858286016153af565b90969095509350505050565b600481106118a157600080fd5b60006020828403121561545557600080fd5b81356120e981615436565b80356fffffffffffffffffffffffffffffffff81168114612b9157600080fd5b6000806040838503121561549357600080fd5b61549c83615460565b91506154aa60208401615460565b90509250929050565b6000806000606084860312156154c857600080fd5b83356154d3816152b3565b925060208401356154e3816152b3565b929592945050506040919091013590565b6000806040838503121561550757600080fd5b50508035926020909101359150565b6000806040838503121561552957600080fd5b82359150602083013561525d816152b3565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561556c5761556c61553b565b604051601f8501601f19908116603f011681019082821181831017156155945761559461553b565b816040528093508581528686860111156155ad57600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156155d957600080fd5b813567ffffffffffffffff8111156155f057600080fd5b8201601f8101841361560157600080fd5b611ab284823560208401615551565b634e487b7160e01b600052602160045260246000fd5b602081016004831061563a5761563a615610565b91905290565b803561ffff81168114612b9157600080fd5b60006020828403121561566457600080fd5b6120e982615640565b60006020828403121561567f57600080fd5b81356120e9816152b3565b60008060006040848603121561569f57600080fd5b83359250602084013567ffffffffffffffff808211156156be57600080fd5b818601915086601f8301126156d257600080fd5b8135818111156156e157600080fd5b8760208285010111156156f357600080fd5b6020830194508093505050509250925092565b60008083601f84011261571857600080fd5b50813567ffffffffffffffff81111561573057600080fd5b6020830191508360208260061b85010111156115d357600080fd5b600080600080600080600080600060c08a8c03121561576957600080fd5b8935615774816152b3565b985060208a013561578481615436565b975060408a013567ffffffffffffffff808211156157a157600080fd5b6157ad8d838e01615706565b909950975060608c01359150808211156157c657600080fd5b6157d28d838e01615706565b909750955060808c01359150808211156157eb57600080fd5b506157f88c828d01615706565b9a9d999c50979a9699959894979660a00135949350505050565b60008060008060008060006080888a03121561582d57600080fd5b873567ffffffffffffffff8082111561584557600080fd5b6158518b838c01615706565b909950975060208a013591508082111561586a57600080fd5b6158768b838c01615706565b909750955060408a013591508082111561588f57600080fd5b5061589c8a828b01615706565b989b979a50959894979596606090950135949350505050565b602080825282518282018190526000919060409081850190868401855b8281101561591e57815180511515855286810151151587860152858101511515868601526060808201511515908601526080908101519085015260a090930192908501906001016158d2565b5091979650505050505050565b6000806040838503121561593e57600080fd5b823561524d816152b3565b60006020828403121561595b57600080fd5b6120e982615460565b6000806000806080858703121561597a57600080fd5b8435615985816152b3565b93506020850135615995816152b3565b925060408501359150606085013567ffffffffffffffff8111156159b857600080fd5b8501601f810187136159c957600080fd5b6159d887823560208401615551565b91505092959194509250565b600080604083850312156159f757600080fd5b615a0083615640565b91506154aa60208401615640565b602081016005831061563a5761563a615610565b600060208284031215615a3457600080fd5b8135600581106120e957600080fd5b600080600060608486031215615a5857600080fd5b8335615a63816152b3565b9250615a7160208501615640565b9150615a7f60408501615640565b90509250925092565b60008060408385031215615a9b57600080fd5b8235615aa6816152b3565b9150602083013561525d816152b3565b600181811c90821680615aca57607f821691505b602082108103615aea57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198203615b2f57615b2f615b06565b5060010190565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112615b6a57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112615ba957600080fd5b83018035915067ffffffffffffffff821115615bc457600080fd5b6020019150368190038213156115d357600080fd5b8082028115828204841417610e8157610e81615b06565b634e487b7160e01b600052601260045260246000fd5b600082615c1557615c15615bf0565b500490565b80820180821115610e8157610e81615b06565b61ffff818116838216019080821115611f0a57611f0a615b06565b8183823760009101908152919050565b60008351615c6a818460208801615307565b835190830190615c7e818360208801615307565b01949350505050565b601f821115610ebb57600081815260208120601f850160051c81016020861015615cae5750805b601f850160051c820191505b818110156148c257828155600101615cba565b815167ffffffffffffffff811115615ce757615ce761553b565b615cfb81615cf58454615ab6565b84615c87565b602080601f831160018114615d305760008415615d185750858301515b600019600386901b1c1916600185901b1785556148c2565b600085815260208120601f198616915b82811015615d5f57888601518255948401946001909101908401615d40565b5085821015615d7d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351615dc581601a850160208801615307565b835190830190615ddc81601a840160208801615307565b01601a01949350505050565b600082615df757615df7615bf0565b500690565b600060208284031215615e0e57600080fd5b81516120e981615221565b81810381811115610e8157610e81615b06565b60006001600160a01b03808716835280861660208401525083604083015260806060830152615e5e608083018461532b565b9695505050505050565b600060208284031215615e7a57600080fd5b81516120e981615268565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615ebd816017850160208801615307565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615efa816028840160208801615307565b01602801949350505050565b600060208284031215615f1857600080fd5b81516120e9816152b3565b600081615f3257615f32615b06565b506000190190565b634e487b7160e01b600052603160045260246000fdfea26469706673582212206117c188a61fe3ac2be98b74d238d3f7787b0efba1992252dde9e6eee1f6e01664736f6c6343000811003300000000000000000000000070c71b539bdcb5b59edd42a500fd95bdec962650000000000000000000000000718987128ea79928917c63ff0c8b3c648846d4c6000000000000000000000000000000000000000000000000000000000000012000000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b0000000000000000000000006351061300295bdc04a611e5db3145106be5efec0000000000000000000000006da00b939a5068699d684456247b5fa3f33541d9000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000009506f435469636b657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004504f435400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004468747470733a2f2f6d61696e6e65742d2d2d706f636d657461646174612d70726f642d723668777276693378612d75632e612e72756e2e6170702f6d657461646174612f00000000000000000000000000000000000000000000000000000000

Deployed Bytecode

0x60806040526004361061044a5760003560e01c80635cd8068f11610243578063a22cb46511610143578063d1ca914e116100bb578063e985e9c51161008a578063f72c0d8b1161006f578063f72c0d8b14610d7a578063f7ea244e14610dae578063f9b202cb14610dce57600080fd5b8063e985e9c514610d3b578063f12937bc14610d5b57600080fd5b8063d1ca914e14610cc6578063d547741f14610ce6578063d547cfb714610d06578063e359457114610d1b57600080fd5b8063c040e6b811610112578063ca15c873116100f7578063ca15c87314610c66578063ce3cd99714610c86578063d06dae0a14610ca657600080fd5b8063c040e6b814610c1f578063c87b56dd14610c4657600080fd5b8063a22cb46514610bac578063ae85115314610bcc578063b88d4fde14610bec578063bff0438414610bff57600080fd5b80638456cb59116101d657806391d14854116101a557806395d89b411161018a57806395d89b4114610b3f578063989ce84e14610b54578063a217fddf14610b9757600080fd5b806391d1485414610ae1578063926837b914610b2757600080fd5b80638456cb5914610a6f57806387b1372014610a845780638ba4cc3c14610aa15780639010d07c14610ac157600080fd5b806370a082311161021257806370a08231146109b357806372c16d09146109d35780637853d06214610a315780638222b7d714610a5a57600080fd5b80635cd8068f146109165780636352211e146109365780636c36c19c146109565780636d147a6d1461098657600080fd5b806330176e131161034e5780633f4ba83a116102e157806346d192ef116102b0578063579ba2c511610295578063579ba2c5146108cb57806357beeb12146108eb5780635c975abb146108fe57600080fd5b806346d192ef1461088b5780634b58fdb8146108ab57600080fd5b80633f4ba83a1461080a57806342842e0e1461081f57806345ffc3f114610832578063461d338c1461086657600080fd5b80633906d7701161031d5780633906d770146107715780633b79276c146107845780633ced37dc146107b85780633ed92533146107f557600080fd5b806330176e13146106e457806331c23d201461070457806333fceb6d1461073857806336568abe1461075157600080fd5b806318160ddd116103e157806323b872dd116103b0578063287ad39f11610395578063287ad39f146106395780632a55205a146106855780632f2ff15d146106c457600080fd5b806323b872dd146105f6578063248a9ca31461060957600080fd5b806318160ddd146105735780631b38388e1461059657806321a77b9b146105b657806322d4e89b146105d657600080fd5b8063081812fc1161041d578063081812fc146104e8578063095ea7b3146105205780630f80035614610533578063117ad57a1461055357600080fd5b806301d5790c1461044f57806301ffc9a71461047157806304634d8d146104a657806306fdde03146104c6575b600080fd5b34801561045b57600080fd5b5061046f61046a36600461522f565b610ded565b005b34801561047d57600080fd5b5061049161048c366004615296565b610e76565b60405190151581526020015b60405180910390f35b3480156104b257600080fd5b5061046f6104c13660046152c8565b610e87565b3480156104d257600080fd5b506104db610ec0565b60405161049d9190615357565b3480156104f457600080fd5b5061050861050336600461536a565b610f52565b6040516001600160a01b03909116815260200161049d565b61046f61052e366004615383565b610fa6565b34801561053f57600080fd5b5061046f61054e3660046153f4565b61101a565b34801561055f57600080fd5b5061046f61056e366004615443565b611086565b34801561057f57600080fd5b50600154600054035b60405190815260200161049d565b3480156105a257600080fd5b5061046f6105b1366004615443565b6110fc565b3480156105c257600080fd5b5061046f6105d1366004615480565b6111d1565b3480156105e257600080fd5b5061046f6105f13660046153f4565b61122b565b61046f6106043660046154b3565b6112e7565b34801561061557600080fd5b5061058861062436600461536a565b60009081526008602052604090206001015490565b34801561064557600080fd5b5060135464010000000090046fffffffffffffffffffffffffffffffff165b6040516fffffffffffffffffffffffffffffffff909116815260200161049d565b34801561069157600080fd5b506106a56106a03660046154f4565b6114fb565b604080516001600160a01b03909316835260208301919091520161049d565b3480156106d057600080fd5b5061046f6106df366004615516565b6115da565b3480156106f057600080fd5b5061046f6106ff3660046155c7565b6115ff565b34801561071057600080fd5b506105887f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7681565b34801561074457600080fd5b5060115461ffff16610588565b34801561075d57600080fd5b5061046f61076c366004615516565b611632565b61046f61077f3660046153f4565b6116ba565b34801561079057600080fd5b506105887ff9091c9c3be31b80afbe6fb18ac7f65afc7ae70116c905e33ea83c890fdda92481565b3480156107c457600080fd5b506019546106649070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1681565b34801561080157600080fd5b50610588611860565b34801561081657600080fd5b5061046f61186f565b61046f61082d3660046154b3565b6118a4565b34801561083e57600080fd5b506105887f969ece9ab893f1b9423c66d92a591ca9bffd655f6928f66c4f520ffe5e28ba9f81565b34801561087257600080fd5b50600d54610100900460ff1660405161049d9190615626565b34801561089757600080fd5b5061046f6108a6366004615652565b6118bf565b3480156108b757600080fd5b5061046f6108c636600461566d565b611925565b3480156108d757600080fd5b506104916108e636600461568a565b61198a565b61046f6108f936600461574b565b611aba565b34801561090a57600080fd5b50600a5460ff16610491565b34801561092257600080fd5b50610588610931366004615812565b611c96565b34801561094257600080fd5b5061050861095136600461536a565b611da2565b34801561096257600080fd5b5061096b611dad565b6040805193845260208401929092529082015260600161049d565b34801561099257600080fd5b506109a66109a13660046153f4565b611dd2565b60405161049d91906158b5565b3480156109bf57600080fd5b506105886109ce36600461566d565b611f11565b3480156109df57600080fd5b506109f36109ee36600461566d565b611f70565b60405161049d9190815161ffff9081168252602080840151821690830152604080840151821690830152606092830151169181019190915260800190565b348015610a3d57600080fd5b50601954610664906fffffffffffffffffffffffffffffffff1681565b348015610a6657600080fd5b5061046f612039565b348015610a7b57600080fd5b5061046f61207a565b348015610a9057600080fd5b50601354610100900460ff16610491565b348015610aad57600080fd5b5061046f610abc366004615383565b6120ac565b348015610acd57600080fd5b50610508610adc3660046154f4565b6120d1565b348015610aed57600080fd5b50610491610afc366004615516565b60009182526008602090815260408084206001600160a01b0393909316845291905290205460ff1690565b348015610b3357600080fd5b5060135460ff16610491565b348015610b4b57600080fd5b506104db6120f0565b348015610b6057600080fd5b50610588610b6f366004615383565b6001600160a01b03919091166000908152601060209081526040808320938352929052205490565b348015610ba357600080fd5b50610588600081565b348015610bb857600080fd5b5061046f610bc736600461592b565b6120ff565b348015610bd857600080fd5b5061046f610be7366004615949565b61216f565b61046f610bfa366004615964565b6121e5565b348015610c0b57600080fd5b5061046f610c1a3660046159e4565b612239565b348015610c2b57600080fd5b50601854610c399060ff1681565b60405161049d9190615a0e565b348015610c5257600080fd5b506104db610c6136600461536a565b6122d2565b348015610c7257600080fd5b50610588610c8136600461536a565b612365565b348015610c9257600080fd5b5061046f610ca1366004615a22565b61237c565b348015610cb257600080fd5b5061046f610cc1366004615a43565b6123ce565b348015610cd257600080fd5b5061046f610ce136600461566d565b61247d565b348015610cf257600080fd5b5061046f610d01366004615516565b6124e7565b348015610d1257600080fd5b506104db61250c565b348015610d2757600080fd5b5061046f610d36366004615652565b61259a565b348015610d4757600080fd5b50610491610d56366004615a88565b612600565b348015610d6757600080fd5b5060115462010000900461ffff16610588565b348015610d8657600080fd5b506105887f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e381565b348015610dba57600080fd5b50610491610dc936600461536a565b61266d565b348015610dda57600080fd5b5060135462010000900461ffff16610588565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf76610e1781612745565b50601380547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000169215157fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff169290921761010091151591909102179055565b6000610e818261274f565b92915050565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf76610eb181612745565b610ebb8383612787565b505050565b606060028054610ecf90615ab6565b80601f0160208091040260200160405190810160405280929190818152602001828054610efb90615ab6565b8015610f485780601f10610f1d57610100808354040283529160200191610f48565b820191906000526020600020905b815481529060010190602001808311610f2b57829003601f168201915b5050505050905090565b6000610f5d826128b2565b610f8a57610f8a7fcf4700e4000000000000000000000000000000000000000000000000000000006128bd565b506000908152600660205260409020546001600160a01b031690565b600d5460ff16158015610fd557506000600d54610100900460ff166003811115610fd257610fd2615610565b14155b1561100c576040517f0a774ec400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61101682826128c7565b5050565b7f189ab7a9244df0848122154315af71fe140f3db0fe014031783b0946b8c9d2e361104481612745565b60005b828110156110805761107084848381811061106457611064615af0565b905060200201356128d3565b61107981615b1c565b9050611047565b50505050565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766110b081612745565b600d5462010000900460ff16156110f3576040517fc5dbcbf100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b611016826129d1565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661112681612745565b600d54610100900460ff16600381111561114257611142615610565b82600381111561115457611154615610565b146111a057600d546040517f6e7074f200000000000000000000000000000000000000000000000000000000815261119791610100900460ff1690600401615626565b60405180910390fd5b5050600d80547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ffff1662010000179055565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766111fb81612745565b506fffffffffffffffffffffffffffffffff90811670010000000000000000000000000000000002911617601955565b601354610100900460ff168061126d576040517f9eda1ca200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60005b82811015611080576112d784848381811061128d5761128d615af0565b905060200281019061129f9190615b36565b358585848181106112b2576112b2615af0565b90506020028101906112c49190615b36565b6112d2906020810190615b74565b612a17565b6112e081615b1c565b9050611270565b60006112f282612b05565b6001600160a01b039485169490915081168414611332576113327fa1148100000000000000000000000000000000000000000000000000000000006128bd565b60008281526006602052604090208054338082146001600160a01b0388169091141761138f576113628633612600565b61138f5761138f7f59c896be000000000000000000000000000000000000000000000000000000006128bd565b61139c8686866001612bbf565b80156113a757600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b7fffffff0000000000000000000000000000000000000000000000000000000000851617177c0200000000000000000000000000000000000000000000000000000000176000858152600460205260408120919091557c02000000000000000000000000000000000000000000000000000000008416900361148f5760018401600081815260046020526040812054900361148d57600054811461148d5760008181526004602052604090208490555b505b6001600160a01b0385168481887fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4806000036114f2576114f27fea553b34000000000000000000000000000000000000000000000000000000006128bd565b50505050505050565b6000828152600c602090815260408083208151808301909252546001600160a01b038116808352740100000000000000000000000000000000000000009091046bffffffffffffffffffffffff1692820192909252829161159c575060408051808201909152600b546001600160a01b03811682527401000000000000000000000000000000000000000090046bffffffffffffffffffffffff1660208201525b6020810151600090612710906115c0906bffffffffffffffffffffffff1687615bd9565b6115ca9190615c06565b91519350909150505b9250929050565b6000828152600860205260409020600101546115f581612745565b610ebb8383612c97565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661162981612745565b61101682612cb9565b6001600160a01b03811633146116b05760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201527f20726f6c657320666f722073656c6600000000000000000000000000000000006064820152608401611197565b6110168282612cc5565b60135460ff16806116f7576040517f9eda1ca200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b81611700612ce7565b60135461171890839062010000900461ffff16615c1a565b1115611750576040517fba0c5c5d00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60135460009061177a9064010000000090046fffffffffffffffffffffffffffffffff1683615bd9565b90508034146117b8576040517f8324d5b400000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b60005b828110156117f4576117e48686838181106117d8576117d8615af0565b90506020020135612d80565b6117ed81615b1c565b90506117bb565b5081601360028282829054906101000a900461ffff166118149190615c2d565b92506101000a81548161ffff021916908361ffff1602179055506118593461184a6018546001600160a01b036101009091041690565b6001600160a01b031690612dcc565b5050505050565b600061186a612ce7565b905090565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661189981612745565b6118a1612ee5565b50565b610ebb838383604051806020016040528060008152506121e5565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766118e981612745565b506011805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661194f81612745565b50601480547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0392909216919091179055565b601454604080516020601f85018190048102820181019092528381526000926001600160a01b031691611a1091908690869081908401838280828437600092019190915250611a0a92506119e19150899050612f37565b60408051602081019290925246908201526060015b604051602081830303815290604052612f4d565b90612f88565b6001600160a01b031614611a50576040517ff4f119c100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008481526015602052604090205460ff16158015611a8b5750611a8b848484604051611a7e929190615c48565b6040518091039020612fac565b8015611ab2575060166000611a9f86612f37565b8152602081019190915260400160002054155b949350505050565b600081611ac78585613029565b611ad18888613029565b611adb8b8b613029565b611ae59190615c1a565b611aef9190615c1a565b611af99190615c1a565b9050611b068a8284613070565b611b158a89898989898961324a565b6001600160a01b038a163314611b3657611b36338b8b8b8b8b8b8b8b6132ce565b600082118015611b5d5750600460185460ff166004811115611b5a57611b5a615610565b14155b15611b94576040517fa5fc3c5a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000611ba589898989898989611c96565b9050803414611be3576040517f0e2e092600000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b611c0e7f00000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d8a8a613556565b611c397f00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b8888613556565b611c647f0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d8686613556565b601854611c7f9061010090046001600160a01b031634612dcc565b611c8933836135f3565b5050505050505050505050565b600080600080611ca461364a565b9250925092506000611cd87f00000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d858e8e613824565b611ce29082615c1a565b9050611d107f00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b848c8c613824565b611d1a9082615c1a565b9050611d487f0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d838a8a613824565b611d529082615c1a565b601954909150611d889070010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1687615bd9565b611d929082615c1a565b9c9b505050505050505050505050565b6000610e8182612b05565b600080600080600080611dbe61364a565b915190519151909891975095509350505050565b60608167ffffffffffffffff811115611ded57611ded61553b565b604051908082528060200260200182016040528015611e4657816020015b6040805160a081018252600080825260208083018290529282018190526060820181905260808201528252600019909201910181611e0b5790505b50905060005b82811015611f0a576000848483818110611e6857611e68615af0565b9050602002013590506000611e7c82613991565b90506040518060a00160405280611e928461266d565b151581526020018215158152602001611eaa8461399c565b15158152602001611eba846139bf565b1515815260200182611ed457611ecf84612f37565b611ed7565b60005b815250848481518110611eec57611eec615af0565b6020026020010181905250505080611f0390615b1c565b9050611e4c565b5092915050565b60006001600160a01b038216611f4a57611f4a7f8f4eb604000000000000000000000000000000000000000000000000000000006128bd565b506001600160a01b031660009081526005602052604090205467ffffffffffffffff1690565b6040805160808101825260008082526020820181905291810182905260608101919091526001600160a01b03821660009081526012602090815260408083208151608081018352905461ffff808216835262010000820481169483018590526401000000008204811693830193909352660100000000000090049091166060820152910361200d57601154640100000000900461ffff1660208201525b806060015161ffff16600003610e81576011546601000000000000900461ffff16606082015292915050565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661206381612745565b6118a160006120756001546000540390565b6139f4565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766120a481612745565b6118a1613a31565b600d805460ff191660011790556120c38282613a6e565b5050600d805460ff19169055565b60008281526009602052604081206120e99083613b28565b9392505050565b606060038054610ecf90615ab6565b600d5460ff1615801561212e57506000600d54610100900460ff16600381111561212b5761212b615610565b14155b15612165576040517f0a774ec400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6110168282613b34565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661219981612745565b50601380546fffffffffffffffffffffffffffffffff909216640100000000027fffffffffffffffffffffffff00000000000000000000000000000000ffffffff909216919091179055565b6121f08484846112e7565b6001600160a01b0383163b156110805761220c84848484613ba0565b611080576110807fd1a57ed6000000000000000000000000000000000000000000000000000000006128bd565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf7661226381612745565b50601180547fffffffffffffffffffffffffffffffffffffffffffffffff00000000ffffffff1664010000000061ffff948516027fffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffff161766010000000000009290931691909102919091179055565b60606122dd826128b2565b61230a5761230a7fa14c4b50000000000000000000000000000000000000000000000000000000006128bd565b6000612314613ce2565b9050805160000361233457604051806020016040528060008152506120e9565b8061233e84613cec565b60405160200161234f929190615c58565b6040516020818303038152906040529392505050565b6000818152600960205260408120610e8190613d30565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766123a681612745565b6018805483919060ff191660018360048111156123c5576123c5615610565b02179055505050565b7f969ece9ab893f1b9423c66d92a591ca9bffd655f6928f66c4f520ffe5e28ba9f6123f881612745565b506001600160a01b0392909216600090815260126020526040902080547fffffffffffffffffffffffffffffffffffffffffffffffff0000ffff0000ffff166201000061ffff938416027fffffffffffffffffffffffffffffffffffffffffffffffff0000ffffffffffff161766010000000000009290931691909102919091179055565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766124a781612745565b50601880546001600160a01b03909216610100027fffffffffffffffffffffff0000000000000000000000000000000000000000ff909216919091179055565b60008281526008602052604090206001015461250281612745565b610ebb8383612cc5565b6017805461251990615ab6565b80601f016020809104026020016040519081016040528092919081815260200182805461254590615ab6565b80156125925780601f1061256757610100808354040283529160200191612592565b820191906000526020600020905b81548152906001019060200180831161257557829003601f168201915b505050505081565b7f1e4c11efbd6a865b1cba79eea33d1b33c1394d834190605ed6a14c71c480bf766125c481612745565b50600f805461ffff90921662010000027fffffffffffffffffffffffffffffffffffffffffffffffffffffffff0000ffff909216919091179055565b600d5460009060ff1615801561263257506000600d54610100900460ff16600381111561262f5761262f615610565b14155b1561263f57506000610e81565b6001600160a01b0380841660009081526007602090815260408083209386168352929052205460ff166120e9565b60008181526015602052604081205460ff1680610e815750610e8182613d3a565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff166110165760008281526008602090815260408083206001600160a01b03851684529091529020805460ff191660011790556126ec3390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60006120e9836001600160a01b038416613d8f565b6118a18133613dde565b600061275a82613e53565b80612769575061276982613f34565b80612778575061277882613f86565b80610e815750610e8182613f91565b6127106bffffffffffffffffffffffff8216111561280d5760405162461bcd60e51b815260206004820152602a60248201527f455243323938313a20726f79616c7479206665652077696c6c2065786365656460448201527f2073616c655072696365000000000000000000000000000000000000000000006064820152608401611197565b6001600160a01b0382166128635760405162461bcd60e51b815260206004820152601960248201527f455243323938313a20696e76616c6964207265636569766572000000000000006044820152606401611197565b604080518082019091526001600160a01b039092168083526bffffffffffffffffffffffff90911660209092018290527401000000000000000000000000000000000000000090910217600b55565b6000610e8182614028565b8060005260046000fd5b61101682826001614068565b6128dc8161266d565b15612916576040517f2f0f6ecc00000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b61291f816128b2565b612958576040517f4d52937600000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b600081815260156020526040808220805460ff1916600117905551829133917fc36b1c4ce94b1b578439d523d5fd60e3c4a38beaef0242377e4595d4cc045d9f9190a36040518181527ff8e1a15aba9398e019f0b49df1a4fde98ee17ae345cb5f6b5e2c27f5033e8ce79060200160405180910390a150565b600d80548291907fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00ff16610100836003811115612a0f57612a0f615610565b021790555050565b60008381526016602052604090205415612a3057505050565b601454604080516020601f85018190048102820181019092528381526001600160a01b0390921691612a9691859085908190840183828082843760009201919091525050604051611a0a92506119f6915088904690602001918252602082015260400190565b6001600160a01b031614612ad6576040517ff4f119c100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8181604051612ae6929190615c48565b6040805191829003909120600094855260166020529320929092555050565b600081815260046020526040812054907c010000000000000000000000000000000000000000000000000000000082169003612b965780600003612b91576000548210612b7557612b757fdf2d9b42000000000000000000000000000000000000000000000000000000006128bd565b5b50600019016000818152600460205260409020548015612b76575b919050565b612b917fdf2d9b42000000000000000000000000000000000000000000000000000000006128bd565b612bcb8484848461413c565b600d5460ff1661108057600d54610100900460ff166000816003811115612bf457612bf4615610565b03612bff5750611080565b6001816003811115612c1357612c13615610565b148015612c2757506001600160a01b038516155b15612c325750611080565b6002816003811115612c4657612c46615610565b148015612c5a57506001600160a01b038416155b15612c655750611080565b6040517f0a774ec400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b612ca1828261268e565b6000828152600960205260409020610ebb9082612730565b60176110168282615ccd565b612ccf8282614194565b6000828152600960205260409020610ebb9082614217565b6000600160185460ff166004811115612d0257612d02615610565b03612d0e575061019090565b600260185460ff166004811115612d2757612d27615610565b03612d3357506102bc90565b600360185460ff166004811115612d4c57612d4c615610565b1480612d6e5750600460185460ff166004811115612d6c57612d6c615610565b145b15612d7a575061032090565b50600090565b612d8981613991565b15612dc3576040517fe20cd84a00000000000000000000000000000000000000000000000000000000815260048101829052602401611197565b6118a1816128d3565b80471015612e1c5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401611197565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114612e69576040519150601f19603f3d011682016040523d82523d6000602084013e612e6e565b606091505b5050905080610ebb5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401611197565b612eed61422c565b600a805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b6000612f4282614280565b610e81906001615c1a565b6000612f598251614302565b82604051602001612f6b929190615d8d565b604051602081830303815290604052805190602001209050919050565b6000806000612f9785856143a2565b91509150612fa4816143e4565b509392505050565b60008082612fb985614549565b6040805160208101939093528201526060810185905260800160408051601f19818403018152919052805160209091012090507f00000000000000000000000000000000000000000000000003333333333333336130206801000000000000000083615de8565b10949350505050565b60008060005b83811015612fa45784848281811061304957613049615af0565b905060400201602001358261305e9190615c1a565b915061306981615b1c565b905061302f565b60115461ffff62010000820481169161308b91859116615c1a565b11156130c3576040517f057a185000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60006130ce84611f70565b9050806020015161ffff1683826000015161ffff166130ed9190615c1a565b1115613125576040517fef08f72400000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b806060015161ffff1682826040015161ffff166131429190615c1a565b111561317a576040517f53aa9be600000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6011805484919060009061319390849061ffff16615c2d565b82546101009290920a61ffff8181021990931691831602179091556001600160a01b0386166000908152601260205260408120805487945090926131d991859116615c2d565b82546101009290920a61ffff8181021990931691831602179091556001600160a01b03861660009081526012602052604090208054859350909160049161322a918591640100000000900416615c2d565b92506101000a81548161ffff021916908361ffff16021790555050505050565b613276877f00000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d8888614554565b6132a2877f00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b8686614554565b6114f2877f0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d8484614554565b60018760038111156132e2576132e2615610565b036133c8576040517f9c395bc20000000000000000000000000000000000000000000000000000000081526001600160a01b038a8116600483015289811660248301527f00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b1690639c395bc290604401602060405180830381865afa15801561336e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906133929190615dfc565b61354b576040517fa9e649e900000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60028760038111156133dc576133dc615610565b036134795784156134125761341289897f00000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d61466f565b82156134435761344389897f00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b61466f565b80156134745761347489897f0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d61466f565b61354b565b600387600381111561348d5761348d615610565b03613519576134bf89897f00000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d8989614763565b6134ec89897f00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b8787614763565b61347489897f0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d8585614763565b6040517fe1e4e59b00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b505050505050505050565b60005b818110156110805782828281811061357357613573615af0565b9050604002016020013560106000866001600160a01b03166001600160a01b0316815260200190815260200160002060008585858181106135b6576135b6615af0565b90506040020160000135815260200190815260200160002060008282546135dd9190615c1a565b909155506135ec905081615b1c565b9050613559565b60005461360083836148ca565b6136338161362e7f0000000000000000000000000000000000000000000000000000000000fc149243615e19565b6149c9565b5050436000908152600e6020526040902044905550565b601954606090819081906fffffffffffffffffffffffffffffffff16600160185460ff16600481111561367f5761367f615610565b036136a55760408051600180825281830190925290602080830190803683370190505093505b600260185460ff1660048111156136be576136be615610565b106137bf57604080516002808252606082018352909160208301908036833701905050935080846001815181106136f7576136f7615af0565b60209081029190910101526040805160028082526060820190925290816020016020820280368337505060195482519296506fffffffffffffffffffffffffffffffff1691869150600190811061375057613750615af0565b60209081029190910101526040805160028082526060820190925290816020016020820280368337019050509250808360008151811061379257613792615af0565b60200260200101818152505080836001815181106137b2576137b2615af0565b6020026020010181815250505b600360185460ff1660048111156137d8576137d8615610565b1061381e576040805160018082528183019092529060208083019080368337019050509150808260008151811061381157613811615af0565b6020026020010181815250505b50909192565b600081810361383557506000611ab2565b61383f8383614a44565b6000805b838110156139875760006138958887878581811061386357613863615af0565b905060400201600001356001600160a01b03919091166000908152601060209081526040808320938352929052205490565b905060008686848181106138ab576138ab615af0565b90506040020160200135826138c09190615c1a565b9050875181111561393257888787858181106138de576138de615af0565b8b51604080517f2845e8310000000000000000000000000000000000000000000000000000000081526001600160a01b03909616600487015290910292909201356024840152506044820152606401611197565b815b818110156139735788818151811061394e5761394e615af0565b6020026020010151856139619190615c1a565b945061396c81615b1c565b9050613934565b5050508061398090615b1c565b9050613843565b5095945050505050565b6000610e8182614aef565b60006139a78261266d565b158015610e8157506139b882613991565b1592915050565b60008181526015602052604081205460ff161580156139e457506139e282613991565b155b8015610e815750610e8182613d3a565b60408051838152602081018390527f6bd5c950a8d8df17f772f5af37cb3655737899cbf903264b9795592da439661c910160405180910390a15050565b613a39614b0a565b600a805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258612f1a3390565b7ff9091c9c3be31b80afbe6fb18ac7f65afc7ae70116c905e33ea83c890fdda924613a9881612745565b600f5461ffff620100008204811691613ab391859116615c1a565b1115613aeb576040517ffd9ee03a00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b600f8054839190600090613b0490849061ffff16615c2d565b92506101000a81548161ffff021916908361ffff160217905550610ebb8383614b5d565b60006120e98383614b67565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6040517f150b7a020000000000000000000000000000000000000000000000000000000081526000906001600160a01b0385169063150b7a0290613bee903390899088908890600401615e2c565b6020604051808303816000875af1925050508015613c29575060408051601f3d908101601f19168201909252613c2691810190615e68565b60015b613c97573d808015613c57576040519150601f19603f3d011682016040523d82523d6000602084013e613c5c565b606091505b508051600003613c8f57613c8f7fd1a57ed6000000000000000000000000000000000000000000000000000000006128bd565b805181602001fd5b7fffffffff00000000000000000000000000000000000000000000000000000000167f150b7a0200000000000000000000000000000000000000000000000000000000149050611ab2565b606061186a614b91565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a900480613d065750819003601f19909101908152919050565b6000610e81825490565b6000613d4582613991565b15613d5257506000919050565b600060166000613d6185612f37565b8152602001908152602001600020549050806000801b03613d855750600092915050565b6120e98382612fac565b6000818152600183016020526040812054613dd657508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610e81565b506000610e81565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff1661101657613e1181614ba0565b613e1c836020614bb2565b604051602001613e2d929190615e85565b60408051601f198184030181529082905262461bcd60e51b825261119791600401615357565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff0000000000000000000000000000000000000000000000000000000083161480613ee657507f80ac58cd000000000000000000000000000000000000000000000000000000007fffffffff000000000000000000000000000000000000000000000000000000008316145b80610e815750507fffffffff00000000000000000000000000000000000000000000000000000000167f5b5e139f000000000000000000000000000000000000000000000000000000001490565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f2a55205a000000000000000000000000000000000000000000000000000000001480610e815750610e81825b6000610e8182614ddb565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f49064906000000000000000000000000000000000000000000000000000000001480610e8157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610e81565b6000805482108015610e815750506000908152600460205260409020547c0100000000000000000000000000000000000000000000000000000000161590565b600061407383611da2565b905081801561408b5750336001600160a01b03821614155b156140c75761409a8133612600565b6140c7576140c77fcfb3b942000000000000000000000000000000000000000000000000000000006128bd565b60008381526006602052604080822080547fffffffffffffffffffffffff0000000000000000000000000000000000000000166001600160a01b0388811691821790925591518693918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a450505050565b600a5460ff161561418f5760405162461bcd60e51b815260206004820152601560248201527f45524337323141436f6d6d6f6e3a2070617573656400000000000000000000006044820152606401611197565b611080565b60008281526008602090815260408083206001600160a01b038516845290915290205460ff16156110165760008281526008602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b60006120e9836001600160a01b038416614e31565b600a5460ff1661427e5760405162461bcd60e51b815260206004820152601460248201527f5061757361626c653a206e6f74207061757365640000000000000000000000006044820152606401611197565b565b600061428b82613991565b156142c5576040517f6c51535a00000000000000000000000000000000000000000000000000000000815260048101839052602401611197565b7f0000000000000000000000000000000000000000000000000000000000fc14926142ef83614f24565b6060015162ffffff16610e819190615c1a565b6060600061430f83614fb5565b600101905060008167ffffffffffffffff81111561432f5761432f61553b565b6040519080825280601f01601f191660200182016040528015614359576020820181803683370190505b5090508181016020015b600019017f3031323334353637383961626364656600000000000000000000000000000000600a86061a8153600a850494508461436357509392505050565b60008082516041036143d85760208301516040840151606085015160001a6143cc87828585615097565b945094505050506115d3565b506000905060026115d3565b60008160048111156143f8576143f8615610565b036144005750565b600181600481111561441457614414615610565b036144615760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401611197565b600281600481111561447557614475615610565b036144c25760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401611197565b60038160048111156144d6576144d6615610565b036118a15760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c60448201527f75650000000000000000000000000000000000000000000000000000000000006064820152608401611197565b6000610e818261515b565b60005b8181101561185957846001600160a01b0316846001600160a01b0316636352211e85858581811061458a5761458a615af0565b905060400201600001356040518263ffffffff1660e01b81526004016145b291815260200190565b602060405180830381865afa1580156145cf573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906145f39190615f06565b6001600160a01b03161461465f578383838381811061461457614614615af0565b604080517f82ab15820000000000000000000000000000000000000000000000000000000081526001600160a01b039095166004860152029190910135602483015250604401611197565b61466881615b1c565b9050614557565b6040517f90c9a2d00000000000000000000000000000000000000000000000000000000081526001600160a01b038481166004830152838116602483015282811660448301527f00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b16906390c9a2d090606401602060405180830381865afa1580156146fe573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906147229190615dfc565b610ebb576040517ffa9418740000000000000000000000000000000000000000000000000000000081526001600160a01b0382166004820152602401611197565b60005b818110156148c2577f00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b6001600160a01b031663aba69cf88787878787878181106147b2576147b2615af0565b6040805160e089901b7fffffffff000000000000000000000000000000000000000000000000000000001681526001600160a01b0397881660048201529587166024870152939095166044850152509202909101356064820152608401602060405180830381865afa15801561482c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906148509190615dfc565b6148b2578383838381811061486757614867615af0565b604080517f523b57b60000000000000000000000000000000000000000000000000000000081526001600160a01b039095166004860152029190910135602483015250604401611197565b6148bb81615b1c565b9050614766565b505050505050565b60008054908290036148ff576148ff7fb562e8dd000000000000000000000000000000000000000000000000000000006128bd565b61490c6000848385612bbf565b60008181526004602090815260408083206001600160a01b0387164260a01b6001881460e11b17811790915580845260059092528220805468010000000000000001860201905590819003614984576149847f2e076300000000000000000000000000000000000000000000000000000000006128bd565b818301825b808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4818160010191508103614989575060005550505050565b60008281526004602052604081205490819003614a0857614a087ed58153000000000000000000000000000000000000000000000000000000006128bd565b6000928352600460205260409092207cffffffffffffffffffffffffffffffffffffffffffffffffffffffffff9290921660e89190911b179055565b6002811015614a51575050565b60005b614a5f600183615e19565b811015610ebb578282614a73836001615c1a565b818110614a8257614a82615af0565b90506040020160000135838383818110614a9e57614a9e615af0565b9050604002016000013510614adf576040517f3f06bf8100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b614ae881615b1c565b9050614a54565b6000614afa82614f24565b6060015162ffffff161592915050565b600a5460ff161561427e5760405162461bcd60e51b815260206004820152601060248201527f5061757361626c653a20706175736564000000000000000000000000000000006044820152606401611197565b6110168282615180565b6000826000018281548110614b7e57614b7e615af0565b9060005260206000200154905092915050565b606060178054610ecf90615ab6565b6060610e816001600160a01b03831660145b60606000614bc1836002615bd9565b614bcc906002615c1a565b67ffffffffffffffff811115614be457614be461553b565b6040519080825280601f01601f191660200182016040528015614c0e576020820181803683370190505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110614c4557614c45615af0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f780000000000000000000000000000000000000000000000000000000000000081600181518110614ca857614ca8615af0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000614ce4846002615bd9565b614cef906001615c1a565b90505b6001811115614d8c577f303132333435363738396162636465660000000000000000000000000000000085600f1660108110614d3057614d30615af0565b1a60f81b828281518110614d4657614d46615af0565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a90535060049490941c93614d8581615f23565b9050614cf2565b5083156120e95760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401611197565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f5a05180f000000000000000000000000000000000000000000000000000000001480610e815750610e818261518a565b60008181526001830160205260408120548015614f1a576000614e55600183615e19565b8554909150600090614e6990600190615e19565b9050818114614ece576000866000018281548110614e8957614e89615af0565b9060005260206000200154905080876000018481548110614eac57614eac615af0565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080614edf57614edf615f3a565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610e81565b6000915050610e81565b604080516080810182526000808252602082018190529181018290526060810191909152610e81614f5483612b05565b604080516080810182526001600160a01b038316815260a083901c67ffffffffffffffff1660208201527c0100000000000000000000000000000000000000000000000000000000831615159181019190915260e89190911c606082015290565b6000807a184f03e93ff9f4daa797ed6e38ed64bf6a1f0100000000000000008310614ffe577a184f03e93ff9f4daa797ed6e38ed64bf6a1f010000000000000000830492506040015b6d04ee2d6d415b85acef8100000000831061502a576d04ee2d6d415b85acef8100000000830492506020015b662386f26fc10000831061504857662386f26fc10000830492506010015b6305f5e1008310615060576305f5e100830492506008015b612710831061507457612710830492506004015b60648310615086576064830492506002015b600a8310610e815760010192915050565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156150ce5750600090506003615152565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015615122573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661514b57600060019250925050615152565b9150600090505b94509492505050565b6000600e600061516a84614280565b8152602001908152602001600020549050919050565b61101682826148ca565b60007fffffffff0000000000000000000000000000000000000000000000000000000082167f7965db0b000000000000000000000000000000000000000000000000000000001480610e8157507f01ffc9a7000000000000000000000000000000000000000000000000000000007fffffffff00000000000000000000000000000000000000000000000000000000831614610e81565b80151581146118a157600080fd5b6000806040838503121561524257600080fd5b823561524d81615221565b9150602083013561525d81615221565b809150509250929050565b7fffffffff00000000000000000000000000000000000000000000000000000000811681146118a157600080fd5b6000602082840312156152a857600080fd5b81356120e981615268565b6001600160a01b03811681146118a157600080fd5b600080604083850312156152db57600080fd5b82356152e6816152b3565b915060208301356bffffffffffffffffffffffff8116811461525d57600080fd5b60005b8381101561532257818101518382015260200161530a565b50506000910152565b60008151808452615343816020860160208601615307565b601f01601f19169290920160200192915050565b6020815260006120e9602083018461532b565b60006020828403121561537c57600080fd5b5035919050565b6000806040838503121561539657600080fd5b82356153a1816152b3565b946020939093013593505050565b60008083601f8401126153c157600080fd5b50813567ffffffffffffffff8111156153d957600080fd5b6020830191508360208260051b85010111156115d357600080fd5b6000806020838503121561540757600080fd5b823567ffffffffffffffff81111561541e57600080fd5b61542a858286016153af565b90969095509350505050565b600481106118a157600080fd5b60006020828403121561545557600080fd5b81356120e981615436565b80356fffffffffffffffffffffffffffffffff81168114612b9157600080fd5b6000806040838503121561549357600080fd5b61549c83615460565b91506154aa60208401615460565b90509250929050565b6000806000606084860312156154c857600080fd5b83356154d3816152b3565b925060208401356154e3816152b3565b929592945050506040919091013590565b6000806040838503121561550757600080fd5b50508035926020909101359150565b6000806040838503121561552957600080fd5b82359150602083013561525d816152b3565b634e487b7160e01b600052604160045260246000fd5b600067ffffffffffffffff8084111561556c5761556c61553b565b604051601f8501601f19908116603f011681019082821181831017156155945761559461553b565b816040528093508581528686860111156155ad57600080fd5b858560208301376000602087830101525050509392505050565b6000602082840312156155d957600080fd5b813567ffffffffffffffff8111156155f057600080fd5b8201601f8101841361560157600080fd5b611ab284823560208401615551565b634e487b7160e01b600052602160045260246000fd5b602081016004831061563a5761563a615610565b91905290565b803561ffff81168114612b9157600080fd5b60006020828403121561566457600080fd5b6120e982615640565b60006020828403121561567f57600080fd5b81356120e9816152b3565b60008060006040848603121561569f57600080fd5b83359250602084013567ffffffffffffffff808211156156be57600080fd5b818601915086601f8301126156d257600080fd5b8135818111156156e157600080fd5b8760208285010111156156f357600080fd5b6020830194508093505050509250925092565b60008083601f84011261571857600080fd5b50813567ffffffffffffffff81111561573057600080fd5b6020830191508360208260061b85010111156115d357600080fd5b600080600080600080600080600060c08a8c03121561576957600080fd5b8935615774816152b3565b985060208a013561578481615436565b975060408a013567ffffffffffffffff808211156157a157600080fd5b6157ad8d838e01615706565b909950975060608c01359150808211156157c657600080fd5b6157d28d838e01615706565b909750955060808c01359150808211156157eb57600080fd5b506157f88c828d01615706565b9a9d999c50979a9699959894979660a00135949350505050565b60008060008060008060006080888a03121561582d57600080fd5b873567ffffffffffffffff8082111561584557600080fd5b6158518b838c01615706565b909950975060208a013591508082111561586a57600080fd5b6158768b838c01615706565b909750955060408a013591508082111561588f57600080fd5b5061589c8a828b01615706565b989b979a50959894979596606090950135949350505050565b602080825282518282018190526000919060409081850190868401855b8281101561591e57815180511515855286810151151587860152858101511515868601526060808201511515908601526080908101519085015260a090930192908501906001016158d2565b5091979650505050505050565b6000806040838503121561593e57600080fd5b823561524d816152b3565b60006020828403121561595b57600080fd5b6120e982615460565b6000806000806080858703121561597a57600080fd5b8435615985816152b3565b93506020850135615995816152b3565b925060408501359150606085013567ffffffffffffffff8111156159b857600080fd5b8501601f810187136159c957600080fd5b6159d887823560208401615551565b91505092959194509250565b600080604083850312156159f757600080fd5b615a0083615640565b91506154aa60208401615640565b602081016005831061563a5761563a615610565b600060208284031215615a3457600080fd5b8135600581106120e957600080fd5b600080600060608486031215615a5857600080fd5b8335615a63816152b3565b9250615a7160208501615640565b9150615a7f60408501615640565b90509250925092565b60008060408385031215615a9b57600080fd5b8235615aa6816152b3565b9150602083013561525d816152b3565b600181811c90821680615aca57607f821691505b602082108103615aea57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198203615b2f57615b2f615b06565b5060010190565b600082357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc1833603018112615b6a57600080fd5b9190910192915050565b60008083357fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe1843603018112615ba957600080fd5b83018035915067ffffffffffffffff821115615bc457600080fd5b6020019150368190038213156115d357600080fd5b8082028115828204841417610e8157610e81615b06565b634e487b7160e01b600052601260045260246000fd5b600082615c1557615c15615bf0565b500490565b80820180821115610e8157610e81615b06565b61ffff818116838216019080821115611f0a57611f0a615b06565b8183823760009101908152919050565b60008351615c6a818460208801615307565b835190830190615c7e818360208801615307565b01949350505050565b601f821115610ebb57600081815260208120601f850160051c81016020861015615cae5750805b601f850160051c820191505b818110156148c257828155600101615cba565b815167ffffffffffffffff811115615ce757615ce761553b565b615cfb81615cf58454615ab6565b84615c87565b602080601f831160018114615d305760008415615d185750858301515b600019600386901b1c1916600185901b1785556148c2565b600085815260208120601f198616915b82811015615d5f57888601518255948401946001909101908401615d40565b5085821015615d7d5787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b7f19457468657265756d205369676e6564204d6573736167653a0a000000000000815260008351615dc581601a850160208801615307565b835190830190615ddc81601a840160208801615307565b01601a01949350505050565b600082615df757615df7615bf0565b500690565b600060208284031215615e0e57600080fd5b81516120e981615221565b81810381811115610e8157610e81615b06565b60006001600160a01b03808716835280861660208401525083604083015260806060830152615e5e608083018461532b565b9695505050505050565b600060208284031215615e7a57600080fd5b81516120e981615268565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351615ebd816017850160208801615307565b7f206973206d697373696e6720726f6c65200000000000000000000000000000006017918401918201528351615efa816028840160208801615307565b01602801949350505050565b600060208284031215615f1857600080fd5b81516120e9816152b3565b600081615f3257615f32615b06565b506000190190565b634e487b7160e01b600052603160045260246000fdfea26469706673582212206117c188a61fe3ac2be98b74d238d3f7787b0efba1992252dde9e6eee1f6e01664736f6c63430008110033

Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)

00000000000000000000000070c71b539bdcb5b59edd42a500fd95bdec962650000000000000000000000000718987128ea79928917c63ff0c8b3c648846d4c6000000000000000000000000000000000000000000000000000000000000012000000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b0000000000000000000000006351061300295bdc04a611e5db3145106be5efec0000000000000000000000006da00b939a5068699d684456247b5fa3f33541d9000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a000000000000000000000000000000000000000000000000000000000000000e00000000000000000000000000000000000000000000000000000000000000009506f435469636b657400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004504f435400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000004468747470733a2f2f6d61696e6e65742d2d2d706f636d657461646174612d70726f642d723668777276693378612d75632e612e72756e2e6170702f6d657461646174612f00000000000000000000000000000000000000000000000000000000

-----Decoded View---------------
Arg [0] : admin (address): 0x70c71b539BDcB5b59Edd42a500Fd95bdeC962650
Arg [1] : steerer (address): 0x718987128EA79928917C63Ff0c8b3C648846d4C6
Arg [2] : setup (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
Arg [3] : tokens (tuple): System.Collections.Generic.List`1[Nethereum.ABI.FunctionEncoding.ParameterOutput]
Arg [4] : delegationRegistry (address): 0x00000000000076A84feF008CDAbe6409d2FE638B
Arg [5] : salesReceiver (address): 0x6351061300295BDC04A611E5DB3145106bE5EFec
Arg [6] : bnSigner (address): 0x6dA00b939a5068699d684456247b5Fa3F33541d9

-----Encoded View---------------
20 Constructor Arguments found :
Arg [0] : 00000000000000000000000070c71b539bdcb5b59edd42a500fd95bdec962650
Arg [1] : 000000000000000000000000718987128ea79928917c63ff0c8b3c648846d4c6
Arg [2] : 0000000000000000000000000000000000000000000000000000000000000120
Arg [3] : 00000000000000000000000008d7c0242953446436f34b4c78fe9da38c73668d
Arg [4] : 00000000000000000000000023581767a106ae21c074b2276d25e5c3e136a68b
Arg [5] : 0000000000000000000000001792a96e5668ad7c167ab804a100ce42395ce54d
Arg [6] : 00000000000000000000000000000000000076a84fef008cdabe6409d2fe638b
Arg [7] : 0000000000000000000000006351061300295bdc04a611e5db3145106be5efec
Arg [8] : 0000000000000000000000006da00b939a5068699d684456247b5fa3f33541d9
Arg [9] : 0000000000000000000000000000000000000000000000000000000000000060
Arg [10] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [11] : 00000000000000000000000000000000000000000000000000000000000000e0
Arg [12] : 0000000000000000000000000000000000000000000000000000000000000009
Arg [13] : 506f435469636b65740000000000000000000000000000000000000000000000
Arg [14] : 0000000000000000000000000000000000000000000000000000000000000004
Arg [15] : 504f435400000000000000000000000000000000000000000000000000000000
Arg [16] : 0000000000000000000000000000000000000000000000000000000000000044
Arg [17] : 68747470733a2f2f6d61696e6e65742d2d2d706f636d657461646174612d7072
Arg [18] : 6f642d723668777276693378612d75632e612e72756e2e6170702f6d65746164
Arg [19] : 6174612f00000000000000000000000000000000000000000000000000000000


Loading...
Loading
Loading...
Loading
[ Download: CSV Export  ]
[ Download: CSV Export  ]

A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.