ETH Price: $2,528.74 (-4.15%)

Token

TerrapinUniverseVillainsCardPack (TUVCP)
 

Overview

Max Total Supply

326 TUVCP

Holders

118

Market

Volume (24H)

N/A

Min Price (24H)

N/A

Max Price (24H)

N/A
Balance
15 TUVCP
0xDd7Ef33957AbE444E364081B5cfE92b238d7A72B
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:
TerrapinUniverseVillainsCardPack

Compiler Version
v0.8.9+commit.e5eed63a

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion, MIT license
File 1 of 21 : TerrapinUniverseVillainsCardPack.sol
//SPDX-License-Identifier: MIT

/*
 ***************************************************************************************************************************
 *                                                                                                                         *
 * ___________                                     .__           ____ ___        .__                                       *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____   |    |   \ ____  |__|___  __  ____ _______  ______  ____   *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  |    |   //    \ |  |\  \/ /_/ __ \\_  __ \/  ___/_/ __ \  *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ |    |  /|   |  \|  | \   / \  ___/ |  | \/\___ \ \  ___/  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  / |______/ |___|  /|__|  \_/   \___  >|__|  /____  > \___  > *
 *               \/                     \/ |__|             \/                \/                 \/            \/      \/  *
 *                                                                                                                         *
 ***************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import "./interfaces/TerrapinUniverse.sol";
import "./interfaces/TerrapinUniverseCardPack.sol";

/**
 * @title Terrapin Universe Villains Card Pack
 *
 * @notice ERC-721 NFT Token Contract
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
contract TerrapinUniverseVillainsCardPack is TerrapinUniverseCardPack {
    using EnumerableSet for EnumerableSet.UintSet;

    uint256 public constant HERO_REDEMPTION_LEVEL = 2;

    TerrapinUniverseCardPack public terrapinUniverseHeroesCardPack;
    TerrapinUniverse public terrapinUniverseHeroes;

    EnumerableSet.UintSet internal _heroRedemptionOriginTokenIds;
    EnumerableSet.UintSet internal _redeemedHeroTokenIds;

    event HeroesCardPackUpdated(
        address oldTerrapinUniverseHeroesCardPack,
        address terrapinUniverseHeroesCardPack
    );
    event HeroesUpdated(
        address oldTerrapinUniverseHeroes,
        address terrapinUniverseHeroes
    );

    error InvalidHeroTokenIds();
    error InvalidTerrapinUniverseHeroesCardPackAddress();
    error InvalidTerrapinUniverseHeroesAddress();

    constructor(
        TerrapinGenesis terrapinGenesis_,
        TerrapinUniverseCardPack terrapinUniverseHeroesCardPack_,
        TerrapinUniverse terrapinUniverseHeroes_,
        string memory baseURI_,
        address[] memory operators
    )
        TerrapinUniverseCardPack(
            "TerrapinUniverseVillainsCardPack",
            "TUVCP",
            terrapinGenesis_,
            baseURI_,
            operators
        )
    {
        terrapinUniverseHeroesCardPack = terrapinUniverseHeroesCardPack_;
        terrapinUniverseHeroes = terrapinUniverseHeroes_;
    }

    /**
     * @notice Mint function, open to valid Gen1 holders. Each owned and unused
     * Gen1 token nets the message sender MINT_COUNT_PER_GEN1 * #gen1TokenIds
     * tokens. After redeeming, Gen1 tokens become 'used' w.r.t. this function.
     *
     * For generating `gen1TokenIds`, see
     * {TerrapinUniverseCardPack-eligibleGen1TokenIdsOf}.
     */
    function mint(uint256[] calldata gen1TokenIds) external {
        mintTo(_msgSender(), gen1TokenIds);
    }

    function mintTo(address to, uint256[] calldata gen1TokenIds)
        public
        nonReentrant
    {
        if (mintActive != true) revert MintNotActive();
        if (_soldOut()) revert MaxSupplyExceeded();
        if (_areGen1TokenIdsEligible(gen1TokenIds, _msgSender()) != true)
            revert InvalidGen1TokenIds();

        _mintViaGen1(to, gen1TokenIds);
    }

    /**
     * @notice Redeem function, open to valid Terrapin Universe Hero token
     * holders. Each unused, level HERO_REDEMPTION_LEVEL or greater, WL-origin
     * Hero nets the message sender 1 Terrapin Universe Villain Card Pack
     * token. After redeeming, Hero becomes 'used' w.r.t. this function.
     *
     * For generating `heroTokenIds`, see
     * {TerrapinUniverseVillainsCardPack-eligibleHeroTokenIdsOf}.
     */
    function redeem(uint256[] calldata heroTokenIds) external {
        redeemTo(_msgSender(), heroTokenIds);
    }

    function setHeroesCardPack(
        TerrapinUniverseCardPack terrapinUniverseHeroesCardPack_
    ) external onlyRole(OPERATOR_ROLE) {
        if (terrapinUniverseHeroesCardPack == terrapinUniverseHeroesCardPack_)
            revert ValueUnchanged();

        TerrapinUniverseCardPack oldTerrapinUniverseHeroesCardPack = terrapinUniverseHeroesCardPack;
        terrapinUniverseHeroesCardPack = terrapinUniverseHeroesCardPack_;

        emit HeroesCardPackUpdated(
            address(oldTerrapinUniverseHeroesCardPack),
            address(terrapinUniverseHeroesCardPack)
        );
    }

    function setHeroes(TerrapinUniverse terrapinUniverseHeroes_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (terrapinUniverseHeroes == terrapinUniverseHeroes_)
            revert ValueUnchanged();

        TerrapinUniverse oldTerrapinUniverseHeroes = terrapinUniverseHeroes;
        terrapinUniverseHeroes = terrapinUniverseHeroes_;

        emit HeroesUpdated(
            address(oldTerrapinUniverseHeroes),
            address(terrapinUniverseHeroes)
        );
    }

    function originOf(uint256 tokenId)
        external
        view
        override
        returns (TokenOrigin)
    {
        if (_hasMintedTokenId(tokenId) != true) revert InvalidTokenId();

        if (_heroRedemptionOriginTokenIds.contains(tokenId)) {
            return TokenOrigin.HeroRedemption;
        }

        return TokenOrigin.Gen1;
    }

    function redeemedHeroTokenIds() external view returns (uint256[] memory) {
        return _redeemedHeroTokenIds.values();
    }

    /**
     * @notice Used to calculate valid and unused heroTokenIds for the
     * given `account` off-chain. The results of this function may be
     * safely passed to {redeem}.
     */
    function eligibleHeroTokenIdsOf(address account)
        external
        view
        returns (uint256[] memory)
    {
        if (address(terrapinUniverseHeroesCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseHeroesCardPackAddress();
        if (address(terrapinUniverseHeroes) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseHeroesAddress();

        uint256[] memory heroTokenIds = terrapinUniverseHeroes.tokensOfOwner(
            account
        );
        uint256[] memory eligibleTokenIdsWithPadding = new uint256[](
            heroTokenIds.length
        );

        uint256 numberOfEligibleTokenIds = 0;
        for (
            uint256 tokenIdIndex = 0;
            tokenIdIndex < eligibleTokenIdsWithPadding.length;
            ++tokenIdIndex
        ) {
            uint256 heroTokenId = heroTokenIds[tokenIdIndex];
            uint256 cardPackTokenId = terrapinUniverseHeroes
                .tokenIdToCardPackTokenId(heroTokenId);

            bool heroHasNotBeenRedeemed = isHeroTokenIdRedeemed(heroTokenId) !=
                true;
            bool heroOriginIsWL = terrapinUniverseHeroesCardPack.originOf(
                cardPackTokenId
            ) == TokenOrigin.WL;
            bool heroLevelRequirementMet = terrapinUniverseHeroes.levelOf(
                heroTokenId
            ) >= HERO_REDEMPTION_LEVEL;

            if (
                heroHasNotBeenRedeemed &&
                heroOriginIsWL &&
                heroLevelRequirementMet
            ) {
                eligibleTokenIdsWithPadding[
                    numberOfEligibleTokenIds
                ] = heroTokenId;
                ++numberOfEligibleTokenIds;
            }
        }

        uint256[] memory eligibleTokenIds = new uint256[](
            numberOfEligibleTokenIds
        );
        for (uint256 index = 0; index < numberOfEligibleTokenIds; ++index) {
            eligibleTokenIds[index] = eligibleTokenIdsWithPadding[index];
        }

        return eligibleTokenIds;
    }

    function redeemTo(address to, uint256[] calldata heroTokenIds)
        public
        nonReentrant
    {
        if (mintActive != true) revert MintNotActive();
        if (_soldOut()) revert MaxSupplyExceeded();

        if (_areHeroTokenIdsEligible(heroTokenIds, _msgSender()) != true)
            revert InvalidHeroTokenIds();

        _redeem(to, heroTokenIds);
    }

    function isHeroTokenIdRedeemed(uint256 tokenId) public view returns (bool) {
        return _redeemedHeroTokenIds.contains(tokenId);
    }

    function _redeem(address to, uint256[] calldata heroTokenIds) private {
        uint256 numberToRedeem = _allowableMintAmount(heroTokenIds.length);

        for (uint256 mintIndex = 0; mintIndex < numberToRedeem; ++mintIndex) {
            uint256 heroTokenId = heroTokenIds[mintIndex];
            uint256 cardPackTokenId = _nextTokenId() + mintIndex;

            _redeemedHeroTokenIds.add(heroTokenId);
            _heroRedemptionOriginTokenIds.add(cardPackTokenId);
        }

        _safeMint(to, numberToRedeem);
    }

    function _areHeroTokenIdsEligible(
        uint256[] calldata tokenIds,
        address account
    ) private view returns (bool) {
        if (address(terrapinUniverseHeroesCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseHeroesCardPackAddress();
        if (address(terrapinUniverseHeroes) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseHeroesAddress();

        bool eligible = true;

        bool[] memory duplicatesCheck = new bool[](
            terrapinUniverseHeroesCardPack.maxSupply()
        );

        for (uint256 index = 0; index < tokenIds.length && eligible; ++index) {
            uint256 heroTokenId = tokenIds[index];
            uint256 cardPackTokenId = terrapinUniverseHeroes
                .tokenIdToCardPackTokenId(heroTokenId);
            uint256 duplicateCheckIndex = heroTokenId - _startTokenId();

            bool isContractOperatorOrHeroOwner = hasRole(
                OPERATOR_ROLE,
                account
            ) || terrapinUniverseHeroes.ownerOf(heroTokenId) == account;
            bool heroHasNotBeenRedeemed = isHeroTokenIdRedeemed(heroTokenId) !=
                true;
            bool isNotDuplicate = duplicatesCheck[duplicateCheckIndex] == false;
            bool heroOriginIsWL = terrapinUniverseHeroesCardPack.originOf(
                cardPackTokenId
            ) == TokenOrigin.WL;
            bool heroLevelRequirementMet = terrapinUniverseHeroes.levelOf(
                heroTokenId
            ) >= HERO_REDEMPTION_LEVEL;

            eligible =
                isContractOperatorOrHeroOwner &&
                heroHasNotBeenRedeemed &&
                isNotDuplicate &&
                heroOriginIsWL &&
                heroLevelRequirementMet;
            duplicatesCheck[duplicateCheckIndex] = true;
        }

        return eligible;
    }
}

File 2 of 21 : AccessControl.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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, _msgSender());
        _;
    }

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

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

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

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

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

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

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

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     *
     * 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.
     */
    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.
     */
    function _revokeRole(bytes32 role, address account) internal virtual {
        if (hasRole(role, account)) {
            _roles[role].members[account] = false;
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 3 of 21 : 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 4 of 21 : Ownable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)

pragma solidity ^0.8.0;

import "../utils/Context.sol";

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

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

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

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
        _;
    }

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

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

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

File 5 of 21 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)

pragma solidity ^0.8.0;

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

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

    uint256 private _status;

    constructor() {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and making it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

File 6 of 21 : Address.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)

pragma solidity ^0.8.0;

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

        uint256 size;
        assembly {
            size := extcodesize(account)
        }
        return size > 0;
    }

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

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

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

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

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

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

        (bool success, bytes memory returndata) = target.call{value: value}(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(
        address target,
        bytes memory data,
        string memory errorMessage
    ) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        (bool success, bytes memory returndata) = target.staticcall(data);
        return verifyCallResult(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) {
        require(isContract(target), "Address: delegate call to non-contract");

        (bool success, bytes memory returndata) = target.delegatecall(data);
        return verifyCallResult(success, returndata, errorMessage);
    }

    /**
     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
     * revert reason 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 {
            // 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

                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 7 of 21 : 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 8 of 21 : Strings.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

File 9 of 21 : ECDSA.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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
    }

    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");
        } else if (error == RecoverError.InvalidSignatureV) {
            revert("ECDSA: invalid signature 'v' 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) {
        // Check the signature length
        // - case 65: r,s,v signature (standard)
        // - case 64: r,vs signature (cf https://eips.ethereum.org/EIPS/eip-2098) _Available since v4.1._
        if (signature.length == 65) {
            bytes32 r;
            bytes32 s;
            uint8 v;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use 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 if (signature.length == 64) {
            bytes32 r;
            bytes32 vs;
            // ecrecover takes the signature parameters, and the only way to get them
            // currently is to use assembly.
            assembly {
                r := mload(add(signature, 0x20))
                vs := mload(add(signature, 0x40))
            }
            return tryRecover(hash, r, vs);
        } 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;
        uint8 v;
        assembly {
            s := and(vs, 0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff)
            v := add(shr(255, vs), 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 (v != 27 && v != 28) {
            return (address(0), RecoverError.InvalidSignatureV);
        }

        // 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 10 of 21 : draft-EIP712.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

import "./ECDSA.sol";

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

    bytes32 private immutable _HASHED_NAME;
    bytes32 private immutable _HASHED_VERSION;
    bytes32 private immutable _TYPE_HASH;

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

    /**
     * @dev Initializes the domain separator and parameter caches.
     *
     * The meaning of `name` and `version` is specified in
     * https://eips.ethereum.org/EIPS/eip-712#definition-of-domainseparator[EIP 712]:
     *
     * - `name`: the user readable name of the signing domain, i.e. the name of the DApp or the protocol.
     * - `version`: the current major version of the signing domain.
     *
     * NOTE: These parameters cannot be changed except through a xref:learn::upgrading-smart-contracts.adoc[smart
     * contract upgrade].
     */
    constructor(string memory name, string memory version) {
        bytes32 hashedName = keccak256(bytes(name));
        bytes32 hashedVersion = keccak256(bytes(version));
        bytes32 typeHash = keccak256(
            "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
        );
        _HASHED_NAME = hashedName;
        _HASHED_VERSION = hashedVersion;
        _CACHED_CHAIN_ID = block.chainid;
        _CACHED_DOMAIN_SEPARATOR = _buildDomainSeparator(typeHash, hashedName, hashedVersion);
        _CACHED_THIS = address(this);
        _TYPE_HASH = typeHash;
    }

    /**
     * @dev Returns the domain separator for the current chain.
     */
    function _domainSeparatorV4() internal view returns (bytes32) {
        if (address(this) == _CACHED_THIS && block.chainid == _CACHED_CHAIN_ID) {
            return _CACHED_DOMAIN_SEPARATOR;
        } else {
            return _buildDomainSeparator(_TYPE_HASH, _HASHED_NAME, _HASHED_VERSION);
        }
    }

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

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

File 11 of 21 : 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 12 of 21 : 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 13 of 21 : Math.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/Math.sol)

pragma solidity ^0.8.0;

/**
 * @dev Standard math utilities missing in the Solidity language.
 */
library Math {
    /**
     * @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 / b + (a % b == 0 ? 0 : 1);
    }
}

File 14 of 21 : EnumerableSet.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)

pragma solidity ^0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library 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) {
        return _values(set._inner);
    }

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

        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 on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

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

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

        assembly {
            result := store
        }

        return result;
    }
}

File 15 of 21 : TerrapinGenesis.sol
//SPDX-License-Identifier: MIT

/*
 ************************************************************************************************************************
 *                                                                                                                      *
 * ___________                                     .__            ________                                 .__          *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____    /  _____/   ____    ____    ____    ______|__|  ______ *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  /   \  ___ _/ __ \  /    \ _/ __ \  /  ___/|  | /  ___/ *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ \    \_\  \\  ___/ |   |  \\  ___/  \___ \ |  | \___ \  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  /  \______  / \___  >|___|  / \___  >/____  >|__|/____  > *
 *               \/                     \/ |__|             \/          \/      \/      \/      \/      \/          \/  *
 *                                                                                                                      *
 ************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/cryptography/draft-EIP712.sol";
import "@openzeppelin/contracts/utils/cryptography/ECDSA.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";

error MintNotActive();
error MaxSupplyExceeded();
error InvalidSignature();
error AccountPreviouslyMinted();
error InvalidValue();
error ValueUnchanged();

contract OSOwnableDelegateProxy {}

contract OSProxyRegistry {
    mapping(address => OSOwnableDelegateProxy) public proxies;
}

/**
 * @title Terrapin Genesis
 *
 * @notice ERC-721 NFT Token Contract.
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
contract TerrapinGenesis is Ownable, AccessControl, EIP712, ERC721AQueryable {
    using Address for address payable;
    using ECDSA for bytes32;

    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    bytes32 public constant MINT_SIGNER_ROLE = keccak256("MINT_SIGNER_ROLE");
    bytes32 public constant WHITELIST_TYPEHASH =
        keccak256("Whitelist(address account)");
    uint256 public constant maxSupply = 333;

    bool public mintActive;
    string public baseURI;

    OSProxyRegistry internal _osProxyRegistry;

    event MintActiveUpdated(bool mintActive);
    event BaseURIUpdated(string oldBaseURI, string baseURI);

    constructor(
        string memory baseURI_,
        address osProxyRegistryAddress,
        address[] memory operators,
        address[] memory mintSigners
    ) EIP712("TerrapinGenesis", "1") ERC721A("TerrapinGenesis", "TG") {
        baseURI = baseURI_;
        _osProxyRegistry = OSProxyRegistry(osProxyRegistryAddress);

        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
        for (uint256 index = 0; index < operators.length; ++index) {
            _grantRole(OPERATOR_ROLE, operators[index]);
        }
        for (uint256 index = 0; index < mintSigners.length; ++index) {
            _grantRole(MINT_SIGNER_ROLE, mintSigners[index]);
        }
    }

    /**
     * @dev Mint function, only whitelisted accounts allowed. With a valid
     * signature from an account with a MINT_SIGNER_ROLE role, accounts may mint
     * up to 1 token.
     */
    function mint(bytes calldata sig) external {
        if (mintActive != true) revert MintNotActive();
        if (numberMinted(_msgSender()) > 0) revert AccountPreviouslyMinted();
        if ((_totalMinted() + 1) > maxSupply) revert MaxSupplyExceeded();

        bytes32 digest = _hashTypedDataV4(
            keccak256(abi.encode(WHITELIST_TYPEHASH, _msgSender()))
        );
        address signer = ECDSA.recover(digest, sig);
        if (hasRole(MINT_SIGNER_ROLE, signer) != true)
            revert InvalidSignature();

        _safeMint(_msgSender(), 1);
    }

    /**
     * @dev Special Mint function. For miscellaneous purposes, e.g. raffles.
     */
    function mintSpecial(address[] calldata addresses)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (_totalMinted() + addresses.length > maxSupply)
            revert MaxSupplyExceeded();

        for (uint256 index = 0; index < addresses.length; ++index) {
            _safeMint(addresses[index], 1);
        }
    }

    /**
     * @dev Reserve Mint function.
     */
    function mintReserve(address to, uint256 quantity)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (_totalMinted() + quantity > maxSupply) revert MaxSupplyExceeded();

        _safeMint(to, quantity);
    }

    function setMintActive(bool mintActive_) external onlyRole(OPERATOR_ROLE) {
        if (mintActive == mintActive_) revert ValueUnchanged();

        mintActive = mintActive_;

        emit MintActiveUpdated(mintActive);
    }

    function setBaseURI(string memory baseURI_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (
            keccak256(abi.encodePacked(baseURI_)) ==
            keccak256(abi.encodePacked(_baseURI()))
        ) revert ValueUnchanged();

        string memory oldBaseURI = _baseURI();
        baseURI = baseURI_;

        emit BaseURIUpdated(oldBaseURI, baseURI_);
    }

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

    /**
     * @dev Number of tokens minted.
     */
    function totalMinted() external view returns (uint256) {
        return _totalMinted();
    }

    /**
     * @dev Returns number of tokens `account` has minted.
     */
    function numberMinted(address account) public view returns (uint256) {
        return _numberMinted(account);
    }

    function isApprovedForAll(address owner_, address operator)
        public
        view
        override
        returns (bool)
    {
        if (super.isApprovedForAll(owner_, operator)) {
            return true;
        }

        if (
            address(_osProxyRegistry) != address(0) &&
            address(_osProxyRegistry.proxies(owner_)) == operator
        ) {
            return true;
        }

        return false;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(AccessControl, ERC721A)
        returns (bool)
    {
        return
            ERC721A.supportsInterface(interfaceId) ||
            AccessControl.supportsInterface(interfaceId);
    }

    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    function _startTokenId() internal pure override returns (uint256) {
        return 1;
    }
}

File 16 of 21 : TerrapinUniverse.sol
//SPDX-License-Identifier: MIT

/*
 ***************************************************************************************************************************
 *                                                                                                                         *
 * ___________                                     .__           ____ ___        .__                                       *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____   |    |   \ ____  |__|___  __  ____ _______  ______  ____   *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  |    |   //    \ |  |\  \/ /_/ __ \\_  __ \/  ___/_/ __ \  *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ |    |  /|   |  \|  | \   / \  ___/ |  | \/\___ \ \  ___/  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  / |______/ |___|  /|__|  \_/   \___  >|__|  /____  > \___  > *
 *               \/                     \/ |__|             \/                \/                 \/            \/      \/  *
 *                                                                                                                         *
 ***************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import {TerrapinGenesis, MintNotActive, MaxSupplyExceeded, InvalidSignature, AccountPreviouslyMinted, InvalidValue, ValueUnchanged} from "../TerrapinGenesis.sol";
import "./TerrapinUniverseCardPack.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";

/**
 * @title Terrapin Universe
 *
 * @notice ERC-721 NFT Token Contract.
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
abstract contract TerrapinUniverse is
    Ownable,
    AccessControl,
    ReentrancyGuard,
    ERC721AQueryable
{
    using Address for address payable;
    using EnumerableSet for EnumerableSet.UintSet;

    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    uint256 public constant maxSupply = 2000;
    uint256 public constant START_TOKEN_ID = 1;
    uint256 public constant STAKE_START_THRESHOLD_DAYS = 3;
    address public constant NULL_ADDRESS = address(0);
    address public constant OS_CONDUIT_ADDRESS =
        0x1E0049783F008A0085193E00003D00cd54003c71;
    TerrapinGenesis public immutable terrapinGenesis;

    uint256[] public LEVEL_EXP_DAYS = [0, 14, 44, 134, 254];
    TerrapinUniverseCardPack public terrapinUniverseCardPack;

    bool public mintActive;
    string public baseURI;
    mapping(uint256 => uint256) public tokenIdToCardPackTokenId;
    mapping(uint256 => uint256) public tokenIdToRawLevelAtLastTransfer;

    EnumerableSet.UintSet internal _usedCardPackTokenIds;

    event MintActiveUpdated(bool mintActive);
    event BaseURIUpdated(string oldBaseURI, string baseURI);
    event CardPackUpdated(
        address oldTerrapinUniverseCardPack,
        address terrapinUniverseCardPack
    );

    error InvalidCardPackTokenIds();
    error InvalidTerrapinUniverseCardPackAddress();

    constructor(
        string memory name_,
        string memory symbol_,
        TerrapinGenesis terrapinGenesis_,
        TerrapinUniverseCardPack terrapinUniverseCardPack_,
        string memory baseURI_,
        address[] memory operators
    ) ERC721A(name_, symbol_) {
        terrapinGenesis = terrapinGenesis_;
        terrapinUniverseCardPack = terrapinUniverseCardPack_;
        baseURI = baseURI_;

        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
        for (uint256 index = 0; index < operators.length; ++index) {
            _grantRole(OPERATOR_ROLE, operators[index]);
        }
    }

    /**
     * @notice Redeem function, open to Terrapin Universe Card Pack holders.
     * Each card pack nets the message sender 1 Terrapin Universe token.
     * Card Pack tokens are BURNED and removed from owners wallet.
     *
     * For generating `cardPackTokenIds`, see
     * {TerrapinUniverse-eligibleCardPackTokenIdsOf}.
     */
    function redeem(uint256[] calldata cardPackTokenIds) external {
        redeemTo(_msgSender(), cardPackTokenIds);
    }

    function setMintActive(bool mintActive_) external onlyRole(OPERATOR_ROLE) {
        if (mintActive == mintActive_) revert ValueUnchanged();

        mintActive = mintActive_;

        emit MintActiveUpdated(mintActive);
    }

    function setBaseURI(string calldata baseURI_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (
            keccak256(abi.encodePacked(baseURI_)) ==
            keccak256(abi.encodePacked(_baseURI()))
        ) revert ValueUnchanged();

        string memory oldBaseURI = _baseURI();
        baseURI = baseURI_;

        emit BaseURIUpdated(oldBaseURI, baseURI_);
    }

    function setCardPack(TerrapinUniverseCardPack terrapinUniverseCardPack_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (terrapinUniverseCardPack == terrapinUniverseCardPack_)
            revert ValueUnchanged();

        TerrapinUniverseCardPack oldTerrapinUniverseCardPack = terrapinUniverseCardPack;
        terrapinUniverseCardPack = terrapinUniverseCardPack_;

        emit CardPackUpdated(
            address(oldTerrapinUniverseCardPack),
            address(terrapinUniverseCardPack)
        );
    }

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

    function totalMinted() external view returns (uint256) {
        return _totalMinted();
    }

    function numberMinted(address account) external view returns (uint256) {
        return _numberMinted(account);
    }

    function usedCardPackTokenIds() external view returns (uint256[] memory) {
        return _usedCardPackTokenIds.values();
    }

    function levelOf(uint256 tokenId) external view returns (uint256) {
        return _levelOf(tokenId, true);
    }

    function rawLevelOf(uint256 tokenId) external view returns (uint256) {
        return _levelOf(tokenId, false);
    }

    function tokenDetailOf(uint256 tokenId)
        external
        view
        returns (
            TokenOwnership memory,
            uint256,
            uint256
        )
    {
        TokenOwnership memory ownership = _ownershipOf(tokenId);
        uint256 level = _levelOf(tokenId, true);
        uint256 rawLevel = _levelOf(tokenId, false);

        return (ownership, level, rawLevel);
    }

    function eligibleCardPackTokenIdsOf(address account)
        external
        view
        returns (uint256[] memory)
    {
        if (address(terrapinUniverseCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseCardPackAddress();

        uint256[] memory tokenIds = terrapinUniverseCardPack.tokensOfOwner(
            account
        );
        uint256[] memory eligibleTokenIdsWithPadding = new uint256[](
            tokenIds.length
        );

        uint256 numberOfEligibleTokenIds = 0;
        for (
            uint256 tokenIdIndex = 0;
            tokenIdIndex < eligibleTokenIdsWithPadding.length;
            ++tokenIdIndex
        ) {
            uint256 tokenId = tokenIds[tokenIdIndex];

            bool hasNotBeenRedeemed = _usedCardPackTokenIds.contains(tokenId) !=
                true;

            if (hasNotBeenRedeemed) {
                eligibleTokenIdsWithPadding[numberOfEligibleTokenIds] = tokenId;
                ++numberOfEligibleTokenIds;
            }
        }

        uint256[] memory eligibleTokenIds = new uint256[](
            numberOfEligibleTokenIds
        );
        for (uint256 index = 0; index < numberOfEligibleTokenIds; ++index) {
            eligibleTokenIds[index] = eligibleTokenIdsWithPadding[index];
        }

        return eligibleTokenIds;
    }

    function redeemTo(address to, uint256[] calldata cardPackTokenIds)
        public
        nonReentrant
    {
        if (mintActive != true) revert MintNotActive();
        if (address(terrapinUniverseCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseCardPackAddress();
        if (_canMintAdditional(cardPackTokenIds.length) != true)
            revert MaxSupplyExceeded();
        if (
            _areCardPackTokenIdsEligible(cardPackTokenIds, _msgSender()) != true
        ) revert InvalidCardPackTokenIds();

        _redeem(to, cardPackTokenIds);
    }

    function isCardPackTokenIdUsed(uint256 tokenId) public view returns (bool) {
        return _usedCardPackTokenIds.contains(tokenId);
    }

    function isApprovedForAll(address owner_, address operator)
        public
        view
        override
        returns (bool)
    {
        if (super.isApprovedForAll(owner_, operator)) {
            return true;
        }

        if (operator == OS_CONDUIT_ADDRESS) {
            return true;
        }

        return false;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(AccessControl, ERC721A)
        returns (bool)
    {
        return
            super.supportsInterface(interfaceId) ||
            AccessControl.supportsInterface(interfaceId);
    }

    function _redeem(address to, uint256[] calldata cardPackTokenIds) internal {
        for (uint256 index = 0; index < cardPackTokenIds.length; ++index) {
            uint256 cardPackTokenId = cardPackTokenIds[index];
            uint256 thisTokenId = _nextTokenId() + index;

            tokenIdToCardPackTokenId[thisTokenId] = cardPackTokenId;
            _usedCardPackTokenIds.add(cardPackTokenId);
        }

        terrapinUniverseCardPack.burn(cardPackTokenIds);
        _safeMint(to, cardPackTokenIds.length);
    }

    function _beforeTokenTransfers(
        address from,
        address,
        uint256 startTokenId,
        uint256 quantity
    ) internal override {
        for (uint256 index = 0; index < quantity; ++index) {
            uint256 tokenId = startTokenId + index;

            if (from != address(0x0)) {
                tokenIdToRawLevelAtLastTransfer[tokenId] = _levelOf(
                    tokenId,
                    false
                );
            }
        }
    }

    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    function _canMintAdditional(uint256 count) internal view returns (bool) {
        return (_totalMinted() + count) <= maxSupply;
    }

    function _startTokenId() internal pure override returns (uint256) {
        return START_TOKEN_ID;
    }

    function _levelOf(uint256 tokenId, bool applyGen1OwnershipBoost)
        internal
        view
        returns (uint256)
    {
        uint256 level = tokenIdToRawLevelAtLastTransfer[tokenId];
        if (level >= LEVEL_EXP_DAYS.length) {
            return level;
        }

        TokenOwnership memory ownership = _ownershipOf(tokenId);
        uint256 numberOfDaysOwnedByCurrentOwner = (block.timestamp -
            ownership.startTimestamp) / (1 days);

        if (numberOfDaysOwnedByCurrentOwner < STAKE_START_THRESHOLD_DAYS) {
            return level;
        }

        uint256 numGen1TokensOwned = terrapinGenesis.balanceOf(ownership.addr);
        uint256 multiplier = 1 +
            (applyGen1OwnershipBoost ? numGen1TokensOwned : 0);
        uint256 eligibleNumDaysExperience = LEVEL_EXP_DAYS[level] +
            numberOfDaysOwnedByCurrentOwner -
            STAKE_START_THRESHOLD_DAYS;
        uint256 experienceInDays = multiplier * eligibleNumDaysExperience;

        while (
            level < LEVEL_EXP_DAYS.length &&
            experienceInDays >= LEVEL_EXP_DAYS[level]
        ) {
            ++level;
        }

        return level;
    }

    function _areCardPackTokenIdsEligible(
        uint256[] calldata cardPackTokenIds,
        address account
    ) private view returns (bool) {
        if (address(terrapinUniverseCardPack) == NULL_ADDRESS)
            revert InvalidTerrapinUniverseCardPackAddress();

        bool eligible = true;

        bool[] memory duplicatesCheck = new bool[](
            terrapinUniverseCardPack.maxSupply()
        );

        for (
            uint256 index = 0;
            index < cardPackTokenIds.length && eligible;
            ++index
        ) {
            uint256 cardPackTokenId = cardPackTokenIds[index];
            uint256 duplicateCheckIndex = cardPackTokenId - _startTokenId();
            bool isContractOperatorOrTokenOwner = hasRole(
                OPERATOR_ROLE,
                account
            ) || terrapinUniverseCardPack.ownerOf(cardPackTokenId) == account;
            bool tokenIdIsUnused = isCardPackTokenIdUsed(cardPackTokenId) !=
                true;
            bool isNotDuplicate = duplicatesCheck[duplicateCheckIndex] == false;

            eligible =
                isContractOperatorOrTokenOwner &&
                tokenIdIsUnused &&
                isNotDuplicate;
            duplicatesCheck[duplicateCheckIndex] = true;
        }

        return eligible;
    }
}

File 17 of 21 : TerrapinUniverseCardPack.sol
//SPDX-License-Identifier: MIT

/*
 ***************************************************************************************************************************
 *                                                                                                                         *
 * ___________                                     .__           ____ ___        .__                                       *
 * \__    ___/____ _______ _______ _____   ______  |__|  ____   |    |   \ ____  |__|___  __  ____ _______  ______  ____   *
 *   |    | _/ __ \\_  __ \\_  __ \\__  \  \____ \ |  | /    \  |    |   //    \ |  |\  \/ /_/ __ \\_  __ \/  ___/_/ __ \  *
 *   |    | \  ___/ |  | \/ |  | \/ / __ \_|  |_> >|  ||   |  \ |    |  /|   |  \|  | \   / \  ___/ |  | \/\___ \ \  ___/  *
 *   |____|  \___  >|__|    |__|   (____  /|   __/ |__||___|  / |______/ |___|  /|__|  \_/   \___  >|__|  /____  > \___  > *
 *               \/                     \/ |__|             \/                \/                 \/            \/      \/  *
 *                                                                                                                         *
 ***************************************************************************************************************************
 */

pragma solidity ^0.8.9;

import {TerrapinGenesis, MintNotActive, MaxSupplyExceeded, InvalidSignature, AccountPreviouslyMinted, InvalidValue, ValueUnchanged} from "../TerrapinGenesis.sol";
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/math/Math.sol";
import "@openzeppelin/contracts/utils/structs/EnumerableSet.sol";
import "erc721a/contracts/extensions/ERC721AQueryable.sol";

enum TokenOrigin {
    Unknown,
    Gen1,
    WL,
    HeroRedemption
}

/**
 * @title Terrapin Universe Card Pack
 *
 * @notice ERC-721 NFT Token Contract.
 *
 * @author 0x1687572416fdd591bcc710fa07cee94a76eea201681884b1d5cc528cba584815
 */
abstract contract TerrapinUniverseCardPack is
    Ownable,
    AccessControl,
    ReentrancyGuard,
    ERC721AQueryable
{
    using Address for address payable;
    using EnumerableSet for EnumerableSet.UintSet;

    bytes32 public constant OPERATOR_ROLE = keccak256("OPERATOR_ROLE");
    bytes32 public constant REDEEMER_ROLE = keccak256("REDEEMER_ROLE");
    uint256 public constant MINT_COUNT_PER_GEN1 = 2;
    uint256 public constant START_TOKEN_ID = 1;
    uint256 public constant maxSupply = 2000;
    address public constant NULL_ADDRESS = address(0);
    address public constant OS_CONDUIT_ADDRESS =
        0x1E0049783F008A0085193E00003D00cd54003c71;
    TerrapinGenesis public immutable terrapinGenesis;

    bool public mintActive;
    string public baseURI;

    EnumerableSet.UintSet internal _usedGen1TokenIds;

    event MintActiveUpdated(bool mintActive);
    event BaseURIUpdated(string oldBaseURI, string baseURI);

    error InvalidGen1TokenIds();
    error InvalidTokenId();
    error InvalidTerrapinGenesisAddress();

    constructor(
        string memory name_,
        string memory symbol_,
        TerrapinGenesis terrapinGenesis_,
        string memory baseURI_,
        address[] memory operators
    ) ERC721A(name_, symbol_) {
        terrapinGenesis = terrapinGenesis_;
        baseURI = baseURI_;

        _grantRole(DEFAULT_ADMIN_ROLE, _msgSender());
        for (uint256 index = 0; index < operators.length; ++index) {
            _grantRole(OPERATOR_ROLE, operators[index]);
        }
    }

    function burn(uint256[] calldata tokenIds)
        external
        onlyRole(REDEEMER_ROLE)
    {
        for (uint256 index = 0; index < tokenIds.length; ++index) {
            uint256 tokenId = tokenIds[index];

            _burn(tokenId, false);
        }
    }

    function setMintActive(bool mintActive_) external onlyRole(OPERATOR_ROLE) {
        if (mintActive == mintActive_) revert ValueUnchanged();

        mintActive = mintActive_;

        emit MintActiveUpdated(mintActive);
    }

    function setBaseURI(string calldata baseURI_)
        external
        onlyRole(OPERATOR_ROLE)
    {
        if (
            keccak256(abi.encodePacked(baseURI_)) ==
            keccak256(abi.encodePacked(_baseURI()))
        ) revert ValueUnchanged();

        string memory oldBaseURI = _baseURI();
        baseURI = baseURI_;

        emit BaseURIUpdated(oldBaseURI, baseURI_);
    }

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

    function totalMinted() external view returns (uint256) {
        return _totalMinted();
    }

    function numberMinted(address account) external view returns (uint256) {
        return _numberMinted(account);
    }

    function usedGen1TokenIds() external view returns (uint256[] memory) {
        return _usedGen1TokenIds.values();
    }

    function originOf(uint256 tokenId)
        external
        view
        virtual
        returns (TokenOrigin);

    /**
     * @notice Used to calculate valid and unused gen1TokenIds for the
     * given `account` off-chain. The results of this function may be
     * safely passed to {mint}.
     */
    function eligibleGen1TokenIdsOf(address account)
        external
        view
        returns (uint256[] memory)
    {
        if (address(terrapinGenesis) == NULL_ADDRESS)
            revert InvalidTerrapinGenesisAddress();

        uint256[] memory tokenIds = terrapinGenesis.tokensOfOwner(account);
        uint256[] memory eligibleTokenIdsWithPadding = new uint256[](
            tokenIds.length
        );

        uint256 numberOfEligibleTokenIds = 0;
        for (
            uint256 tokenIdIndex = 0;
            tokenIdIndex < eligibleTokenIdsWithPadding.length;
            ++tokenIdIndex
        ) {
            uint256 tokenId = tokenIds[tokenIdIndex];
            if (isGen1TokenIdUsed(tokenId) != true) {
                eligibleTokenIdsWithPadding[numberOfEligibleTokenIds] = tokenId;
                ++numberOfEligibleTokenIds;
            }
        }

        uint256[] memory eligibleTokenIds = new uint256[](
            numberOfEligibleTokenIds
        );
        for (uint256 index = 0; index < numberOfEligibleTokenIds; ++index) {
            eligibleTokenIds[index] = eligibleTokenIdsWithPadding[index];
        }

        return eligibleTokenIds;
    }

    function isGen1TokenIdUsed(uint256 tokenId) public view returns (bool) {
        return _usedGen1TokenIds.contains(tokenId);
    }

    function isApprovedForAll(address owner_, address operator)
        public
        view
        override
        returns (bool)
    {
        if (super.isApprovedForAll(owner_, operator)) {
            return true;
        }

        if (operator == OS_CONDUIT_ADDRESS) {
            return true;
        }

        return false;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(AccessControl, ERC721A)
        returns (bool)
    {
        return
            super.supportsInterface(interfaceId) ||
            AccessControl.supportsInterface(interfaceId);
    }

    function _mintViaGen1(address to, uint256[] calldata tokenIds) internal {
        uint256 numberToMint = MINT_COUNT_PER_GEN1;
        for (
            uint256 mintIndex = 0;
            mintIndex < tokenIds.length && numberToMint == MINT_COUNT_PER_GEN1;
            ++mintIndex
        ) {
            numberToMint = _allowableMintAmount(MINT_COUNT_PER_GEN1);
            if (numberToMint > 0) {
                _usedGen1TokenIds.add(tokenIds[mintIndex]);
                _safeMint(to, numberToMint);
            }
        }
    }

    function _baseURI() internal view override returns (string memory) {
        return baseURI;
    }

    function _soldOut() internal view returns (bool) {
        return _totalMinted() >= maxSupply;
    }

    function _allowableMintAmount(uint256 targetAmount)
        internal
        view
        returns (uint256)
    {
        uint256 remainingMintableAmount = maxSupply - _totalMinted();
        return Math.min(targetAmount, remainingMintableAmount);
    }

    function _hasMintedTokenId(uint256 tokenId) internal view returns (bool) {
        return tokenId >= _startTokenId() && tokenId < _nextTokenId();
    }

    function _startTokenId() internal pure override returns (uint256) {
        return START_TOKEN_ID;
    }

    function _areGen1TokenIdsEligible(
        uint256[] calldata tokenIds,
        address account
    ) internal view returns (bool) {
        if (address(terrapinGenesis) == NULL_ADDRESS)
            revert InvalidTerrapinGenesisAddress();

        bool eligible = true;

        bool[] memory duplicatesCheck = new bool[](terrapinGenesis.maxSupply());

        for (uint256 index = 0; index < tokenIds.length && eligible; ++index) {
            uint256 tokenId = tokenIds[index];
            uint256 duplicateCheckIndex = tokenId - _startTokenId();
            bool isContractOperatorOrTokenOwner = hasRole(
                OPERATOR_ROLE,
                account
            ) || terrapinGenesis.ownerOf(tokenId) == account;
            bool tokenIdIsUnused = _usedGen1TokenIds.contains(tokenId) != true;
            bool isNotDuplicate = duplicatesCheck[duplicateCheckIndex] == false;

            eligible =
                isContractOperatorOrTokenOwner &&
                tokenIdIsUnused &&
                isNotDuplicate;
            duplicatesCheck[duplicateCheckIndex] = true;
        }

        return eligible;
    }
}

File 18 of 21 : 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();
        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();

        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) {
        uint256 curr = tokenId;

        unchecked {
            if (_startTokenId() <= curr)
                if (curr < _currentIndex) {
                    uint256 packed = _packedOwnerships[curr];
                    // If not burned.
                    if (packed & _BITMASK_BURNED == 0) {
                        // 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, `curr` will not underflow.
                        //
                        // We can directly compare the packed value.
                        // If the address is zero, packed will be zero.
                        while (packed == 0) {
                            packed = _packedOwnerships[--curr];
                        }
                        return packed;
                    }
                }
        }
        revert OwnerQueryForNonexistentToken();
    }

    /**
     * @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.
     * 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) public payable virtual override {
        address owner = ownerOf(tokenId);

        if (_msgSenderERC721A() != owner)
            if (!isApprovedForAll(owner, _msgSenderERC721A())) {
                revert ApprovalCallerNotOwnerNorApproved();
            }

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

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

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

        if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();

        (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();

        if (to == address(0)) revert TransferToZeroAddress();

        _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;
                    }
                }
            }
        }

        emit Transfer(from, to, tokenId);
        _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();
            }
    }

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

        _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:
            // - `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)
            );

            uint256 toMasked;
            uint256 end = startTokenId + quantity;

            // Use assembly to loop and emit the `Transfer` event for gas savings.
            // The duplicated `log4` removes an extra check and reduces stack juggling.
            // The assembly, together with the surrounding Solidity code, have been
            // delicately arranged to nudge the compiler into producing optimized opcodes.
            assembly {
                // Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
                toMasked := and(to, _BITMASK_ADDRESS)
                // 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`.
                    startTokenId // `tokenId`.
                )

                // The `iszero(eq(,))` check ensures that large values of `quantity`
                // that overflows uint256 will make the loop run out of gas.
                // The compiler will optimize the `iszero` away for performance.
                for {
                    let tokenId := add(startTokenId, 1)
                } iszero(eq(tokenId, end)) {
                    tokenId := add(tokenId, 1)
                } {
                    // Emit the `Transfer` event. Similar to above.
                    log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
                }
            }
            if (toMasked == 0) revert MintToZeroAddress();

            _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();
        if (quantity == 0) revert MintZeroQuantity();
        if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();

        _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();
                    }
                } while (index < end);
                // Reentrancy protection.
                if (_currentIndex != end) revert();
            }
        }
    }

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

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

        _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();
        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)
        }
    }
}

File 19 of 21 : 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 20 of 21 : ERC721AQueryable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import './IERC721AQueryable.sol';
import '../ERC721A.sol';

/**
 * @title ERC721AQueryable.
 *
 * @dev ERC721A subclass with convenience query functions.
 */
abstract contract ERC721AQueryable is ERC721A, IERC721AQueryable {
    /**
     * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
     *
     * If the `tokenId` is out of bounds:
     *
     * - `addr = address(0)`
     * - `startTimestamp = 0`
     * - `burned = false`
     * - `extraData = 0`
     *
     * If the `tokenId` is burned:
     *
     * - `addr = <Address of owner before token was burned>`
     * - `startTimestamp = <Timestamp when token was burned>`
     * - `burned = true`
     * - `extraData = <Extra data when token was burned>`
     *
     * Otherwise:
     *
     * - `addr = <Address of owner>`
     * - `startTimestamp = <Timestamp of start of ownership>`
     * - `burned = false`
     * - `extraData = <Extra data at start of ownership>`
     */
    function explicitOwnershipOf(uint256 tokenId) public view virtual override returns (TokenOwnership memory) {
        TokenOwnership memory ownership;
        if (tokenId < _startTokenId() || tokenId >= _nextTokenId()) {
            return ownership;
        }
        ownership = _ownershipAt(tokenId);
        if (ownership.burned) {
            return ownership;
        }
        return _ownershipOf(tokenId);
    }

    /**
     * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
     * See {ERC721AQueryable-explicitOwnershipOf}
     */
    function explicitOwnershipsOf(uint256[] calldata tokenIds)
        external
        view
        virtual
        override
        returns (TokenOwnership[] memory)
    {
        unchecked {
            uint256 tokenIdsLength = tokenIds.length;
            TokenOwnership[] memory ownerships = new TokenOwnership[](tokenIdsLength);
            for (uint256 i; i != tokenIdsLength; ++i) {
                ownerships[i] = explicitOwnershipOf(tokenIds[i]);
            }
            return ownerships;
        }
    }

    /**
     * @dev Returns an array of token IDs owned by `owner`,
     * in the range [`start`, `stop`)
     * (i.e. `start <= tokenId < stop`).
     *
     * This function allows for tokens to be queried if the collection
     * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
     *
     * Requirements:
     *
     * - `start < stop`
     */
    function tokensOfOwnerIn(
        address owner,
        uint256 start,
        uint256 stop
    ) external view virtual override returns (uint256[] memory) {
        unchecked {
            if (start >= stop) revert InvalidQueryRange();
            uint256 tokenIdsIdx;
            uint256 stopLimit = _nextTokenId();
            // Set `start = max(start, _startTokenId())`.
            if (start < _startTokenId()) {
                start = _startTokenId();
            }
            // Set `stop = min(stop, stopLimit)`.
            if (stop > stopLimit) {
                stop = stopLimit;
            }
            uint256 tokenIdsMaxLength = balanceOf(owner);
            // Set `tokenIdsMaxLength = min(balanceOf(owner), stop - start)`,
            // to cater for cases where `balanceOf(owner)` is too big.
            if (start < stop) {
                uint256 rangeLength = stop - start;
                if (rangeLength < tokenIdsMaxLength) {
                    tokenIdsMaxLength = rangeLength;
                }
            } else {
                tokenIdsMaxLength = 0;
            }
            uint256[] memory tokenIds = new uint256[](tokenIdsMaxLength);
            if (tokenIdsMaxLength == 0) {
                return tokenIds;
            }
            // We need to call `explicitOwnershipOf(start)`,
            // because the slot at `start` may not be initialized.
            TokenOwnership memory ownership = explicitOwnershipOf(start);
            address currOwnershipAddr;
            // If the starting slot exists (i.e. not burned), initialize `currOwnershipAddr`.
            // `ownership.address` will not be zero, as `start` is clamped to the valid token ID range.
            if (!ownership.burned) {
                currOwnershipAddr = ownership.addr;
            }
            for (uint256 i = start; i != stop && tokenIdsIdx != tokenIdsMaxLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            // Downsize the array to fit.
            assembly {
                mstore(tokenIds, tokenIdsIdx)
            }
            return tokenIds;
        }
    }

    /**
     * @dev Returns an array of token IDs owned by `owner`.
     *
     * This function scans the ownership mapping and is O(`totalSupply`) in complexity.
     * It is meant to be called off-chain.
     *
     * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
     * multiple smaller scans if the collection is large enough to cause
     * an out-of-gas error (10K collections should be fine).
     */
    function tokensOfOwner(address owner) external view virtual override returns (uint256[] memory) {
        unchecked {
            uint256 tokenIdsIdx;
            address currOwnershipAddr;
            uint256 tokenIdsLength = balanceOf(owner);
            uint256[] memory tokenIds = new uint256[](tokenIdsLength);
            TokenOwnership memory ownership;
            for (uint256 i = _startTokenId(); tokenIdsIdx != tokenIdsLength; ++i) {
                ownership = _ownershipAt(i);
                if (ownership.burned) {
                    continue;
                }
                if (ownership.addr != address(0)) {
                    currOwnershipAddr = ownership.addr;
                }
                if (currOwnershipAddr == owner) {
                    tokenIds[tokenIdsIdx++] = i;
                }
            }
            return tokenIds;
        }
    }
}

File 21 of 21 : IERC721AQueryable.sol
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs

pragma solidity ^0.8.4;

import '../IERC721A.sol';

/**
 * @dev Interface of ERC721AQueryable.
 */
interface IERC721AQueryable is IERC721A {
    /**
     * Invalid query range (`start` >= `stop`).
     */
    error InvalidQueryRange();

    /**
     * @dev Returns the `TokenOwnership` struct at `tokenId` without reverting.
     *
     * If the `tokenId` is out of bounds:
     *
     * - `addr = address(0)`
     * - `startTimestamp = 0`
     * - `burned = false`
     * - `extraData = 0`
     *
     * If the `tokenId` is burned:
     *
     * - `addr = <Address of owner before token was burned>`
     * - `startTimestamp = <Timestamp when token was burned>`
     * - `burned = true`
     * - `extraData = <Extra data when token was burned>`
     *
     * Otherwise:
     *
     * - `addr = <Address of owner>`
     * - `startTimestamp = <Timestamp of start of ownership>`
     * - `burned = false`
     * - `extraData = <Extra data at start of ownership>`
     */
    function explicitOwnershipOf(uint256 tokenId) external view returns (TokenOwnership memory);

    /**
     * @dev Returns an array of `TokenOwnership` structs at `tokenIds` in order.
     * See {ERC721AQueryable-explicitOwnershipOf}
     */
    function explicitOwnershipsOf(uint256[] memory tokenIds) external view returns (TokenOwnership[] memory);

    /**
     * @dev Returns an array of token IDs owned by `owner`,
     * in the range [`start`, `stop`)
     * (i.e. `start <= tokenId < stop`).
     *
     * This function allows for tokens to be queried if the collection
     * grows too big for a single call of {ERC721AQueryable-tokensOfOwner}.
     *
     * Requirements:
     *
     * - `start < stop`
     */
    function tokensOfOwnerIn(
        address owner,
        uint256 start,
        uint256 stop
    ) external view returns (uint256[] memory);

    /**
     * @dev Returns an array of token IDs owned by `owner`.
     *
     * This function scans the ownership mapping and is O(`totalSupply`) in complexity.
     * It is meant to be called off-chain.
     *
     * See {ERC721AQueryable-tokensOfOwnerIn} for splitting the scan into
     * multiple smaller scans if the collection is large enough to cause
     * an out-of-gas error (10K collections should be fine).
     */
    function tokensOfOwner(address owner) external view returns (uint256[] memory);
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"contract TerrapinGenesis","name":"terrapinGenesis_","type":"address"},{"internalType":"contract TerrapinUniverseCardPack","name":"terrapinUniverseHeroesCardPack_","type":"address"},{"internalType":"contract TerrapinUniverse","name":"terrapinUniverseHeroes_","type":"address"},{"internalType":"string","name":"baseURI_","type":"string"},{"internalType":"address[]","name":"operators","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"ApprovalCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"ApprovalQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"BalanceQueryForZeroAddress","type":"error"},{"inputs":[],"name":"InvalidGen1TokenIds","type":"error"},{"inputs":[],"name":"InvalidHeroTokenIds","type":"error"},{"inputs":[],"name":"InvalidQueryRange","type":"error"},{"inputs":[],"name":"InvalidTerrapinGenesisAddress","type":"error"},{"inputs":[],"name":"InvalidTerrapinUniverseHeroesAddress","type":"error"},{"inputs":[],"name":"InvalidTerrapinUniverseHeroesCardPackAddress","type":"error"},{"inputs":[],"name":"InvalidTokenId","type":"error"},{"inputs":[],"name":"MaxSupplyExceeded","type":"error"},{"inputs":[],"name":"MintERC2309QuantityExceedsLimit","type":"error"},{"inputs":[],"name":"MintNotActive","type":"error"},{"inputs":[],"name":"MintToZeroAddress","type":"error"},{"inputs":[],"name":"MintZeroQuantity","type":"error"},{"inputs":[],"name":"OwnerQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"OwnershipNotInitializedForExtraData","type":"error"},{"inputs":[],"name":"TransferCallerNotOwnerNorApproved","type":"error"},{"inputs":[],"name":"TransferFromIncorrectOwner","type":"error"},{"inputs":[],"name":"TransferToNonERC721ReceiverImplementer","type":"error"},{"inputs":[],"name":"TransferToZeroAddress","type":"error"},{"inputs":[],"name":"URIQueryForNonexistentToken","type":"error"},{"inputs":[],"name":"ValueUnchanged","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":"string","name":"oldBaseURI","type":"string"},{"indexed":false,"internalType":"string","name":"baseURI","type":"string"}],"name":"BaseURIUpdated","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":"address","name":"oldTerrapinUniverseHeroesCardPack","type":"address"},{"indexed":false,"internalType":"address","name":"terrapinUniverseHeroesCardPack","type":"address"}],"name":"HeroesCardPackUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"address","name":"oldTerrapinUniverseHeroes","type":"address"},{"indexed":false,"internalType":"address","name":"terrapinUniverseHeroes","type":"address"}],"name":"HeroesUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bool","name":"mintActive","type":"bool"}],"name":"MintActiveUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"previousOwner","type":"address"},{"indexed":true,"internalType":"address","name":"newOwner","type":"address"}],"name":"OwnershipTransferred","type":"event"},{"anonymous":false,"inputs":[{"indexed":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":"from","type":"address"},{"indexed":true,"internalType":"address","name":"to","type":"address"},{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"Transfer","type":"event"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"HERO_REDEMPTION_LEVEL","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MINT_COUNT_PER_GEN1","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"NULL_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OPERATOR_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"OS_CONDUIT_ADDRESS","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"REDEEMER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"START_TOKEN_ID","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","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":"baseURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"eligibleGen1TokenIdsOf","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"eligibleHeroTokenIdsOf","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"explicitOwnershipOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"tokenIds","type":"uint256[]"}],"name":"explicitOwnershipsOf","outputs":[{"components":[{"internalType":"address","name":"addr","type":"address"},{"internalType":"uint64","name":"startTimestamp","type":"uint64"},{"internalType":"bool","name":"burned","type":"bool"},{"internalType":"uint24","name":"extraData","type":"uint24"}],"internalType":"struct IERC721A.TokenOwnership[]","name":"","type":"tuple[]"}],"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":"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":"uint256","name":"tokenId","type":"uint256"}],"name":"isGen1TokenIdUsed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"isHeroTokenIdRedeemed","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"gen1TokenIds","type":"uint256[]"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"mintActive","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"gen1TokenIds","type":"uint256[]"}],"name":"mintTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"name","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"account","type":"address"}],"name":"numberMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"originOf","outputs":[{"internalType":"enum TokenOrigin","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"owner","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"ownerOf","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256[]","name":"heroTokenIds","type":"uint256[]"}],"name":"redeem","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"to","type":"address"},{"internalType":"uint256[]","name":"heroTokenIds","type":"uint256[]"}],"name":"redeemTo","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"redeemedHeroTokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renounceOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"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":"approved","type":"bool"}],"name":"setApprovalForAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"string","name":"baseURI_","type":"string"}],"name":"setBaseURI","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract TerrapinUniverse","name":"terrapinUniverseHeroes_","type":"address"}],"name":"setHeroes","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"contract TerrapinUniverseCardPack","name":"terrapinUniverseHeroesCardPack_","type":"address"}],"name":"setHeroesCardPack","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bool","name":"mintActive_","type":"bool"}],"name":"setMintActive","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes4","name":"interfaceId","type":"bytes4"}],"name":"supportsInterface","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"symbol","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"terrapinGenesis","outputs":[{"internalType":"contract TerrapinGenesis","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"terrapinUniverseHeroes","outputs":[{"internalType":"contract TerrapinUniverse","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"terrapinUniverseHeroesCardPack","outputs":[{"internalType":"contract TerrapinUniverseCardPack","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"}],"name":"tokensOfOwner","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"owner","type":"address"},{"internalType":"uint256","name":"start","type":"uint256"},{"internalType":"uint256","name":"stop","type":"uint256"}],"name":"tokensOfOwnerIn","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"totalMinted","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"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":[{"internalType":"address","name":"newOwner","type":"address"}],"name":"transferOwnership","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"usedGen1TokenIds","outputs":[{"internalType":"uint256[]","name":"","type":"uint256[]"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"}]

60a06040523480156200001157600080fd5b506040516200462d3803806200462d83398101604081905262000034916200041b565b60408051808201825260208082527f546572726170696e556e69766572736556696c6c61696e73436172645061636b8183015282518084019093526005835264054555643560dc1b908301529086848484846200009133620001a7565b60016002558151620000ab90600590602085019062000280565b508051620000c190600690602084019062000280565b50600160035550506001600160a01b0383166080528151620000eb90600c90602085019062000280565b50620000f9600033620001f7565b60005b81518110156200016757620001547f97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b92983838151811062000140576200014062000543565b6020026020010151620001f760201b60201c565b6200015f8162000559565b9050620000fc565b5050600f80546001600160a01b03998a166001600160a01b031991821617909155601080549890991697169690961790965550620005c095505050505050565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b60008281526001602090815260408083206001600160a01b038516845290915290205460ff166200027c5760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45b5050565b8280546200028e9062000583565b90600052602060002090601f016020900481019282620002b25760008555620002fd565b82601f10620002cd57805160ff1916838001178555620002fd565b82800160010185558215620002fd579182015b82811115620002fd578251825591602001919060010190620002e0565b506200030b9291506200030f565b5090565b5b808211156200030b576000815560010162000310565b6001600160a01b03811681146200033c57600080fd5b50565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b03811182821017156200038057620003806200033f565b604052919050565b600082601f8301126200039a57600080fd5b815160206001600160401b03821115620003b857620003b86200033f565b8160051b620003c982820162000355565b9283528481018201928281019087851115620003e457600080fd5b83870192505b8483101562000410578251620004008162000326565b82529183019190830190620003ea565b979650505050505050565b600080600080600060a086880312156200043457600080fd5b8551620004418162000326565b80955050602080870151620004568162000326565b6040880151909550620004698162000326565b60608801519094506001600160401b03808211156200048757600080fd5b818901915089601f8301126200049c57600080fd5b815181811115620004b157620004b16200033f565b620004c5601f8201601f1916850162000355565b8181528b85838601011115620004da57600080fd5b60005b82811015620004fa578481018601518282018701528501620004dd565b828111156200050c5760008684840101525b5060808b0151909650935050808311156200052657600080fd5b5050620005368882890162000388565b9150509295509295909350565b634e487b7160e01b600052603260045260246000fd5b60006000198214156200057c57634e487b7160e01b600052601160045260246000fd5b5060010190565b600181811c908216806200059857607f821691505b60208210811415620005ba57634e487b7160e01b600052602260045260246000fd5b50919050565b60805161402e620005ff60003960008181610a4101528181611fbb0152818161202201528181612e6a01528181612eb90152612ffe015261402e6000f3fe60806040526004361061038c5760003560e01c80637fa46ab4116101dc578063c87b56dd11610102578063ee1cc944116100a0578063f4cc37bd1161006f578063f4cc37bd14610a2f578063f5b541a614610a63578063f8e93ef914610a85578063f9afb26a14610aa557600080fd5b8063ee1cc944146109af578063f07a886e146109cf578063f26b6e1a146109ef578063f2fde38b14610a0f57600080fd5b8063dc33e681116100dc578063dc33e6811461093a578063de0ce17d1461095a578063e43058471461096f578063e985e9c51461098f57600080fd5b8063c87b56dd146108e4578063d547741f14610904578063d5abeb011461092457600080fd5b806399a2557a1161017a578063b80f55c911610149578063b80f55c914610864578063b88d4fde14610884578063c23dc68f14610897578063c847bc64146108c457600080fd5b806399a2557a146107fa578063a217fddf1461081a578063a22cb4651461082f578063a2309ff81461084f57600080fd5b80638a88487d116101b65780638a88487d146107925780638da5cb5b146107a757806391d14854146107c557806395d89b41146107e557600080fd5b80637fa46ab4146107295780638462151c1461075d57806387f65c911461077d57600080fd5b80632fa32eb9116102c15780636352211e1161025f57806370a082311161022e57806370a08231146106a7578063715018a6146106c7578063794b2a07146106dc5780637c1f9eb11461070957600080fd5b80636352211e1461062a578063640d79a61461064a5780636c0360eb1461066a578063702d53941461067f57600080fd5b806342842e0e1161029b57806342842e0e146105a857806355f804b3146105bb5780635bbb2177146105db57806360378c5a1461060857600080fd5b80632fa32eb91461055357806336568abe146105735780633ccfd60b1461059357600080fd5b80631a8997441161032e578063248a9ca311610308578063248a9ca3146104c857806325fd90f3146104f95780632cc70dcc146105135780632f2ff15d1461053357600080fd5b80631a899744146104955780631be4782b1461039157806323b872dd146104b557600080fd5b8063081812fc1161036a578063081812fc1461040b578063095ea7b31461044357806318160ddd146104585780631867d33d1461047557600080fd5b80630164f0881461039157806301ffc9a7146103b957806306fdde03146103e9575b600080fd5b34801561039d57600080fd5b506103a6600281565b6040519081526020015b60405180910390f35b3480156103c557600080fd5b506103d96103d43660046136d1565b610ac5565b60405190151581526020016103b0565b3480156103f557600080fd5b506103fe610ae5565b6040516103b09190613746565b34801561041757600080fd5b5061042b610426366004613759565b610b77565b6040516001600160a01b0390911681526020016103b0565b610456610451366004613787565b610bbb565b005b34801561046457600080fd5b5060045460035403600019016103a6565b34801561048157600080fd5b506103d9610490366004613759565b610c5b565b3480156104a157600080fd5b506103d96104b0366004613759565b610c68565b6104566104c33660046137b3565b610c75565b3480156104d457600080fd5b506103a66104e3366004613759565b6000908152600160208190526040909120015490565b34801561050557600080fd5b50600b546103d99060ff1681565b34801561051f57600080fd5b5061045661052e3660046137f4565b610dfe565b34801561053f57600080fd5b5061045661054e366004613811565b610ea9565b34801561055f57600080fd5b5061045661056e3660046137f4565b610ed5565b34801561057f57600080fd5b5061045661058e366004613811565b610f77565b34801561059f57600080fd5b50610456610ffa565b6104566105b63660046137b3565b611013565b3480156105c757600080fd5b506104566105d6366004613841565b61102e565b3480156105e757600080fd5b506105fb6105f63660046138fd565b611117565b6040516103b0919061397a565b34801561061457600080fd5b5061061d6111e2565b6040516103b091906139bc565b34801561063657600080fd5b5061042b610645366004613759565b6111f3565b34801561065657600080fd5b5061061d6106653660046137f4565b6111fe565b34801561067657600080fd5b506103fe6115f6565b34801561068b57600080fd5b5061042b731e0049783f008a0085193e00003d00cd54003c7181565b3480156106b357600080fd5b506103a66106c23660046137f4565b611684565b3480156106d357600080fd5b506104566116d2565b3480156106e857600080fd5b506106fc6106f7366004613759565b611738565b6040516103b09190613a0a565b34801561071557600080fd5b50610456610724366004613a32565b611785565b34801561073557600080fd5b506103a67f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc81565b34801561076957600080fd5b5061061d6107783660046137f4565b61186b565b34801561078957600080fd5b506103a6600181565b34801561079e57600080fd5b5061061d61197a565b3480156107b357600080fd5b506000546001600160a01b031661042b565b3480156107d157600080fd5b506103d96107e0366004613811565b611986565b3480156107f157600080fd5b506103fe6119b1565b34801561080657600080fd5b5061061d610815366004613a86565b6119c0565b34801561082657600080fd5b506103a6600081565b34801561083b57600080fd5b5061045661084a366004613ad0565b611b4b565b34801561085b57600080fd5b506103a6611bb7565b34801561087057600080fd5b5061045661087f3660046138fd565b611bc6565b610456610892366004613b4b565b611c3b565b3480156108a357600080fd5b506108b76108b2366004613759565b611c7f565b6040516103b09190613c0e565b3480156108d057600080fd5b506104566108df366004613a32565b611d07565b3480156108f057600080fd5b506103fe6108ff366004613759565b611de3565b34801561091057600080fd5b5061045661091f366004613811565b611e67565b34801561093057600080fd5b506103a66107d081565b34801561094657600080fd5b506103a66109553660046137f4565b611e8e565b34801561096657600080fd5b5061042b600081565b34801561097b57600080fd5b50600f5461042b906001600160a01b031681565b34801561099b57600080fd5b506103d96109aa366004613c1c565b611eb8565b3480156109bb57600080fd5b506104566109ca366004613c4a565b611f26565b3480156109db57600080fd5b5060105461042b906001600160a01b031681565b3480156109fb57600080fd5b5061061d610a0a3660046137f4565b611fb7565b348015610a1b57600080fd5b50610456610a2a3660046137f4565b6121fc565b348015610a3b57600080fd5b5061042b7f000000000000000000000000000000000000000000000000000000000000000081565b348015610a6f57600080fd5b506103a6600080516020613fb983398151915281565b348015610a9157600080fd5b50610456610aa03660046138fd565b6122c4565b348015610ab157600080fd5b50610456610ac03660046138fd565b6122cf565b6000610ad0826122da565b80610adf5750610adf82612328565b92915050565b606060058054610af490613c65565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2090613c65565b8015610b6d5780601f10610b4257610100808354040283529160200191610b6d565b820191906000526020600020905b815481529060010190602001808311610b5057829003601f168201915b5050505050905090565b6000610b828261235d565b610b9f576040516333d1c03960e21b815260040160405180910390fd5b506000908152600960205260409020546001600160a01b031690565b6000610bc6826111f3565b9050336001600160a01b03821614610bff57610be28133611eb8565b610bff576040516367d9dca160e11b815260040160405180910390fd5b60008281526009602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000610adf601383612392565b6000610adf600d83612392565b6000610c80826123aa565b9050836001600160a01b0316816001600160a01b031614610cb35760405162a1148160e81b815260040160405180910390fd5b60008281526009602052604090208054610cdf8187335b6001600160a01b039081169116811491141790565b610d0a57610ced8633611eb8565b610d0a57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610d3157604051633a954ecd60e21b815260040160405180910390fd5b8015610d3c57600082555b6001600160a01b038681166000908152600860205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260076020526040902055600160e11b8316610dc75760018401600081815260076020526040902054610dc5576003548114610dc55760008181526007602052604090208490555b505b83856001600160a01b0316876001600160a01b0316600080516020613fd983398151915260405160405180910390a4505050505050565b600080516020613fb9833981519152610e178133612413565b600f546001600160a01b0383811691161415610e465760405163df82d43b60e01b815260040160405180910390fd5b600f80546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f79fba93312e9194e8ea4394b9bd3250d14e5de3a148c097cea369b0f6522487191015b60405180910390a1505050565b60008281526001602081905260409091200154610ec68133612413565b610ed08383612477565b505050565b600080516020613fb9833981519152610eee8133612413565b6010546001600160a01b0383811691161415610f1d5760405163df82d43b60e01b815260040160405180910390fd5b601080546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f5dd729082de1a21e31b76d239f00d2c4b212ad6bb86abd4cc22510df65926a3c9101610e9c565b6001600160a01b0381163314610fec5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610ff682826124e2565b5050565b60006110068133612413565b6110103347612549565b50565b610ed083838360405180602001604052806000815250611c3b565b600080516020613fb98339815191526110478133612413565b61104f612662565b60405160200161105f9190613ca0565b604051602081830303815290604052805190602001208383604051602001611088929190613cbc565b6040516020818303038152906040528051906020012014156110bd5760405163df82d43b60e01b815260040160405180910390fd5b60006110c7612662565b90506110d5600c8585613622565b507f309b29ded109b9e28fb9885757b3e0096eb75c51d23aa4635d68bcd569f6adc181858560405161110993929190613ccc565b60405180910390a150505050565b6060816000816001600160401b0381111561113457611134613b05565b60405190808252806020026020018201604052801561118657816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816111525790505b50905060005b8281146111d9576111b48686838181106111a8576111a8613d12565b90506020020135611c7f565b8282815181106111c6576111c6613d12565b602090810291909101015260010161118c565b50949350505050565b60606111ee6013612671565b905090565b6000610adf826123aa565b600f546060906001600160a01b031661122a57604051635467b26b60e01b815260040160405180910390fd5b6010546001600160a01b03166112535760405163afeb453960e01b815260040160405180910390fd5b601054604051632118854760e21b81526001600160a01b0384811660048301526000921690638462151c9060240160006040518083038186803b15801561129957600080fd5b505afa1580156112ad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112d59190810190613d28565b9050600081516001600160401b038111156112f2576112f2613b05565b60405190808252806020026020018201604052801561131b578160200160208202803683370190505b5090506000805b825181101561155357600084828151811061133f5761133f613d12565b6020908102919091010151601054604051626eef5b60e51b8152600481018390529192506000916001600160a01b0390911690630dddeb609060240160206040518083038186803b15801561139357600080fd5b505afa1580156113a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113cb9190613dcd565b905060006113d883610c5b565b151560011415905060006002600f5460405163794b2a0760e01b8152600481018690526001600160a01b039091169063794b2a079060240160206040518083038186803b15801561142857600080fd5b505afa15801561143c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114609190613de6565b6003811115611471576114716139f4565b6010546040516336af181960e11b8152600481018890529290911492506000916002916001600160a01b031690636d5e30329060240160206040518083038186803b1580156114bf57600080fd5b505afa1580156114d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f79190613dcd565b101590508280156115055750815b801561150e5750805b1561153d578488888151811061152657611526613d12565b602090810291909101015261153a87613e1d565b96505b50505050508061154c90613e1d565b9050611322565b506000816001600160401b0381111561156e5761156e613b05565b604051908082528060200260200182016040528015611597578160200160208202803683370190505b50905060005b828110156115ec578381815181106115b7576115b7613d12565b60200260200101518282815181106115d1576115d1613d12565b60209081029190910101526115e581613e1d565b905061159d565b5095945050505050565b600c805461160390613c65565b80601f016020809104026020016040519081016040528092919081815260200182805461162f90613c65565b801561167c5780601f106116515761010080835404028352916020019161167c565b820191906000526020600020905b81548152906001019060200180831161165f57829003601f168201915b505050505081565b60006001600160a01b0382166116ad576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600860205260409020546001600160401b031690565b6000546001600160a01b0316331461172c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fe3565b611736600061267e565b565b6000611743826126ce565b1515600114611765576040516307ed98ed60e31b815260040160405180910390fd5b611770601183612392565b1561177d57506003919050565b506001919050565b6002805414156117d75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610fe3565b60028055600b5460ff1615156001146118035760405163914edb0f60e01b815260040160405180910390fd5b61180b6126e4565b1561182957604051638a164f6360e01b815260040160405180910390fd5b6118348282336126fd565b151560011461185657604051635ada107360e11b815260040160405180910390fd5b611861838383612b49565b5050600160025550565b6060600080600061187b85611684565b90506000816001600160401b0381111561189757611897613b05565b6040519080825280602002602001820160405280156118c0578160200160208202803683370190505b5090506118ed60408051608081018252600080825260208201819052918101829052606081019190915290565b60015b83861461196e5761190081612bcc565b915081604001511561191157611966565b81516001600160a01b03161561192657815194505b876001600160a01b0316856001600160a01b03161415611966578083878060010198508151811061195957611959613d12565b6020026020010181815250505b6001016118f0565b50909695505050505050565b60606111ee600d612671565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060068054610af490613c65565b60608183106119e257604051631960ccad60e11b815260040160405180910390fd5b6000806119ee60035490565b905060018510156119fe57600194505b80841115611a0a578093505b6000611a1587611684565b905084861015611a345785850381811015611a2e578091505b50611a38565b5060005b6000816001600160401b03811115611a5257611a52613b05565b604051908082528060200260200182016040528015611a7b578160200160208202803683370190505b50905081611a8e579350611b4492505050565b6000611a9988611c7f565b905060008160400151611aaa575080515b885b888114158015611abc5750848714155b15611b3857611aca81612bcc565b9250826040015115611adb57611b30565b82516001600160a01b031615611af057825191505b8a6001600160a01b0316826001600160a01b03161415611b305780848880600101995081518110611b2357611b23613d12565b6020026020010181815250505b600101611aac565b50505092835250909150505b9392505050565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006111ee6003546000190190565b7f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc611bf18133612413565b60005b82811015611c35576000848483818110611c1057611c10613d12565b905060200201359050611c24816000612c08565b50611c2e81613e1d565b9050611bf4565b50505050565b611c46848484610c75565b6001600160a01b0383163b15611c3557611c6284848484612d3a565b611c35576040516368d2bf6b60e11b815260040160405180910390fd5b6040805160808101825260008082526020820181905291810182905260608101919091526040805160808101825260008082526020820181905291810182905260608101919091526001831080611cd857506003548310155b15611ce35792915050565b611cec83612bcc565b9050806040015115611cfe5792915050565b611b4483612e31565b600280541415611d595760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610fe3565b60028055600b5460ff161515600114611d855760405163914edb0f60e01b815260040160405180910390fd5b611d8d6126e4565b15611dab57604051638a164f6360e01b815260040160405180910390fd5b611db6828233612e66565b1515600114611dd85760405163a4633ea560e01b815260040160405180910390fd5b611861838383613131565b6060611dee8261235d565b611e0b57604051630a14c4b560e41b815260040160405180910390fd5b6000611e15612662565b9050805160001415611e365760405180602001604052806000815250611b44565b80611e40846131aa565b604051602001611e51929190613e38565b6040516020818303038152906040529392505050565b60008281526001602081905260409091200154611e848133612413565b610ed083836124e2565b6001600160a01b038116600090815260086020526040808220546001600160401b03911c16610adf565b6001600160a01b038083166000908152600a6020908152604080832093851683529290529081205460ff1615611ef057506001610adf565b6001600160a01b038216731e0049783f008a0085193e00003d00cd54003c711415611f1d57506001610adf565b50600092915050565b600080516020613fb9833981519152611f3f8133612413565b600b5460ff1615158215151415611f695760405163df82d43b60e01b815260040160405180910390fd5b600b805460ff191683151590811790915560405160ff909116151581527f4f6846e1a6a026ffba330735c9ca2845cfe23bccb44541d241c637b8542fa7a09060200160405180910390a15050565b60607f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031661200057604051636f2c3cd960e01b815260040160405180910390fd5b604051632118854760e21b81526001600160a01b0383811660048301526000917f000000000000000000000000000000000000000000000000000000000000000090911690638462151c9060240160006040518083038186803b15801561206657600080fd5b505afa15801561207a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526120a29190810190613d28565b9050600081516001600160401b038111156120bf576120bf613b05565b6040519080825280602002602001820160405280156120e8578160200160208202803683370190505b5090506000805b825181101561216357600084828151811061210c5761210c613d12565b6020026020010151905061211f81610c68565b1515600114612152578084848151811061213b5761213b613d12565b602090810291909101015261214f83613e1d565b92505b5061215c81613e1d565b90506120ef565b506000816001600160401b0381111561217e5761217e613b05565b6040519080825280602002602001820160405280156121a7578160200160208202803683370190505b50905060005b828110156115ec578381815181106121c7576121c7613d12565b60200260200101518282815181106121e1576121e1613d12565b60209081029190910101526121f581613e1d565b90506121ad565b6000546001600160a01b031633146122565760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fe3565b6001600160a01b0381166122bb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610fe3565b6110108161267e565b610ff6338383611d07565b610ff6338383611785565b60006301ffc9a760e01b6001600160e01b03198316148061230b57506380ac58cd60e01b6001600160e01b03198316145b80610adf5750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b03198216637965db0b60e01b1480610adf57506301ffc9a760e01b6001600160e01b0319831614610adf565b600081600111158015612371575060035482105b8015610adf575050600090815260076020526040902054600160e01b161590565b60008181526001830160205260408120541515611b44565b600081806001116123fa576003548110156123fa57600081815260076020526040902054600160e01b81166123f8575b80611b445750600019016000818152600760205260409020546123da565b505b604051636f96cda160e11b815260040160405180910390fd5b61241d8282611986565b610ff657612435816001600160a01b031660146131f8565b6124408360206131f8565b604051602001612451929190613e67565b60408051601f198184030181529082905262461bcd60e51b8252610fe391600401613746565b6124818282611986565b610ff65760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6124ec8282611986565b15610ff65760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b804710156125995760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610fe3565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146125e6576040519150601f19603f3d011682016040523d82523d6000602084013e6125eb565b606091505b5050905080610ed05760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610fe3565b6060600c8054610af490613c65565b60606000611b4483613393565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060018210158015610adf5750506003541190565b60006107d06126f66003546000190190565b1015905090565b600f546000906001600160a01b031661272957604051635467b26b60e01b815260040160405180910390fd5b6010546001600160a01b03166127525760405163afeb453960e01b815260040160405180910390fd5b600f546040805163d5abeb0160e01b815290516001926000926001600160a01b039091169163d5abeb0191600480820192602092909190829003018186803b15801561279d57600080fd5b505afa1580156127b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d59190613dcd565b6001600160401b038111156127ec576127ec613b05565b604051908082528060200260200182016040528015612815578160200160208202803683370190505b50905060005b85811080156128275750825b15612b3e57600087878381811061284057612840613d12565b601054604051626eef5b60e51b815260209290920293909301356004820181905293506000926001600160a01b03169150630dddeb609060240160206040518083038186803b15801561289257600080fd5b505afa1580156128a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ca9190613dcd565b905060006128d9600184613edc565b905060006128f5600080516020613fb98339815191528a611986565b8061298457506010546040516331a9108f60e11b8152600481018690526001600160a01b038b8116921690636352211e9060240160206040518083038186803b15801561294157600080fd5b505afa158015612955573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129799190613ef3565b6001600160a01b0316145b9050600061299185610c5b565b1515600115151415905060008784815181106129af576129af613d12565b602090810291909101015115905060006002600f5460405163794b2a0760e01b8152600481018990526001600160a01b039091169063794b2a079060240160206040518083038186803b158015612a0557600080fd5b505afa158015612a19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a3d9190613de6565b6003811115612a4e57612a4e6139f4565b6010546040516336af181960e11b8152600481018b90529290911492506000916002916001600160a01b031690636d5e30329060240160206040518083038186803b158015612a9c57600080fd5b505afa158015612ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad49190613dcd565b10159050848015612ae25750835b8015612aeb5750825b8015612af45750815b8015612afd5750805b9a5060018a8781518110612b1357612b13613d12565b602002602001019015159081151581525050505050505050505080612b3790613e1d565b905061281b565b509095945050505050565b6000612b54826133ef565b905060005b81811015612bc1576000848483818110612b7557612b75613d12565b905060200201359050600082612b8a60035490565b612b949190613f10565b9050612ba1601383613417565b50612bad601182613417565b50505080612bba90613e1d565b9050612b59565b50611c358482613423565b604080516080810182526000808252602082018190529181018290526060810191909152600082815260076020526040902054610adf9061343d565b6000612c13836123aa565b905080600080612c3186600090815260096020526040902080549091565b915091508415612c7157612c46818433610cca565b612c7157612c548333611eb8565b612c7157604051632ce44b5f60e11b815260040160405180910390fd5b8015612c7c57600082555b6001600160a01b038316600081815260086020526040902080546fffffffffffffffffffffffffffffffff0190554260a01b17600360e01b17600087815260076020526040902055600160e11b8416612d035760018601600081815260076020526040902054612d01576003548114612d015760008181526007602052604090208590555b505b60405186906000906001600160a01b03861690600080516020613fd9833981519152908390a4505060048054600101905550505050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612d6f903390899088908890600401613f28565b602060405180830381600087803b158015612d8957600080fd5b505af1925050508015612db9575060408051601f3d908101601f19168201909252612db691810190613f65565b60015b612e14573d808015612de7576040519150601f19603f3d011682016040523d82523d6000602084013e612dec565b606091505b508051612e0c576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b604080516080810182526000808252602082018190529181018290526060810191909152610adf612e61836123aa565b61343d565b60007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316612eaf57604051636f2c3cd960e01b815260040160405180910390fd5b60006001905060007f00000000000000000000000000000000000000000000000000000000000000006001600160a01b031663d5abeb016040518163ffffffff1660e01b815260040160206040518083038186803b158015612f1057600080fd5b505afa158015612f24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f489190613dcd565b6001600160401b03811115612f5f57612f5f613b05565b604051908082528060200260200182016040528015612f88578160200160208202803683370190505b50905060005b8581108015612f9a5750825b15612b3e576000878783818110612fb357612fb3613d12565b9050602002013590506000612fc6600190565b612fd09083613edc565b90506000612fec600080516020613fb983398151915289611986565b806130a55750876001600160a01b03167f00000000000000000000000000000000000000000000000000000000000000006001600160a01b0316636352211e856040518263ffffffff1660e01b815260040161304a91815260200190565b60206040518083038186803b15801561306257600080fd5b505afa158015613076573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061309a9190613ef3565b6001600160a01b0316145b905060006130b4600d85612392565b1515600115151415905060008684815181106130d2576130d2613d12565b60209081029190910101511590508280156130ea5750815b80156130f35750805b9750600187858151811061310957613109613d12565b60200260200101901515908115158152505050505050508061312a90613e1d565b9050612f8e565b600260005b82811080156131455750600282145b156131a35761315460026133ef565b915081156131935761318884848381811061317157613171613d12565b90506020020135600d61341790919063ffffffff16565b506131938583613423565b61319c81613e1d565b9050613136565b5050505050565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806131e1576131e6565b6131c4565b50819003601f19909101908152919050565b60606000613207836002613f82565b613212906002613f10565b6001600160401b0381111561322957613229613b05565b6040519080825280601f01601f191660200182016040528015613253576020820181803683370190505b509050600360fc1b8160008151811061326e5761326e613d12565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061329d5761329d613d12565b60200101906001600160f81b031916908160001a90535060006132c1846002613f82565b6132cc906001613f10565b90505b6001811115613344576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061330057613300613d12565b1a60f81b82828151811061331657613316613d12565b60200101906001600160f81b031916908160001a90535060049490941c9361333d81613fa1565b90506132cf565b508315611b445760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610fe3565b6060816000018054806020026020016040519081016040528092919081815260200182805480156133e357602002820191906000526020600020905b8154815260200190600101908083116133cf575b50505050509050919050565b6000806133ff6003546000190190565b61340b906107d0613edc565b9050611b448382613484565b6000611b44838361349a565b610ff68282604051806020016040528060008152506134e9565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b60008183106134935781611b44565b5090919050565b60008181526001830160205260408120546134e157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610adf565b506000610adf565b6134f3838361354f565b6001600160a01b0383163b15610ed0576003548281035b61351d6000868380600101945086612d3a565b61353a576040516368d2bf6b60e11b815260040160405180910390fd5b81811061350a5781600354146131a357600080fd5b600354816135705760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526008602090815260408083208054680100000000000000018802019055848352600790915281206001851460e11b4260a01b17831790558284019083908390600080516020613fd98339815191528180a4600183015b8181146135fb5780836000600080516020613fd9833981519152600080a46001016135d5565b508161361957604051622e076360e81b815260040160405180910390fd5b60035550505050565b82805461362e90613c65565b90600052602060002090601f0160209004810192826136505760008555613696565b82601f106136695782800160ff19823516178555613696565b82800160010185558215613696579182015b8281111561369657823582559160200191906001019061367b565b506136a29291506136a6565b5090565b5b808211156136a257600081556001016136a7565b6001600160e01b03198116811461101057600080fd5b6000602082840312156136e357600080fd5b8135611b44816136bb565b60005b838110156137095781810151838201526020016136f1565b83811115611c355750506000910152565b600081518084526137328160208601602086016136ee565b601f01601f19169290920160200192915050565b602081526000611b44602083018461371a565b60006020828403121561376b57600080fd5b5035919050565b6001600160a01b038116811461101057600080fd5b6000806040838503121561379a57600080fd5b82356137a581613772565b946020939093013593505050565b6000806000606084860312156137c857600080fd5b83356137d381613772565b925060208401356137e381613772565b929592945050506040919091013590565b60006020828403121561380657600080fd5b8135611b4481613772565b6000806040838503121561382457600080fd5b82359150602083013561383681613772565b809150509250929050565b6000806020838503121561385457600080fd5b82356001600160401b038082111561386b57600080fd5b818501915085601f83011261387f57600080fd5b81358181111561388e57600080fd5b8660208285010111156138a057600080fd5b60209290920196919550909350505050565b60008083601f8401126138c457600080fd5b5081356001600160401b038111156138db57600080fd5b6020830191508360208260051b85010111156138f657600080fd5b9250929050565b6000806020838503121561391057600080fd5b82356001600160401b0381111561392657600080fd5b613932858286016138b2565b90969095509350505050565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b6020808252825182820181905260009190848201906040850190845b8181101561196e576139a983855161393e565b9284019260809290920191600101613996565b6020808252825182820181905260009190848201906040850190845b8181101561196e578351835292840192918401916001016139d8565b634e487b7160e01b600052602160045260246000fd5b6020810160048310613a2c57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600060408486031215613a4757600080fd5b8335613a5281613772565b925060208401356001600160401b03811115613a6d57600080fd5b613a79868287016138b2565b9497909650939450505050565b600080600060608486031215613a9b57600080fd5b8335613aa681613772565b95602085013595506040909401359392505050565b80358015158114613acb57600080fd5b919050565b60008060408385031215613ae357600080fd5b8235613aee81613772565b9150613afc60208401613abb565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613b4357613b43613b05565b604052919050565b60008060008060808587031215613b6157600080fd5b8435613b6c81613772565b9350602085810135613b7d81613772565b93506040860135925060608601356001600160401b0380821115613ba057600080fd5b818801915088601f830112613bb457600080fd5b813581811115613bc657613bc6613b05565b613bd8601f8201601f19168501613b1b565b91508082528984828501011115613bee57600080fd5b808484018584013760008482840101525080935050505092959194509250565b60808101610adf828461393e565b60008060408385031215613c2f57600080fd5b8235613c3a81613772565b9150602083013561383681613772565b600060208284031215613c5c57600080fd5b611b4482613abb565b600181811c90821680613c7957607f821691505b60208210811415613c9a57634e487b7160e01b600052602260045260246000fd5b50919050565b60008251613cb28184602087016136ee565b9190910192915050565b8183823760009101908152919050565b604081526000613cdf604083018661371a565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b634e487b7160e01b600052603260045260246000fd5b60006020808385031215613d3b57600080fd5b82516001600160401b0380821115613d5257600080fd5b818501915085601f830112613d6657600080fd5b815181811115613d7857613d78613b05565b8060051b9150613d89848301613b1b565b8181529183018401918481019088841115613da357600080fd5b938501935b83851015613dc157845182529385019390850190613da8565b98975050505050505050565b600060208284031215613ddf57600080fd5b5051919050565b600060208284031215613df857600080fd5b815160048110611b4457600080fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415613e3157613e31613e07565b5060010190565b60008351613e4a8184602088016136ee565b835190830190613e5e8183602088016136ee565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613e9f8160178501602088016136ee565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613ed08160288401602088016136ee565b01602801949350505050565b600082821015613eee57613eee613e07565b500390565b600060208284031215613f0557600080fd5b8151611b4481613772565b60008219821115613f2357613f23613e07565b500190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613f5b9083018461371a565b9695505050505050565b600060208284031215613f7757600080fd5b8151611b44816136bb565b6000816000190483118215151615613f9c57613f9c613e07565b500290565b600081613fb057613fb0613e07565b50600019019056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220aef9f7486e51ce7fb9074145cdf264d16d3e7eefbea85636e10d4ef2d62f88df64736f6c63430008090033000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b70000000000000000000000006ab3dcca416ab4a8a1c94da71e4d60b321779c2c000000000000000000000000d1f07a57928b42202bb8e964dd1954bd0dec8b3400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000003868747470733a2f2f6d657461646174612e746572726170696e67656e657369732e636f6d2f746f6b656e2d756e6976657273652d7663702f00000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c329d2dc3685ed3be3209b33daf37f60347c969d000000000000000000000000b643c924632f71ac70a982ebc7e4099620f076c1

Deployed Bytecode

0x60806040526004361061038c5760003560e01c80637fa46ab4116101dc578063c87b56dd11610102578063ee1cc944116100a0578063f4cc37bd1161006f578063f4cc37bd14610a2f578063f5b541a614610a63578063f8e93ef914610a85578063f9afb26a14610aa557600080fd5b8063ee1cc944146109af578063f07a886e146109cf578063f26b6e1a146109ef578063f2fde38b14610a0f57600080fd5b8063dc33e681116100dc578063dc33e6811461093a578063de0ce17d1461095a578063e43058471461096f578063e985e9c51461098f57600080fd5b8063c87b56dd146108e4578063d547741f14610904578063d5abeb011461092457600080fd5b806399a2557a1161017a578063b80f55c911610149578063b80f55c914610864578063b88d4fde14610884578063c23dc68f14610897578063c847bc64146108c457600080fd5b806399a2557a146107fa578063a217fddf1461081a578063a22cb4651461082f578063a2309ff81461084f57600080fd5b80638a88487d116101b65780638a88487d146107925780638da5cb5b146107a757806391d14854146107c557806395d89b41146107e557600080fd5b80637fa46ab4146107295780638462151c1461075d57806387f65c911461077d57600080fd5b80632fa32eb9116102c15780636352211e1161025f57806370a082311161022e57806370a08231146106a7578063715018a6146106c7578063794b2a07146106dc5780637c1f9eb11461070957600080fd5b80636352211e1461062a578063640d79a61461064a5780636c0360eb1461066a578063702d53941461067f57600080fd5b806342842e0e1161029b57806342842e0e146105a857806355f804b3146105bb5780635bbb2177146105db57806360378c5a1461060857600080fd5b80632fa32eb91461055357806336568abe146105735780633ccfd60b1461059357600080fd5b80631a8997441161032e578063248a9ca311610308578063248a9ca3146104c857806325fd90f3146104f95780632cc70dcc146105135780632f2ff15d1461053357600080fd5b80631a899744146104955780631be4782b1461039157806323b872dd146104b557600080fd5b8063081812fc1161036a578063081812fc1461040b578063095ea7b31461044357806318160ddd146104585780631867d33d1461047557600080fd5b80630164f0881461039157806301ffc9a7146103b957806306fdde03146103e9575b600080fd5b34801561039d57600080fd5b506103a6600281565b6040519081526020015b60405180910390f35b3480156103c557600080fd5b506103d96103d43660046136d1565b610ac5565b60405190151581526020016103b0565b3480156103f557600080fd5b506103fe610ae5565b6040516103b09190613746565b34801561041757600080fd5b5061042b610426366004613759565b610b77565b6040516001600160a01b0390911681526020016103b0565b610456610451366004613787565b610bbb565b005b34801561046457600080fd5b5060045460035403600019016103a6565b34801561048157600080fd5b506103d9610490366004613759565b610c5b565b3480156104a157600080fd5b506103d96104b0366004613759565b610c68565b6104566104c33660046137b3565b610c75565b3480156104d457600080fd5b506103a66104e3366004613759565b6000908152600160208190526040909120015490565b34801561050557600080fd5b50600b546103d99060ff1681565b34801561051f57600080fd5b5061045661052e3660046137f4565b610dfe565b34801561053f57600080fd5b5061045661054e366004613811565b610ea9565b34801561055f57600080fd5b5061045661056e3660046137f4565b610ed5565b34801561057f57600080fd5b5061045661058e366004613811565b610f77565b34801561059f57600080fd5b50610456610ffa565b6104566105b63660046137b3565b611013565b3480156105c757600080fd5b506104566105d6366004613841565b61102e565b3480156105e757600080fd5b506105fb6105f63660046138fd565b611117565b6040516103b0919061397a565b34801561061457600080fd5b5061061d6111e2565b6040516103b091906139bc565b34801561063657600080fd5b5061042b610645366004613759565b6111f3565b34801561065657600080fd5b5061061d6106653660046137f4565b6111fe565b34801561067657600080fd5b506103fe6115f6565b34801561068b57600080fd5b5061042b731e0049783f008a0085193e00003d00cd54003c7181565b3480156106b357600080fd5b506103a66106c23660046137f4565b611684565b3480156106d357600080fd5b506104566116d2565b3480156106e857600080fd5b506106fc6106f7366004613759565b611738565b6040516103b09190613a0a565b34801561071557600080fd5b50610456610724366004613a32565b611785565b34801561073557600080fd5b506103a67f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc81565b34801561076957600080fd5b5061061d6107783660046137f4565b61186b565b34801561078957600080fd5b506103a6600181565b34801561079e57600080fd5b5061061d61197a565b3480156107b357600080fd5b506000546001600160a01b031661042b565b3480156107d157600080fd5b506103d96107e0366004613811565b611986565b3480156107f157600080fd5b506103fe6119b1565b34801561080657600080fd5b5061061d610815366004613a86565b6119c0565b34801561082657600080fd5b506103a6600081565b34801561083b57600080fd5b5061045661084a366004613ad0565b611b4b565b34801561085b57600080fd5b506103a6611bb7565b34801561087057600080fd5b5061045661087f3660046138fd565b611bc6565b610456610892366004613b4b565b611c3b565b3480156108a357600080fd5b506108b76108b2366004613759565b611c7f565b6040516103b09190613c0e565b3480156108d057600080fd5b506104566108df366004613a32565b611d07565b3480156108f057600080fd5b506103fe6108ff366004613759565b611de3565b34801561091057600080fd5b5061045661091f366004613811565b611e67565b34801561093057600080fd5b506103a66107d081565b34801561094657600080fd5b506103a66109553660046137f4565b611e8e565b34801561096657600080fd5b5061042b600081565b34801561097b57600080fd5b50600f5461042b906001600160a01b031681565b34801561099b57600080fd5b506103d96109aa366004613c1c565b611eb8565b3480156109bb57600080fd5b506104566109ca366004613c4a565b611f26565b3480156109db57600080fd5b5060105461042b906001600160a01b031681565b3480156109fb57600080fd5b5061061d610a0a3660046137f4565b611fb7565b348015610a1b57600080fd5b50610456610a2a3660046137f4565b6121fc565b348015610a3b57600080fd5b5061042b7f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b781565b348015610a6f57600080fd5b506103a6600080516020613fb983398151915281565b348015610a9157600080fd5b50610456610aa03660046138fd565b6122c4565b348015610ab157600080fd5b50610456610ac03660046138fd565b6122cf565b6000610ad0826122da565b80610adf5750610adf82612328565b92915050565b606060058054610af490613c65565b80601f0160208091040260200160405190810160405280929190818152602001828054610b2090613c65565b8015610b6d5780601f10610b4257610100808354040283529160200191610b6d565b820191906000526020600020905b815481529060010190602001808311610b5057829003601f168201915b5050505050905090565b6000610b828261235d565b610b9f576040516333d1c03960e21b815260040160405180910390fd5b506000908152600960205260409020546001600160a01b031690565b6000610bc6826111f3565b9050336001600160a01b03821614610bff57610be28133611eb8565b610bff576040516367d9dca160e11b815260040160405180910390fd5b60008281526009602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b6000610adf601383612392565b6000610adf600d83612392565b6000610c80826123aa565b9050836001600160a01b0316816001600160a01b031614610cb35760405162a1148160e81b815260040160405180910390fd5b60008281526009602052604090208054610cdf8187335b6001600160a01b039081169116811491141790565b610d0a57610ced8633611eb8565b610d0a57604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b038516610d3157604051633a954ecd60e21b815260040160405180910390fd5b8015610d3c57600082555b6001600160a01b038681166000908152600860205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260076020526040902055600160e11b8316610dc75760018401600081815260076020526040902054610dc5576003548114610dc55760008181526007602052604090208490555b505b83856001600160a01b0316876001600160a01b0316600080516020613fd983398151915260405160405180910390a4505050505050565b600080516020613fb9833981519152610e178133612413565b600f546001600160a01b0383811691161415610e465760405163df82d43b60e01b815260040160405180910390fd5b600f80546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f79fba93312e9194e8ea4394b9bd3250d14e5de3a148c097cea369b0f6522487191015b60405180910390a1505050565b60008281526001602081905260409091200154610ec68133612413565b610ed08383612477565b505050565b600080516020613fb9833981519152610eee8133612413565b6010546001600160a01b0383811691161415610f1d5760405163df82d43b60e01b815260040160405180910390fd5b601080546001600160a01b038481166001600160a01b031983168117909355604080519190921680825260208201939093527f5dd729082de1a21e31b76d239f00d2c4b212ad6bb86abd4cc22510df65926a3c9101610e9c565b6001600160a01b0381163314610fec5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610ff682826124e2565b5050565b60006110068133612413565b6110103347612549565b50565b610ed083838360405180602001604052806000815250611c3b565b600080516020613fb98339815191526110478133612413565b61104f612662565b60405160200161105f9190613ca0565b604051602081830303815290604052805190602001208383604051602001611088929190613cbc565b6040516020818303038152906040528051906020012014156110bd5760405163df82d43b60e01b815260040160405180910390fd5b60006110c7612662565b90506110d5600c8585613622565b507f309b29ded109b9e28fb9885757b3e0096eb75c51d23aa4635d68bcd569f6adc181858560405161110993929190613ccc565b60405180910390a150505050565b6060816000816001600160401b0381111561113457611134613b05565b60405190808252806020026020018201604052801561118657816020015b6040805160808101825260008082526020808301829052928201819052606082015282526000199092019101816111525790505b50905060005b8281146111d9576111b48686838181106111a8576111a8613d12565b90506020020135611c7f565b8282815181106111c6576111c6613d12565b602090810291909101015260010161118c565b50949350505050565b60606111ee6013612671565b905090565b6000610adf826123aa565b600f546060906001600160a01b031661122a57604051635467b26b60e01b815260040160405180910390fd5b6010546001600160a01b03166112535760405163afeb453960e01b815260040160405180910390fd5b601054604051632118854760e21b81526001600160a01b0384811660048301526000921690638462151c9060240160006040518083038186803b15801561129957600080fd5b505afa1580156112ad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526112d59190810190613d28565b9050600081516001600160401b038111156112f2576112f2613b05565b60405190808252806020026020018201604052801561131b578160200160208202803683370190505b5090506000805b825181101561155357600084828151811061133f5761133f613d12565b6020908102919091010151601054604051626eef5b60e51b8152600481018390529192506000916001600160a01b0390911690630dddeb609060240160206040518083038186803b15801561139357600080fd5b505afa1580156113a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906113cb9190613dcd565b905060006113d883610c5b565b151560011415905060006002600f5460405163794b2a0760e01b8152600481018690526001600160a01b039091169063794b2a079060240160206040518083038186803b15801561142857600080fd5b505afa15801561143c573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114609190613de6565b6003811115611471576114716139f4565b6010546040516336af181960e11b8152600481018890529290911492506000916002916001600160a01b031690636d5e30329060240160206040518083038186803b1580156114bf57600080fd5b505afa1580156114d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906114f79190613dcd565b101590508280156115055750815b801561150e5750805b1561153d578488888151811061152657611526613d12565b602090810291909101015261153a87613e1d565b96505b50505050508061154c90613e1d565b9050611322565b506000816001600160401b0381111561156e5761156e613b05565b604051908082528060200260200182016040528015611597578160200160208202803683370190505b50905060005b828110156115ec578381815181106115b7576115b7613d12565b60200260200101518282815181106115d1576115d1613d12565b60209081029190910101526115e581613e1d565b905061159d565b5095945050505050565b600c805461160390613c65565b80601f016020809104026020016040519081016040528092919081815260200182805461162f90613c65565b801561167c5780601f106116515761010080835404028352916020019161167c565b820191906000526020600020905b81548152906001019060200180831161165f57829003601f168201915b505050505081565b60006001600160a01b0382166116ad576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600860205260409020546001600160401b031690565b6000546001600160a01b0316331461172c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fe3565b611736600061267e565b565b6000611743826126ce565b1515600114611765576040516307ed98ed60e31b815260040160405180910390fd5b611770601183612392565b1561177d57506003919050565b506001919050565b6002805414156117d75760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610fe3565b60028055600b5460ff1615156001146118035760405163914edb0f60e01b815260040160405180910390fd5b61180b6126e4565b1561182957604051638a164f6360e01b815260040160405180910390fd5b6118348282336126fd565b151560011461185657604051635ada107360e11b815260040160405180910390fd5b611861838383612b49565b5050600160025550565b6060600080600061187b85611684565b90506000816001600160401b0381111561189757611897613b05565b6040519080825280602002602001820160405280156118c0578160200160208202803683370190505b5090506118ed60408051608081018252600080825260208201819052918101829052606081019190915290565b60015b83861461196e5761190081612bcc565b915081604001511561191157611966565b81516001600160a01b03161561192657815194505b876001600160a01b0316856001600160a01b03161415611966578083878060010198508151811061195957611959613d12565b6020026020010181815250505b6001016118f0565b50909695505050505050565b60606111ee600d612671565b60009182526001602090815260408084206001600160a01b0393909316845291905290205460ff1690565b606060068054610af490613c65565b60608183106119e257604051631960ccad60e11b815260040160405180910390fd5b6000806119ee60035490565b905060018510156119fe57600194505b80841115611a0a578093505b6000611a1587611684565b905084861015611a345785850381811015611a2e578091505b50611a38565b5060005b6000816001600160401b03811115611a5257611a52613b05565b604051908082528060200260200182016040528015611a7b578160200160208202803683370190505b50905081611a8e579350611b4492505050565b6000611a9988611c7f565b905060008160400151611aaa575080515b885b888114158015611abc5750848714155b15611b3857611aca81612bcc565b9250826040015115611adb57611b30565b82516001600160a01b031615611af057825191505b8a6001600160a01b0316826001600160a01b03161415611b305780848880600101995081518110611b2357611b23613d12565b6020026020010181815250505b600101611aac565b50505092835250909150505b9392505050565b336000818152600a602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b60006111ee6003546000190190565b7f44ac9762eec3a11893fefb11d028bb3102560094137c3ed4518712475b2577cc611bf18133612413565b60005b82811015611c35576000848483818110611c1057611c10613d12565b905060200201359050611c24816000612c08565b50611c2e81613e1d565b9050611bf4565b50505050565b611c46848484610c75565b6001600160a01b0383163b15611c3557611c6284848484612d3a565b611c35576040516368d2bf6b60e11b815260040160405180910390fd5b6040805160808101825260008082526020820181905291810182905260608101919091526040805160808101825260008082526020820181905291810182905260608101919091526001831080611cd857506003548310155b15611ce35792915050565b611cec83612bcc565b9050806040015115611cfe5792915050565b611b4483612e31565b600280541415611d595760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610fe3565b60028055600b5460ff161515600114611d855760405163914edb0f60e01b815260040160405180910390fd5b611d8d6126e4565b15611dab57604051638a164f6360e01b815260040160405180910390fd5b611db6828233612e66565b1515600114611dd85760405163a4633ea560e01b815260040160405180910390fd5b611861838383613131565b6060611dee8261235d565b611e0b57604051630a14c4b560e41b815260040160405180910390fd5b6000611e15612662565b9050805160001415611e365760405180602001604052806000815250611b44565b80611e40846131aa565b604051602001611e51929190613e38565b6040516020818303038152906040529392505050565b60008281526001602081905260409091200154611e848133612413565b610ed083836124e2565b6001600160a01b038116600090815260086020526040808220546001600160401b03911c16610adf565b6001600160a01b038083166000908152600a6020908152604080832093851683529290529081205460ff1615611ef057506001610adf565b6001600160a01b038216731e0049783f008a0085193e00003d00cd54003c711415611f1d57506001610adf565b50600092915050565b600080516020613fb9833981519152611f3f8133612413565b600b5460ff1615158215151415611f695760405163df82d43b60e01b815260040160405180910390fd5b600b805460ff191683151590811790915560405160ff909116151581527f4f6846e1a6a026ffba330735c9ca2845cfe23bccb44541d241c637b8542fa7a09060200160405180910390a15050565b60607f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b76001600160a01b031661200057604051636f2c3cd960e01b815260040160405180910390fd5b604051632118854760e21b81526001600160a01b0383811660048301526000917f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b790911690638462151c9060240160006040518083038186803b15801561206657600080fd5b505afa15801561207a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526120a29190810190613d28565b9050600081516001600160401b038111156120bf576120bf613b05565b6040519080825280602002602001820160405280156120e8578160200160208202803683370190505b5090506000805b825181101561216357600084828151811061210c5761210c613d12565b6020026020010151905061211f81610c68565b1515600114612152578084848151811061213b5761213b613d12565b602090810291909101015261214f83613e1d565b92505b5061215c81613e1d565b90506120ef565b506000816001600160401b0381111561217e5761217e613b05565b6040519080825280602002602001820160405280156121a7578160200160208202803683370190505b50905060005b828110156115ec578381815181106121c7576121c7613d12565b60200260200101518282815181106121e1576121e1613d12565b60209081029190910101526121f581613e1d565b90506121ad565b6000546001600160a01b031633146122565760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610fe3565b6001600160a01b0381166122bb5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610fe3565b6110108161267e565b610ff6338383611d07565b610ff6338383611785565b60006301ffc9a760e01b6001600160e01b03198316148061230b57506380ac58cd60e01b6001600160e01b03198316145b80610adf5750506001600160e01b031916635b5e139f60e01b1490565b60006001600160e01b03198216637965db0b60e01b1480610adf57506301ffc9a760e01b6001600160e01b0319831614610adf565b600081600111158015612371575060035482105b8015610adf575050600090815260076020526040902054600160e01b161590565b60008181526001830160205260408120541515611b44565b600081806001116123fa576003548110156123fa57600081815260076020526040902054600160e01b81166123f8575b80611b445750600019016000818152600760205260409020546123da565b505b604051636f96cda160e11b815260040160405180910390fd5b61241d8282611986565b610ff657612435816001600160a01b031660146131f8565b6124408360206131f8565b604051602001612451929190613e67565b60408051601f198184030181529082905262461bcd60e51b8252610fe391600401613746565b6124818282611986565b610ff65760008281526001602081815260408084206001600160a01b0386168086529252808420805460ff19169093179092559051339285917f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d9190a45050565b6124ec8282611986565b15610ff65760008281526001602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b804710156125995760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610fe3565b6000826001600160a01b03168260405160006040518083038185875af1925050503d80600081146125e6576040519150601f19603f3d011682016040523d82523d6000602084013e6125eb565b606091505b5050905080610ed05760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610fe3565b6060600c8054610af490613c65565b60606000611b4483613393565b600080546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b600060018210158015610adf5750506003541190565b60006107d06126f66003546000190190565b1015905090565b600f546000906001600160a01b031661272957604051635467b26b60e01b815260040160405180910390fd5b6010546001600160a01b03166127525760405163afeb453960e01b815260040160405180910390fd5b600f546040805163d5abeb0160e01b815290516001926000926001600160a01b039091169163d5abeb0191600480820192602092909190829003018186803b15801561279d57600080fd5b505afa1580156127b1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906127d59190613dcd565b6001600160401b038111156127ec576127ec613b05565b604051908082528060200260200182016040528015612815578160200160208202803683370190505b50905060005b85811080156128275750825b15612b3e57600087878381811061284057612840613d12565b601054604051626eef5b60e51b815260209290920293909301356004820181905293506000926001600160a01b03169150630dddeb609060240160206040518083038186803b15801561289257600080fd5b505afa1580156128a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906128ca9190613dcd565b905060006128d9600184613edc565b905060006128f5600080516020613fb98339815191528a611986565b8061298457506010546040516331a9108f60e11b8152600481018690526001600160a01b038b8116921690636352211e9060240160206040518083038186803b15801561294157600080fd5b505afa158015612955573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906129799190613ef3565b6001600160a01b0316145b9050600061299185610c5b565b1515600115151415905060008784815181106129af576129af613d12565b602090810291909101015115905060006002600f5460405163794b2a0760e01b8152600481018990526001600160a01b039091169063794b2a079060240160206040518083038186803b158015612a0557600080fd5b505afa158015612a19573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a3d9190613de6565b6003811115612a4e57612a4e6139f4565b6010546040516336af181960e11b8152600481018b90529290911492506000916002916001600160a01b031690636d5e30329060240160206040518083038186803b158015612a9c57600080fd5b505afa158015612ab0573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612ad49190613dcd565b10159050848015612ae25750835b8015612aeb5750825b8015612af45750815b8015612afd5750805b9a5060018a8781518110612b1357612b13613d12565b602002602001019015159081151581525050505050505050505080612b3790613e1d565b905061281b565b509095945050505050565b6000612b54826133ef565b905060005b81811015612bc1576000848483818110612b7557612b75613d12565b905060200201359050600082612b8a60035490565b612b949190613f10565b9050612ba1601383613417565b50612bad601182613417565b50505080612bba90613e1d565b9050612b59565b50611c358482613423565b604080516080810182526000808252602082018190529181018290526060810191909152600082815260076020526040902054610adf9061343d565b6000612c13836123aa565b905080600080612c3186600090815260096020526040902080549091565b915091508415612c7157612c46818433610cca565b612c7157612c548333611eb8565b612c7157604051632ce44b5f60e11b815260040160405180910390fd5b8015612c7c57600082555b6001600160a01b038316600081815260086020526040902080546fffffffffffffffffffffffffffffffff0190554260a01b17600360e01b17600087815260076020526040902055600160e11b8416612d035760018601600081815260076020526040902054612d01576003548114612d015760008181526007602052604090208590555b505b60405186906000906001600160a01b03861690600080516020613fd9833981519152908390a4505060048054600101905550505050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290612d6f903390899088908890600401613f28565b602060405180830381600087803b158015612d8957600080fd5b505af1925050508015612db9575060408051601f3d908101601f19168201909252612db691810190613f65565b60015b612e14573d808015612de7576040519150601f19603f3d011682016040523d82523d6000602084013e612dec565b606091505b508051612e0c576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050949350505050565b604080516080810182526000808252602082018190529181018290526060810191909152610adf612e61836123aa565b61343d565b60007f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b76001600160a01b0316612eaf57604051636f2c3cd960e01b815260040160405180910390fd5b60006001905060007f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b76001600160a01b031663d5abeb016040518163ffffffff1660e01b815260040160206040518083038186803b158015612f1057600080fd5b505afa158015612f24573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612f489190613dcd565b6001600160401b03811115612f5f57612f5f613b05565b604051908082528060200260200182016040528015612f88578160200160208202803683370190505b50905060005b8581108015612f9a5750825b15612b3e576000878783818110612fb357612fb3613d12565b9050602002013590506000612fc6600190565b612fd09083613edc565b90506000612fec600080516020613fb983398151915289611986565b806130a55750876001600160a01b03167f000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b76001600160a01b0316636352211e856040518263ffffffff1660e01b815260040161304a91815260200190565b60206040518083038186803b15801561306257600080fd5b505afa158015613076573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061309a9190613ef3565b6001600160a01b0316145b905060006130b4600d85612392565b1515600115151415905060008684815181106130d2576130d2613d12565b60209081029190910101511590508280156130ea5750815b80156130f35750805b9750600187858151811061310957613109613d12565b60200260200101901515908115158152505050505050508061312a90613e1d565b9050612f8e565b600260005b82811080156131455750600282145b156131a35761315460026133ef565b915081156131935761318884848381811061317157613171613d12565b90506020020135600d61341790919063ffffffff16565b506131938583613423565b61319c81613e1d565b9050613136565b5050505050565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806131e1576131e6565b6131c4565b50819003601f19909101908152919050565b60606000613207836002613f82565b613212906002613f10565b6001600160401b0381111561322957613229613b05565b6040519080825280601f01601f191660200182016040528015613253576020820181803683370190505b509050600360fc1b8160008151811061326e5761326e613d12565b60200101906001600160f81b031916908160001a905350600f60fb1b8160018151811061329d5761329d613d12565b60200101906001600160f81b031916908160001a90535060006132c1846002613f82565b6132cc906001613f10565b90505b6001811115613344576f181899199a1a9b1b9c1cb0b131b232b360811b85600f166010811061330057613300613d12565b1a60f81b82828151811061331657613316613d12565b60200101906001600160f81b031916908160001a90535060049490941c9361333d81613fa1565b90506132cf565b508315611b445760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610fe3565b6060816000018054806020026020016040519081016040528092919081815260200182805480156133e357602002820191906000526020600020905b8154815260200190600101908083116133cf575b50505050509050919050565b6000806133ff6003546000190190565b61340b906107d0613edc565b9050611b448382613484565b6000611b44838361349a565b610ff68282604051806020016040528060008152506134e9565b604080516080810182526001600160a01b038316815260a083901c6001600160401b03166020820152600160e01b831615159181019190915260e89190911c606082015290565b60008183106134935781611b44565b5090919050565b60008181526001830160205260408120546134e157508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610adf565b506000610adf565b6134f3838361354f565b6001600160a01b0383163b15610ed0576003548281035b61351d6000868380600101945086612d3a565b61353a576040516368d2bf6b60e11b815260040160405180910390fd5b81811061350a5781600354146131a357600080fd5b600354816135705760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526008602090815260408083208054680100000000000000018802019055848352600790915281206001851460e11b4260a01b17831790558284019083908390600080516020613fd98339815191528180a4600183015b8181146135fb5780836000600080516020613fd9833981519152600080a46001016135d5565b508161361957604051622e076360e81b815260040160405180910390fd5b60035550505050565b82805461362e90613c65565b90600052602060002090601f0160209004810192826136505760008555613696565b82601f106136695782800160ff19823516178555613696565b82800160010185558215613696579182015b8281111561369657823582559160200191906001019061367b565b506136a29291506136a6565b5090565b5b808211156136a257600081556001016136a7565b6001600160e01b03198116811461101057600080fd5b6000602082840312156136e357600080fd5b8135611b44816136bb565b60005b838110156137095781810151838201526020016136f1565b83811115611c355750506000910152565b600081518084526137328160208601602086016136ee565b601f01601f19169290920160200192915050565b602081526000611b44602083018461371a565b60006020828403121561376b57600080fd5b5035919050565b6001600160a01b038116811461101057600080fd5b6000806040838503121561379a57600080fd5b82356137a581613772565b946020939093013593505050565b6000806000606084860312156137c857600080fd5b83356137d381613772565b925060208401356137e381613772565b929592945050506040919091013590565b60006020828403121561380657600080fd5b8135611b4481613772565b6000806040838503121561382457600080fd5b82359150602083013561383681613772565b809150509250929050565b6000806020838503121561385457600080fd5b82356001600160401b038082111561386b57600080fd5b818501915085601f83011261387f57600080fd5b81358181111561388e57600080fd5b8660208285010111156138a057600080fd5b60209290920196919550909350505050565b60008083601f8401126138c457600080fd5b5081356001600160401b038111156138db57600080fd5b6020830191508360208260051b85010111156138f657600080fd5b9250929050565b6000806020838503121561391057600080fd5b82356001600160401b0381111561392657600080fd5b613932858286016138b2565b90969095509350505050565b80516001600160a01b031682526020808201516001600160401b03169083015260408082015115159083015260609081015162ffffff16910152565b6020808252825182820181905260009190848201906040850190845b8181101561196e576139a983855161393e565b9284019260809290920191600101613996565b6020808252825182820181905260009190848201906040850190845b8181101561196e578351835292840192918401916001016139d8565b634e487b7160e01b600052602160045260246000fd5b6020810160048310613a2c57634e487b7160e01b600052602160045260246000fd5b91905290565b600080600060408486031215613a4757600080fd5b8335613a5281613772565b925060208401356001600160401b03811115613a6d57600080fd5b613a79868287016138b2565b9497909650939450505050565b600080600060608486031215613a9b57600080fd5b8335613aa681613772565b95602085013595506040909401359392505050565b80358015158114613acb57600080fd5b919050565b60008060408385031215613ae357600080fd5b8235613aee81613772565b9150613afc60208401613abb565b90509250929050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f191681016001600160401b0381118282101715613b4357613b43613b05565b604052919050565b60008060008060808587031215613b6157600080fd5b8435613b6c81613772565b9350602085810135613b7d81613772565b93506040860135925060608601356001600160401b0380821115613ba057600080fd5b818801915088601f830112613bb457600080fd5b813581811115613bc657613bc6613b05565b613bd8601f8201601f19168501613b1b565b91508082528984828501011115613bee57600080fd5b808484018584013760008482840101525080935050505092959194509250565b60808101610adf828461393e565b60008060408385031215613c2f57600080fd5b8235613c3a81613772565b9150602083013561383681613772565b600060208284031215613c5c57600080fd5b611b4482613abb565b600181811c90821680613c7957607f821691505b60208210811415613c9a57634e487b7160e01b600052602260045260246000fd5b50919050565b60008251613cb28184602087016136ee565b9190910192915050565b8183823760009101908152919050565b604081526000613cdf604083018661371a565b8281036020840152838152838560208301376000602085830101526020601f19601f860116820101915050949350505050565b634e487b7160e01b600052603260045260246000fd5b60006020808385031215613d3b57600080fd5b82516001600160401b0380821115613d5257600080fd5b818501915085601f830112613d6657600080fd5b815181811115613d7857613d78613b05565b8060051b9150613d89848301613b1b565b8181529183018401918481019088841115613da357600080fd5b938501935b83851015613dc157845182529385019390850190613da8565b98975050505050505050565b600060208284031215613ddf57600080fd5b5051919050565b600060208284031215613df857600080fd5b815160048110611b4457600080fd5b634e487b7160e01b600052601160045260246000fd5b6000600019821415613e3157613e31613e07565b5060010190565b60008351613e4a8184602088016136ee565b835190830190613e5e8183602088016136ee565b01949350505050565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000815260008351613e9f8160178501602088016136ee565b7001034b99036b4b9b9b4b733903937b6329607d1b6017918401918201528351613ed08160288401602088016136ee565b01602801949350505050565b600082821015613eee57613eee613e07565b500390565b600060208284031215613f0557600080fd5b8151611b4481613772565b60008219821115613f2357613f23613e07565b500190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613f5b9083018461371a565b9695505050505050565b600060208284031215613f7757600080fd5b8151611b44816136bb565b6000816000190483118215151615613f9c57613f9c613e07565b500290565b600081613fb057613fb0613e07565b50600019019056fe97667070c54ef182b0f5858b034beac1b6f3089aa2d3188bb1e8929f4fa9b929ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3efa2646970667358221220aef9f7486e51ce7fb9074145cdf264d16d3e7eefbea85636e10d4ef2d62f88df64736f6c63430008090033

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

000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b70000000000000000000000006ab3dcca416ab4a8a1c94da71e4d60b321779c2c000000000000000000000000d1f07a57928b42202bb8e964dd1954bd0dec8b3400000000000000000000000000000000000000000000000000000000000000a00000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000003868747470733a2f2f6d657461646174612e746572726170696e67656e657369732e636f6d2f746f6b656e2d756e6976657273652d7663702f00000000000000000000000000000000000000000000000000000000000000000000000000000002000000000000000000000000c329d2dc3685ed3be3209b33daf37f60347c969d000000000000000000000000b643c924632f71ac70a982ebc7e4099620f076c1

-----Decoded View---------------
Arg [0] : terrapinGenesis_ (address): 0xf68f9Bf35312C228c9D213f31c477c92032d80b7
Arg [1] : terrapinUniverseHeroesCardPack_ (address): 0x6ab3dcCA416AB4a8A1C94DA71e4d60B321779c2C
Arg [2] : terrapinUniverseHeroes_ (address): 0xD1f07a57928B42202Bb8e964Dd1954bD0deC8b34
Arg [3] : baseURI_ (string): https://metadata.terrapingenesis.com/token-universe-vcp/
Arg [4] : operators (address[]): 0xC329D2dC3685eD3BE3209b33DAF37f60347c969d,0xb643c924632f71ac70a982Ebc7E4099620f076C1

-----Encoded View---------------
11 Constructor Arguments found :
Arg [0] : 000000000000000000000000f68f9bf35312c228c9d213f31c477c92032d80b7
Arg [1] : 0000000000000000000000006ab3dcca416ab4a8a1c94da71e4d60b321779c2c
Arg [2] : 000000000000000000000000d1f07a57928b42202bb8e964dd1954bd0dec8b34
Arg [3] : 00000000000000000000000000000000000000000000000000000000000000a0
Arg [4] : 0000000000000000000000000000000000000000000000000000000000000100
Arg [5] : 0000000000000000000000000000000000000000000000000000000000000038
Arg [6] : 68747470733a2f2f6d657461646174612e746572726170696e67656e65736973
Arg [7] : 2e636f6d2f746f6b656e2d756e6976657273652d7663702f0000000000000000
Arg [8] : 0000000000000000000000000000000000000000000000000000000000000002
Arg [9] : 000000000000000000000000c329d2dc3685ed3be3209b33daf37f60347c969d
Arg [10] : 000000000000000000000000b643c924632f71ac70a982ebc7e4099620f076c1


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.