ETH Price: $3,349.33 (-2.03%)

Contract

0xe2a72079b5f7E3cF3DAC893C3DC1D650794cE701
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
GuildURIHandler

Compiler Version
v0.8.13+commit.abaa5c0e

Optimization Enabled:
Yes with 200 runs

Other Settings:
default evmVersion
File 1 of 23 : GuildURIHandler.sol
// SPDX-License-Identifier: MIT

/// @title RaidParty Guild URI Handler

/**
 *   ___      _    _ ___          _
 *  | _ \__ _(_)__| | _ \__ _ _ _| |_ _  _
 *  |   / _` | / _` |  _/ _` | '_|  _| || |
 *  |_|_\__,_|_\__,_|_| \__,_|_|  \__|\_, |
 *                                    |__/
 */

pragma solidity ^0.8.0;

import "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol";
import "@openzeppelin/contracts-upgradeable/access/AccessControlEnumerableUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/IERC721Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/ECDSAUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/cryptography/draft-EIP712Upgradeable.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/utils/ERC721HolderUpgradeable.sol";
import "@openzeppelin/contracts-upgradeable/utils/math/MathUpgradeable.sol";
import "../interfaces/IGuildURIHandler.sol";
import "../interfaces/IERC20Burnable.sol";
import "../interfaces/IParty.sol";

contract GuildURIHandler is
    Initializable,
    AccessControlEnumerableUpgradeable,
    EIP712Upgradeable,
    ERC721HolderUpgradeable,
    IGuildURIHandler
{
    using StringsUpgradeable for uint256;
    using ECDSAUpgradeable for bytes32;

    /** EVENTS */

    /// @notice Emitted when a user joins a given guild.
    event Join(address indexed user, uint256 indexed guildId);

    /// @notice Emitted when a user leaves a given guild.
    event Leave(address indexed user, uint256 indexed guildId);

    /// @notice Emitted when a user initiates a vault deposit.
    event VaultDeposit(address indexed user, uint256 amount);

    /// @notice Emitted when GCFTI is minted to a user.
    event Mint(address indexed user, uint256 amount);

    /// @notice Emitted when a user deposits GCFTI to a guild.
    event Deposit(
        address indexed user,
        uint256 indexed guildId,
        uint256 amount
    );

    /// @notice Emitted when a user stakes a hero.
    event Stake(address indexed user, uint256 hero);

    /// @notice Emitted when a user unstakes a hero.
    event Unstake(address indexed user, uint256 hero);

    /// @notice Emitted when a user upgrades their base guild level.
    event Upgrade(uint256 indexed guildId, uint16 level);

    /// @notice Emitted when a user upgrades the tech tree on a given guild.
    event UpgradeTechTree(uint256 indexed guildId, Branch branch, uint16 level);

    /** ERRORS */

    /// @notice Public state-changing functions are currently paused.
    error Paused();

    /// @notice Hero already staked.
    error HeroPresent();

    /// @notice No hero is currently staked.
    error HeroNotPresent();

    /// @notice User is currently in a guild.
    error GuildPresent();

    /// @notice User is not currently in a guild.
    error GuildNotPresent();

    /// @notice Guild has reached it's membership capacity.
    error GuildAtCapacity();

    /// @notice User is not currently in a guild.
    error GuildAtMaxLevel();

    /// @notice Insufficient funds to complete an operation.
    error InsufficientFunds(uint256 missingAmount);

    /// @notice User is not currently the owner of a given guild.
    error GuildNotOwned();

    /// @notice User is not currently a member of a given guild.
    error NotGuildMember();

    /// @notice Forage delay not yet passed.
    error ForageDelay(uint256 delay);

    /// @notice Invite redeemer is not a recipient.
    error NotRecipient();

    /// @notice Level requirement for upgrade not met.
    error LevelRequirementNotMet(Branch branch);

    /// @notice Name too long.
    error OutOfBounds();

    /// @notice Name taken.
    error NameUnavailable();

    /// @notice Invite timeout passed.
    error TimeoutExceeded();

    /// @notice Insufficient permissions.
    error InsufficientPermissions();

    /** CONSTANTS */

    uint16 private constant MAX_LEVEL = 5;
    uint16 private constant MAX_BRANCH_LEVEL = 5;

    string public constant INVITE_NAME = "Invite";
    string public constant INVITE_VERSION = "1";
    bytes32 public constant INVITE_TYPEHASH =
        keccak256("Invite(address user,uint256 guildId,uint256 timeout)");

    bytes32 public constant GCFTI_MINTER_ROLE = keccak256("GCFTI_MINTER_ROLE");

    /// @notice Precision of GCFTI / vault balance
    uint64 public constant DECIMALS = 10**3;
    /// @notice Decimal difference between GCFTI / vault balance and CFTI
    uint64 public constant DECIMAL_DELTA = 10**15;

    uint64 public constant FORAGE_DELAY = 1 weeks;
    uint64 public constant FORAGE_REWARD = 50 * DECIMALS;

    /** STATE */

    IERC721Upgradeable private _guild;
    IERC721Upgradeable private _hero;
    IERC20Burnable private _confetti;
    IParty private _party;
    address private _team;
    bool private _paused;

    mapping(uint256 => Guild) private _guilds;
    mapping(address => Member) private _members;
    mapping(bytes32 => bool) private _names;

    /** MODIFIERS */

    modifier whenNotPaused() {
        if (_paused) revert Paused();
        _;
    }

    /** ADMIN */

    function initialize(
        address admin,
        IERC721Upgradeable guild,
        IERC721Upgradeable hero,
        IERC20Burnable confetti,
        IParty party
    ) public initializer {
        __AccessControl_init();
        __EIP712_init(INVITE_NAME, INVITE_VERSION);
        _setupRole(DEFAULT_ADMIN_ROLE, admin);
        _setupRole(GCFTI_MINTER_ROLE, admin);
        _confetti = IERC20Burnable(confetti);
        _team = admin;
        _guild = guild;
        _hero = hero;
        _party = party;
        _paused = true;
    }

    function pause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _paused = true;
    }

    function unpause() external onlyRole(DEFAULT_ADMIN_ROLE) {
        _paused = false;
    }

    /**
     * @notice Mints GCFTI to a given user.
     */
    function mint(address user, uint64 amount)
        external
        onlyRole(GCFTI_MINTER_ROLE)
        whenNotPaused
    {
        _mint(user, amount);
    }

    //** UTILITY */

    /**
     * @notice Sets a 32 byte name for a guild.
     */
    function setName(uint256 guildId, string calldata name)
        external
        whenNotPaused
    {
        if (bytes(name).length > 32) revert OutOfBounds();
        if (_guild.ownerOf(guildId) != msg.sender) revert GuildNotOwned();

        // Reset name if it was previously set
        if (_guilds[guildId].name != bytes32(0)) {
            _names[_guilds[guildId].name] = false;
        }

        // Check name availability
        bytes32 bName = bytes32(bytes(name));
        if (bName != bytes32(0)) {
            if (_names[bName]) revert NameUnavailable();
            _names[bName] = true;
        }

        // Set name
        _guilds[guildId].name = bName;
    }

    /**
     * @notice Locks CFTI into a users guild vault given an input amount.
     * Vault balances are further used for in-game effects.
     */
    function vaultDeposit(uint256 amount) external whenNotPaused {
        _confetti.burnFrom(msg.sender, amount);

        uint64 guildConfetti = toGuildConfetti(amount);

        // Convert CFTI amount directly into a lower precision value
        _members[msg.sender].vault += guildConfetti;
        // NOTE: Guild vault is an aggregate sum of each member's vault
        if (_members[msg.sender].guildId != 0) {
            _guilds[_members[msg.sender].guildId].vault += guildConfetti;
        }

        emit VaultDeposit(msg.sender, amount);
    }

    /**
     * @notice Locks CFTI in a form of a guild gCFTI balance, used for guild
     * progression.
     */
    function deposit(uint256 amount) external whenNotPaused {
        Member storage member = _members[msg.sender];
        if (member.guildId == 0) revert GuildNotPresent();
        Guild storage guild = _guilds[member.guildId];

        _confetti.burnFrom(msg.sender, amount);

        // When contributing CFTI to a guild, a user earns gCFTI in 1:1 ratio
        // but gets a linear bonus percentage of up to 100% depending on the guild vault.
        // NOTE: We specifically first calculate the rewards and only update
        // the guild vault afterwards, so the benefit is only for in subsequent deposits
        uint64 gcfti = _calculateRewards(amount, guild);
        guild.balance += gcfti;
        // Player vault is also filled by half of their direct deposit to a guild,
        // irrespective of the calculated reward amount
        uint64 vaultReward = toGuildConfetti(amount) / 2;
        member.vault += vaultReward;
        // ...and guild's vault is an aggregate sum of their member's vault
        guild.vault += vaultReward;

        emit Deposit(msg.sender, member.guildId, gcfti);
    }

    /**
     * @dev Convenience function that adjusts CFTI to GCFTI decimals
     */
    function toGuildConfetti(uint256 confetti)
        internal
        pure
        returns (uint64 gcfti)
    {
        unchecked {
            gcfti = uint64(confetti / DECIMAL_DELTA);
        }
    }

    /**
     * @notice Stake a hero.
     */
    function stake(uint32 id) external whenNotPaused {
        Member storage member = _members[msg.sender];
        if (member.hero != 0) revert HeroPresent();

        member.hero = id;
        member.lastForage = uint64(block.timestamp);

        _hero.safeTransferFrom(msg.sender, address(this), id);

        emit Stake(msg.sender, id);
    }

    /**
     * @notice Unstake a hero.
     */
    function unstake() external whenNotPaused {
        Member storage member = _members[msg.sender];
        uint32 hero = member.hero;
        if (hero == 0) revert HeroNotPresent();

        member.hero = 0;

        _hero.safeTransferFrom(address(this), msg.sender, hero);

        emit Unstake(msg.sender, hero);
    }

    /**
     * @notice Forage for GCFTI. This can occur once per time period if a user has staked a hero.
     */
    function forage() external whenNotPaused {
        Member storage member = _members[msg.sender];
        if (member.hero == 0) revert HeroNotPresent();
        if ((block.timestamp - member.lastForage) < FORAGE_DELAY)
            revert ForageDelay(block.timestamp - member.lastForage);
        uint64 count = (uint64(block.timestamp) - member.lastForage) /
            FORAGE_DELAY;
        member.lastForage = uint64(
            (block.timestamp / FORAGE_DELAY) * FORAGE_DELAY
        );
        _mint(msg.sender, count * FORAGE_REWARD);
    }

    /**
     * @notice Accepts a guild invite.
     */
    function join(Invite calldata invite, bytes memory signature)
        external
        whenNotPaused
    {
        if (invite.timeout < block.timestamp) revert TimeoutExceeded();

        Member storage member = _members[msg.sender];
        if (member.guildId != 0) revert GuildPresent();
        _verifyInvite(invite, signature);

        Guild storage guild = _guilds[invite.guildId];
        if (guild.members.length >= _getMaxMembers(guild.level))
            revert GuildAtCapacity();
        member.guildId = invite.guildId;
        member.lastForage = uint64(block.timestamp);
        member.slot = uint16(guild.members.length);
        // NOTE: Guild vault is an aggregate sum of each member's vault
        guild.vault += member.vault;
        guild.members.push(msg.sender);

        emit Join(msg.sender, invite.guildId);
    }

    /**
     * @notice Leaves the users current guild.
     */
    function leave() external whenNotPaused {
        Member storage member = _members[msg.sender];
        if (member.guildId == 0) revert GuildNotPresent();

        _removeMember(msg.sender, member);
    }

    /**
     * @notice Kicks a user from the guild.
     */
    function kick(address user) external whenNotPaused {
        Member storage member = _members[user];
        if (_guild.ownerOf(member.guildId) != msg.sender)
            revert GuildNotOwned();

        _removeMember(user, member);
    }

    /**
     * @notice Sets user authorization to spend gCFTI.
     */
    function setAuthorization(
        uint256 guildId,
        address user,
        bool authorized
    ) external whenNotPaused {
        if (_guild.ownerOf(guildId) != msg.sender) revert GuildNotOwned();

        if (_members[user].guildId != guildId) revert GuildNotPresent();

        _members[user].permissions = (authorized) ? 1 : 0;
    }

    /**
     * @notice Upgrades a guild's level.
     */
    function upgrade(uint256 guildId) external whenNotPaused {
        if (
            _guild.ownerOf(guildId) != msg.sender &&
            _members[msg.sender].permissions != 1
        ) revert InsufficientPermissions();

        Guild storage guild = _guilds[guildId];
        if (guild.level >= MAX_LEVEL) revert GuildAtMaxLevel();

        uint64 cost = getLevelCost(guild.level);
        if (cost > guild.balance)
            revert InsufficientFunds(cost - guild.balance);

        guild.balance -= cost;
        guild.level += 1;

        emit Upgrade(guildId, guild.level);
    }

    /**
     * @notice Upgrades a guild's tech tree.
     */
    function upgradeTechTree(uint256 guildId, Branch branch)
        external
        whenNotPaused
    {
        if (
            _guild.ownerOf(guildId) != msg.sender &&
            _members[msg.sender].permissions != 1
        ) revert InsufficientPermissions();

        Guild storage guild = _guilds[guildId];
        uint256 tree = guild.techTree;
        if (guild.level < uint16(branch)) revert LevelRequirementNotMet(branch);

        uint64 cost = getTreeCost(_getTechTreeLevel(tree, branch), branch);
        if (cost > guild.balance)
            revert InsufficientFunds(cost - guild.balance);

        guild.balance -= cost;
        tree = _incrementTechTreeLevel(tree, branch);
        guild.techTree = tree;

        emit UpgradeTechTree(guildId, branch, _getTechTreeLevel(tree, branch));
    }

    /** VIEWS */

    function getName(uint256 guildId) public view returns (string memory) {
        bytes32 name = _guilds[guildId].name;

        if (name == bytes32(0)) {
            return string(abi.encodePacked("Guild #", guildId.toString()));
        } else {
            return string(abi.encodePacked(_guilds[guildId].name));
        }
    }

    function tokenURI(uint256 tokenId) public pure returns (string memory) {
        return string(abi.encodePacked(_baseURI(), tokenId.toString()));
    }

    function getMaxMembers(uint256 guildId) public view returns (uint16) {
        uint16 level = _guilds[guildId].level;
        return _getMaxMembers(level);
    }

    function getMembers(uint256 guildId)
        external
        view
        returns (address[] memory)
    {
        return _guilds[guildId].members;
    }

    function getGuildLevel(uint256 guildId) external view returns (uint16) {
        return _guilds[guildId].level;
    }

    function getGuildTechLevel(uint256 guildId, Branch branch)
        external
        view
        returns (uint16)
    {
        return _getTechTreeLevel(_guilds[guildId].techTree, branch);
    }

    function getGuildTechTree(uint256 guildId)
        public
        view
        returns (TechTree memory)
    {
        return _getTechTree(_guilds[guildId].techTree);
    }

    function getGuildVault(uint256 guildId) external view returns (uint64) {
        return _guilds[guildId].vault;
    }

    function getGuildBalance(uint256 guildId) external view returns (uint64) {
        return _guilds[guildId].balance;
    }

    function getGuildData(uint256 guildId)
        external
        view
        returns (
            uint64 balance,
            uint16 level,
            uint64 vault,
            TechTree memory techTree,
            address[] memory members,
            string memory name
        )
    {
        Guild storage guild = _guilds[guildId];
        balance = guild.balance;
        level = guild.level;
        vault = guild.vault;
        members = guild.members;
        techTree = getGuildTechTree(guildId);
        name = getName(guildId);
    }

    function calculateRewards(uint256 rewards, uint256 guildId)
        external
        view
        returns (uint64)
    {
        return guildId == 0 ? 0 : _calculateRewards(rewards, _guilds[guildId]);
    }

    function getMember(address user) external view returns (Member memory) {
        return _members[user];
    }

    function getGuild(address user) external view returns (uint256) {
        return _members[user].guildId;
    }

    function getTreeCost(uint16 level, Branch branch)
        public
        pure
        returns (uint64)
    {
        uint64 cost;

        if (branch == Branch.FRUGALITY) {
            if (level == 0) {
                cost = 5_000;
            } else if (level == 1) {
                cost = 10_000;
            } else if (level == 2) {
                cost = 20_000;
            } else if (level == 3) {
                cost = 50_000;
            } else {
                cost = 100_000;
            }
        } else if (branch == Branch.DISCIPLINE) {
            if (level == 0) {
                cost = 10_000;
            } else if (level == 1) {
                cost = 20_000;
            } else if (level == 2) {
                cost = 50_000;
            } else if (level == 3) {
                cost = 100_000;
            } else {
                cost = 250_000;
            }
        } else if (branch == Branch.MORALE) {
            if (level == 0) {
                cost = 20_000;
            } else if (level == 1) {
                cost = 50_000;
            } else if (level == 2) {
                cost = 100_000;
            } else if (level == 3) {
                cost = 250_000;
            } else {
                cost = 500_000;
            }
        } else if (branch == Branch.INDEMNITY) {
            if (level == 0) {
                cost = 50_000;
            } else if (level == 1) {
                cost = 100_000;
            } else if (level == 2) {
                cost = 250_000;
            } else if (level == 3) {
                cost = 500_000;
            } else {
                cost = 1_000_000;
            }
        } else if (branch == Branch.SUPERSTITION) {
            if (level == 0) {
                cost = 100_000;
            } else if (level == 1) {
                cost = 250_000;
            } else if (level == 2) {
                cost = 500_000;
            } else if (level == 3) {
                cost = 1_000_000;
            } else {
                cost = 2_000_000;
            }
        } else {
            if (level == 0) {
                cost = 250_000;
            } else if (level == 1) {
                cost = 500_000;
            } else if (level == 2) {
                cost = 1_000_000;
            } else if (level == 3) {
                cost = 2_000_000;
            } else {
                cost = 4_000_000;
            }
        }

        return cost * DECIMALS;
    }

    function getLevelCost(uint16 level) public pure returns (uint64) {
        uint64 cost;

        if (level == 0) {
            cost = 10_000;
        } else if (level == 1) {
            cost = 20_000;
        } else if (level == 2) {
            cost = 40_000;
        } else if (level == 3) {
            cost = 160_000;
        } else {
            cost = 2_560_000;
        }

        return cost * DECIMALS;
    }

    function isAuthorized(address user) external view returns (bool) {
        return _members[user].permissions == 1;
    }

    function supportsInterface(bytes4 interfaceId)
        public
        view
        override(AccessControlEnumerableUpgradeable)
        returns (bool)
    {
        return super.supportsInterface(interfaceId);
    }

    function inviteHash(Invite calldata invite) public view returns (bytes32) {
        return
            _hashTypedDataV4(
                keccak256(
                    abi.encode(
                        INVITE_TYPEHASH,
                        invite.user,
                        invite.guildId,
                        invite.timeout
                    )
                )
            );
    }

    /** INTERNAL */

    function _baseURI() internal pure returns (string memory) {
        return "https://api.raid.party/metadata/guild/";
    }

    function _verifyInvite(Invite calldata invite, bytes memory signature)
        internal
        view
    {
        if (invite.user != msg.sender) revert NotRecipient();
        bytes32 hash = inviteHash(invite);
        address signer = ECDSAUpgradeable.recover(hash, signature);
        if (signer != _guild.ownerOf(invite.guildId)) revert GuildNotOwned();
    }

    function _mint(address user, uint64 amount) internal {
        Member storage member = _members[user];
        if (member.guildId == 0) revert GuildNotPresent();

        _guilds[member.guildId].balance += amount;

        emit Mint(user, amount);
    }

    function _getMaxMembers(uint16 level) internal pure returns (uint16) {
        if (level == 0) {
            return 10;
        } else if (level == 1) {
            return 15;
        } else if (level == 2) {
            return 25;
        } else if (level == 3) {
            return 35;
        } else if (level == 4) {
            return 50;
        } else {
            return 100;
        }
    }

    function _getTechTreeLevel(uint256 tree, Branch branch)
        internal
        pure
        returns (uint16)
    {
        unchecked {
            return uint16(tree >> (uint256(branch) * 16));
        }
    }

    function _getTechTree(uint256 tree)
        internal
        pure
        returns (TechTree memory)
    {
        TechTree memory techTree;

        assembly {
            mstore(techTree, tree)
            mstore(add(techTree, 0x20), shr(16, tree))
            mstore(add(techTree, 0x40), shr(32, tree))
            mstore(add(techTree, 0x60), shr(48, tree))
            mstore(add(techTree, 0x80), shr(64, tree))
            mstore(add(techTree, 0xa0), shr(80, tree))
        }

        return techTree;
    }

    function _incrementTechTreeLevel(uint256 tree, Branch branch)
        internal
        pure
        returns (uint256)
    {
        unchecked {
            if (_getTechTreeLevel(tree, branch) >= MAX_BRANCH_LEVEL)
                revert GuildAtMaxLevel();
            return tree + (1 << (uint256(branch) * 16));
        }
    }

    function _calculateRewards(uint256 rewards, Guild memory guild)
        internal
        pure
        returns (uint64)
    {
        unchecked {
            return
                toGuildConfetti(
                    rewards +
                        // Guild vault gives linearly up to extra +100% rewards,
                        // capped at 3M gCFTI (10^3 precision).
                        ((rewards *
                            MathUpgradeable.min(guild.vault, 3_000_000e3)) /
                            3_000_000e3)
                );
        }
    }

    function _removeMember(address user, Member storage member) internal {
        uint256 guildId = member.guildId;
        Guild storage guild = _guilds[guildId];
        // NOTE: Guild vault is an aggregate sum of each member's vault
        guild.vault -= member.vault;

        if (member.slot != (guild.members.length - 1)) {
            (
                guild.members[member.slot],
                guild.members[guild.members.length - 1]
            ) = (
                guild.members[guild.members.length - 1],
                guild.members[member.slot]
            );
            _members[guild.members[member.slot]].slot = member.slot;
        }
        guild.members.pop();

        member.permissions = 0;
        member.guildId = 0;
        member.slot = 0;

        _party.updateDamage(user);

        emit Leave(user, guildId);
    }
}

File 2 of 23 : StringsUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)

pragma solidity ^0.8.0;

/**
 * @dev String operations.
 */
library StringsUpgradeable {
    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 3 of 23 : Initializable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (proxy/utils/Initializable.sol)

pragma solidity ^0.8.2;

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

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

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

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

    /**
     * @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
     * `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
     */
    modifier initializer() {
        bool isTopLevelCall = _setInitializedVersion(1);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(1);
        }
    }

    /**
     * @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
     * contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
     * used to initialize parent contracts.
     *
     * `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
     * initialization step. This is essential to configure modules that are added through upgrades and that require
     * initialization.
     *
     * Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
     * a contract, executing them in the right order is up to the developer or operator.
     */
    modifier reinitializer(uint8 version) {
        bool isTopLevelCall = _setInitializedVersion(version);
        if (isTopLevelCall) {
            _initializing = true;
        }
        _;
        if (isTopLevelCall) {
            _initializing = false;
            emit Initialized(version);
        }
    }

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

    /**
     * @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
     * Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
     * to any version. It is recommended to use this to lock implementation contracts that are designed to be called
     * through proxies.
     */
    function _disableInitializers() internal virtual {
        _setInitializedVersion(type(uint8).max);
    }

    function _setInitializedVersion(uint8 version) private returns (bool) {
        // If the contract is initializing we ignore whether _initialized is set in order to support multiple
        // inheritance patterns, but we only do this in the context of a constructor, and for the lowest level
        // of initializers, because in other contexts the contract may have been reentered.
        if (_initializing) {
            require(
                version == 1 && !AddressUpgradeable.isContract(address(this)),
                "Initializable: contract is already initialized"
            );
            return false;
        } else {
            require(_initialized < version, "Initializable: contract is already initialized");
            _initialized = version;
            return true;
        }
    }
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

File 5 of 23 : IERC721Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

    /**
     * @dev Transfers `tokenId` token from `from` to `to`.
     *
     * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
     *
     * Requirements:
     *
     * - `from` cannot be the zero address.
     * - `to` cannot be the zero address.
     * - `tokenId` token must be owned by `from`.
     * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
     *
     * Emits a {Transfer} event.
     */
    function transferFrom(
        address from,
        address to,
        uint256 tokenId
    ) external;

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

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

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

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

File 6 of 23 : ECDSAUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/cryptography/ECDSA.sol)

pragma solidity ^0.8.0;

import "../StringsUpgradeable.sol";

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

    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 = vs & bytes32(0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff);
        uint8 v = uint8((uint256(vs) >> 255) + 27);
        return tryRecover(hash, v, r, s);
    }

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

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

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

File 7 of 23 : draft-EIP712Upgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/draft-EIP712.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

File 8 of 23 : ERC721HolderUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/utils/ERC721Holder.sol)

pragma solidity ^0.8.0;

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

/**
 * @dev Implementation of the {IERC721Receiver} interface.
 *
 * Accepts all token transfers.
 * Make sure the contract is able to use its token with {IERC721-safeTransferFrom}, {IERC721-approve} or {IERC721-setApprovalForAll}.
 */
contract ERC721HolderUpgradeable is Initializable, IERC721ReceiverUpgradeable {
    function __ERC721Holder_init() internal onlyInitializing {
    }

    function __ERC721Holder_init_unchained() internal onlyInitializing {
    }
    /**
     * @dev See {IERC721Receiver-onERC721Received}.
     *
     * Always returns `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address,
        address,
        uint256,
        bytes memory
    ) public virtual override returns (bytes4) {
        return this.onERC721Received.selector;
    }

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

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

pragma solidity ^0.8.0;

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

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

    /**
     * @dev Returns the average of two numbers. The result is rounded towards
     * zero.
     */
    function average(uint256 a, uint256 b) internal pure returns (uint256) {
        // (a + b) / 2 can overflow.
        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 10 of 23 : IGuildURIHandler.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

interface IGuildURIHandler {
    /**
     * @notice Branches represent various guild buffs
     * each of which are capped at level 5
     *
     * FRUGALITY: Rebate on CFTI sinks
     * 0.5% | 1% | 1.5% | 2% | 2.5%
     *
     * DISCIPLINE: Flat damage buff
     * 2 * heroBaseDmg * (heroLevel + 1) * perkLevel
     *
     * MORALE: Damage multiplier
     * 1.5% | 3% | 5% | 7% | 10%
     *
     * INDEMNITY: Second-wind chance on failure
     * 1% | 2% | 3% | 4% | 10%
     *
     * SUPERSTITION: Downgrade chance decrease
     * 1% | 2% | 3% | 4% | 5%
     *
     * FORTUNE: Enhancement success chance increase
     * 1% | 2% | 3% | 4% | 5%
     *
     */
    // NOTE: Keep in sync with `struct TechTree`
    enum Branch {
        FRUGALITY,
        DISCIPLINE,
        MORALE,
        INDEMNITY,
        SUPERSTITION,
        FORTUNE
    }

    /** STRUCTS */

    /**
     * @notice Below is documentation on Member struct elements.
     *
     * @param guildId       current active guild ID
     * @param vault         current vault balance
     * @param lastForage    last forage timestamp
     * @param hero          current staked hero
     * @param slot          current slot in guild membership array
     * @param permissions   permissions bitmap for current guild
     *
     */
    struct Member {
        uint256 guildId;
        uint64 vault;
        uint64 lastForage;
        uint32 hero;
        uint16 slot;
        uint8 permissions;
    }

    /**
     * @notice Below is documentation on Guild struct elements.
     *
     * @param balance  current guild GCFTI balance
     * @param vault    cumulative vault holdings of guild members
     * @param level    current guild level
     * @param techTree compact set of tech tree levels for each branch
     * @param members  array of guild members
     *
     */
    struct Guild {
        uint64 balance;
        uint64 vault;
        uint16 level;
        uint256 techTree;
        bytes32 name;
        address[] members;
    }

    struct Invite {
        address user;
        uint256 guildId;
        uint256 timeout;
    }

    // NOTE: Keep in sync with `enum Branch`
    struct TechTree {
        uint16 frugality;
        uint16 discipline;
        uint16 morale;
        uint16 indemnity;
        uint16 superstition;
        uint16 fortune;
        uint160 _scratch;
    }

    /** FUNCTIONS */

    function tokenURI(uint256 tokenId) external view returns (string memory);

    function getMembers(uint256 guildId)
        external
        view
        returns (address[] memory);

    function getGuildLevel(uint256 guildId) external view returns (uint16);

    function getGuildTechLevel(uint256 guildId, Branch branch)
        external
        view
        returns (uint16);

    function getGuildVault(uint256 guildId) external view returns (uint64);

    function getGuildBalance(uint256 guildId) external view returns (uint64);

    function getGuildData(uint256 guildId)
        external
        view
        returns (
            uint64 balance,
            uint16 level,
            uint64 vault,
            TechTree memory techTree,
            address[] memory members,
            string memory name
        );

    function getMember(address user) external view returns (Member memory);

    function getGuild(address user) external view returns (uint256);

    function calculateRewards(uint256 rewards, uint256 guildId)
        external
        view
        returns (uint64);

    function getGuildTechTree(uint256 guildId)
        external
        view
        returns (TechTree memory);

    function mint(address user, uint64 amount) external;
}

File 11 of 23 : IERC20Burnable.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/IERC20.sol";

interface IERC20Burnable is IERC20 {
    function mint(address to, uint256 amount) external;

    function burn(uint256 amount) external;

    function burnFrom(address account, uint256 amount) external;
}

File 12 of 23 : IParty.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "../lib/Stats.sol";

interface IParty {
    event Equipped(address indexed user, uint8 item, uint8 slot, uint256 id);

    event Unequipped(address indexed user, uint8 item, uint8 slot, uint256 id);

    event DamageUpdated(address indexed user, uint32 damageCurr);

    struct PartyData {
        uint256 hero;
        mapping(uint256 => uint256) fighters;
    }

    struct Action {
        ActionType action;
        uint256 id;
        uint8 slot;
    }

    enum Property {
        HERO,
        FIGHTER
    }

    enum ActionType {
        UNEQUIP,
        EQUIP
    }

    function act(
        Action[] calldata heroActions,
        Action[] calldata fighterActions
    ) external;

    function equip(
        Property item,
        uint256 id,
        uint8 slot
    ) external;

    function unequip(Property item, uint8 slot) external;

    function enhance(
        Property item,
        uint8 slot,
        uint256 burnTokenId
    ) external;

    function getUserHero(address user) external view returns (uint256);

    function getUserFighters(address user)
        external
        view
        returns (uint256[] memory);

    function getDamage(address user) external view returns (uint32);

    function updateDamage(address user) external;
}

File 13 of 23 : AddressUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)

pragma solidity ^0.8.1;

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

        return account.code.length > 0;
    }

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

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

    /**
     * @dev Performs a Solidity function call using a low level `call`. A
     * plain `call` is an unsafe replacement for a function call: use this
     * function instead.
     *
     * If `target` reverts with a revert reason, it is bubbled up by this
     * function (like regular Solidity function calls).
     *
     * Returns the raw returned data. To convert to the expected return value,
     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
     *
     * Requirements:
     *
     * - `target` must be a contract.
     * - calling `target` with `data` must not revert.
     *
     * _Available since v3.1._
     */
    function functionCall(address target, bytes memory data) internal returns (bytes memory) {
        return 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 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 14 of 23 : IAccessControlEnumerableUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControlEnumerable.sol)

pragma solidity ^0.8.0;

import "./IAccessControlUpgradeable.sol";

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

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

File 15 of 23 : AccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

    mapping(bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

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

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

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

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

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

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

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    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());
        }
    }

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

File 16 of 23 : EnumerableSetUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (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 EnumerableSetUpgradeable {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

File 18 of 23 : IERC721ReceiverUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC721/IERC721Receiver.sol)

pragma solidity ^0.8.0;

/**
 * @title ERC721 token receiver interface
 * @dev Interface for any contract that wants to support safeTransfers
 * from ERC721 asset contracts.
 */
interface IERC721ReceiverUpgradeable {
    /**
     * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
     * by `operator` from `from`, this function is called.
     *
     * It must return its Solidity selector to confirm the token transfer.
     * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
     *
     * The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
     */
    function onERC721Received(
        address operator,
        address from,
        uint256 tokenId,
        bytes calldata data
    ) external returns (bytes4);
}

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

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

File 20 of 23 : Stats.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

library Stats {
    struct HeroStats {
        uint8 dmgMultiplier;
        uint8 partySize;
        uint8 enhancement;
    }

    struct FighterStats {
        uint32 dmg;
        uint8 enhancement;
    }

    struct EquipmentStats {
        uint32 dmg;
        uint8 dmgMultiplier;
        uint8 slot;
    }
}

File 21 of 23 : IAccessControlUpgradeable.sol
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)

pragma solidity ^0.8.0;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

pragma solidity ^0.8.0;

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

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

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

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

Settings
{
  "remappings": [
    "@chainlink/=lib/chainlink/",
    "@openzeppelin/contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/contracts/",
    "@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/",
    "chainlink/=lib/chainlink/",
    "ds-test/=lib/ds-test/src/",
    "forge-std/=lib/forge-std/src/",
    "openzeppelin-contracts-upgradeable/=lib/openzeppelin-contracts-upgradeable/",
    "openzeppelin-contracts/=lib/openzeppelin-contracts/",
    "script/=script/",
    "src/=src/",
    "test/=test/",
    "src/=src/",
    "test/=test/",
    "script/=script/"
  ],
  "optimizer": {
    "enabled": true,
    "runs": 200
  },
  "metadata": {
    "bytecodeHash": "ipfs"
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "evmVersion": "london",
  "libraries": {
    "src/lib/Damage.sol": {
      "Damage": "0x1aa1bc989105048951a95baf1f5195af9b19bddb"
    }
  }
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"delay","type":"uint256"}],"name":"ForageDelay","type":"error"},{"inputs":[],"name":"GuildAtCapacity","type":"error"},{"inputs":[],"name":"GuildAtMaxLevel","type":"error"},{"inputs":[],"name":"GuildNotOwned","type":"error"},{"inputs":[],"name":"GuildNotPresent","type":"error"},{"inputs":[],"name":"GuildPresent","type":"error"},{"inputs":[],"name":"HeroNotPresent","type":"error"},{"inputs":[],"name":"HeroPresent","type":"error"},{"inputs":[{"internalType":"uint256","name":"missingAmount","type":"uint256"}],"name":"InsufficientFunds","type":"error"},{"inputs":[],"name":"InsufficientPermissions","type":"error"},{"inputs":[{"internalType":"enum IGuildURIHandler.Branch","name":"branch","type":"uint8"}],"name":"LevelRequirementNotMet","type":"error"},{"inputs":[],"name":"NameUnavailable","type":"error"},{"inputs":[],"name":"NotGuildMember","type":"error"},{"inputs":[],"name":"NotRecipient","type":"error"},{"inputs":[],"name":"OutOfBounds","type":"error"},{"inputs":[],"name":"Paused","type":"error"},{"inputs":[],"name":"TimeoutExceeded","type":"error"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"guildId","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Deposit","type":"event"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"uint8","name":"version","type":"uint8"}],"name":"Initialized","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"Join","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":true,"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"Leave","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"Mint","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":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"hero","type":"uint256"}],"name":"Stake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"hero","type":"uint256"}],"name":"Unstake","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"guildId","type":"uint256"},{"indexed":false,"internalType":"uint16","name":"level","type":"uint16"}],"name":"Upgrade","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"guildId","type":"uint256"},{"indexed":false,"internalType":"enum IGuildURIHandler.Branch","name":"branch","type":"uint8"},{"indexed":false,"internalType":"uint16","name":"level","type":"uint16"}],"name":"UpgradeTechTree","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"user","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"VaultDeposit","type":"event"},{"inputs":[],"name":"DECIMALS","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DECIMAL_DELTA","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FORAGE_DELAY","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"FORAGE_REWARD","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"GCFTI_MINTER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INVITE_NAME","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INVITE_TYPEHASH","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"INVITE_VERSION","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"rewards","type":"uint256"},{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"calculateRewards","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"deposit","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"forage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getGuild","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getGuildBalance","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getGuildData","outputs":[{"internalType":"uint64","name":"balance","type":"uint64"},{"internalType":"uint16","name":"level","type":"uint16"},{"internalType":"uint64","name":"vault","type":"uint64"},{"components":[{"internalType":"uint16","name":"frugality","type":"uint16"},{"internalType":"uint16","name":"discipline","type":"uint16"},{"internalType":"uint16","name":"morale","type":"uint16"},{"internalType":"uint16","name":"indemnity","type":"uint16"},{"internalType":"uint16","name":"superstition","type":"uint16"},{"internalType":"uint16","name":"fortune","type":"uint16"},{"internalType":"uint160","name":"_scratch","type":"uint160"}],"internalType":"struct IGuildURIHandler.TechTree","name":"techTree","type":"tuple"},{"internalType":"address[]","name":"members","type":"address[]"},{"internalType":"string","name":"name","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getGuildLevel","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"},{"internalType":"enum IGuildURIHandler.Branch","name":"branch","type":"uint8"}],"name":"getGuildTechLevel","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getGuildTechTree","outputs":[{"components":[{"internalType":"uint16","name":"frugality","type":"uint16"},{"internalType":"uint16","name":"discipline","type":"uint16"},{"internalType":"uint16","name":"morale","type":"uint16"},{"internalType":"uint16","name":"indemnity","type":"uint16"},{"internalType":"uint16","name":"superstition","type":"uint16"},{"internalType":"uint16","name":"fortune","type":"uint16"},{"internalType":"uint160","name":"_scratch","type":"uint160"}],"internalType":"struct IGuildURIHandler.TechTree","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getGuildVault","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"level","type":"uint16"}],"name":"getLevelCost","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getMaxMembers","outputs":[{"internalType":"uint16","name":"","type":"uint16"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"getMember","outputs":[{"components":[{"internalType":"uint256","name":"guildId","type":"uint256"},{"internalType":"uint64","name":"vault","type":"uint64"},{"internalType":"uint64","name":"lastForage","type":"uint64"},{"internalType":"uint32","name":"hero","type":"uint32"},{"internalType":"uint16","name":"slot","type":"uint16"},{"internalType":"uint8","name":"permissions","type":"uint8"}],"internalType":"struct IGuildURIHandler.Member","name":"","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getMembers","outputs":[{"internalType":"address[]","name":"","type":"address[]"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"getName","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint16","name":"level","type":"uint16"},{"internalType":"enum IGuildURIHandler.Branch","name":"branch","type":"uint8"}],"name":"getTreeCost","outputs":[{"internalType":"uint64","name":"","type":"uint64"}],"stateMutability":"pure","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":"admin","type":"address"},{"internalType":"contract IERC721Upgradeable","name":"guild","type":"address"},{"internalType":"contract IERC721Upgradeable","name":"hero","type":"address"},{"internalType":"contract IERC20Burnable","name":"confetti","type":"address"},{"internalType":"contract IParty","name":"party","type":"address"}],"name":"initialize","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"guildId","type":"uint256"},{"internalType":"uint256","name":"timeout","type":"uint256"}],"internalType":"struct IGuildURIHandler.Invite","name":"invite","type":"tuple"}],"name":"inviteHash","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"isAuthorized","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint256","name":"guildId","type":"uint256"},{"internalType":"uint256","name":"timeout","type":"uint256"}],"internalType":"struct IGuildURIHandler.Invite","name":"invite","type":"tuple"},{"internalType":"bytes","name":"signature","type":"bytes"}],"name":"join","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"}],"name":"kick","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"leave","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"user","type":"address"},{"internalType":"uint64","name":"amount","type":"uint64"}],"name":"mint","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"},{"internalType":"address","name":"","type":"address"},{"internalType":"uint256","name":"","type":"uint256"},{"internalType":"bytes","name":"","type":"bytes"}],"name":"onERC721Received","outputs":[{"internalType":"bytes4","name":"","type":"bytes4"}],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"pause","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":"uint256","name":"guildId","type":"uint256"},{"internalType":"address","name":"user","type":"address"},{"internalType":"bool","name":"authorized","type":"bool"}],"name":"setAuthorization","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"},{"internalType":"string","name":"name","type":"string"}],"name":"setName","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint32","name":"id","type":"uint32"}],"name":"stake","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":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"pure","type":"function"},{"inputs":[],"name":"unpause","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"unstake","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"}],"name":"upgrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"guildId","type":"uint256"},{"internalType":"enum IGuildURIHandler.Branch","name":"branch","type":"uint8"}],"name":"upgradeTechTree","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"vaultDeposit","outputs":[],"stateMutability":"nonpayable","type":"function"}]

608060405234801561001057600080fd5b506142fd806100206000396000f3fe608060405234801561001057600080fd5b50600436106102f15760003560e01c80635a3638641161019d578063b9a54f6d116100e9578063d4d10cd2116100a2578063df1dd9761161007c578063df1dd97614610884578063f4ec87d3146108a9578063fe55932a146108d0578063fe9fbb80146108e357600080fd5b8063d4d10cd214610856578063d547741f14610869578063d66d9e191461087c57600080fd5b8063b9a54f6d146107ac578063c477ecab146107dd578063c741e13c146107fd578063c87b56dd1461081d578063c92d2b7814610830578063ca15c8731461084357600080fd5b80639010d07c1161015657806396c551751161013057806396c551751461076b578063a217fddf1461077e578063a5ef8aa614610786578063b6b55f251461079957600080fd5b80639010d07c1461071a57806391d148541461074557806392fea19a1461075857600080fd5b80635a363864146106c35780636b8ff574146106d15780637fcfb7c2146106e4578063838b836b146106f75780638456cb591461070a5780638d8a34261461071257600080fd5b806336568abe1161025c57806347444bc111610215578063502e9e9a116101ef578063502e9e9a146106505780635729b3941461067a57806357dd13111461068d578063580a14461461069757600080fd5b806347444bc11461060e578063479e9ded1461061657806348a887061461063d57600080fd5b806336568abe1461059057806337b9b2d0146105a35780633db68934146105cd5780633f4ba83a146105e05780633fe41235146105e857806345977d03146105fb57600080fd5b8063248a9ca3116102ae578063248a9ca3146103e25780632893c5b0146104135780632ada2596146104265780632def6620146105545780632e0f26251461055c5780632f2ff15d1461057d57600080fd5b806301ffc9a7146102f6578063022b1a861461031e5780631459457a14610350578063150b7a0214610365578063164491ae1461039c5780631c68c4b1146103c2575b600080fd5b6103096103043660046138cf565b61091d565b60405190151581526020015b60405180910390f35b61034360405180604001604052806006815260200165496e7669746560d01b81525081565b6040516103159190613951565b61036361035e366004613979565b61092e565b005b610383610373366004613a8c565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610315565b6103af6103aa366004613af7565b610a8b565b60405161ffff9091168152602001610315565b6103d56103d0366004613af7565b610ab6565b6040516103159190613b6c565b6104056103f0366004613af7565b60009081526065602052604090206001015490565b604051908152602001610315565b610363610421366004613b7a565b610ada565b6104ec610434366004613bbf565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152506001600160a01b031660009081526101356020908152604091829020825160c081018452815481526001909101546001600160401b0380821693830193909352600160401b810490921692810192909252600160801b810463ffffffff166060830152600160a01b810461ffff166080830152600160b01b900460ff1660a082015290565b6040516103159190600060c0820190508251825260208301516001600160401b038082166020850152806040860151166040850152505063ffffffff606084015116606083015261ffff608084015116608083015260ff60a08401511660a083015292915050565b610363610b3f565b6105656103e881565b6040516001600160401b039091168152602001610315565b61036361058b366004613bdc565b610c73565b61036361059e366004613bdc565b610c98565b6104056105b1366004613bbf565b6001600160a01b03166000908152610135602052604090205490565b6103636105db366004613c19565b610d1b565b610363610f0a565b6104056105f6366004613c67565b610f26565b610363610609366004613af7565b610fa5565b610565611201565b6104057f62943daa8ff92d447f5dbd09be1204cdbd3c24313c218af83aece06ede8fe02781565b61056561064b366004613c83565b611211565b61056561065e366004613af7565b600090815261013460205260409020546001600160401b031690565b610363610688366004613af7565b6112ed565b61056562093a8081565b6103af6106a5366004613af7565b60009081526101346020526040902054600160801b900461ffff1690565b61056566038d7ea4c6800081565b6103436106df366004613af7565b611493565b6103636106f2366004613ca5565b611501565b610363610705366004613cda565b611661565b610363611889565b6103636118ab565b61072d610728366004613c83565b611a19565b6040516001600160a01b039091168152602001610315565b610309610753366004613bdc565b611a31565b610363610766366004613d06565b611a5c565b610363610779366004613bbf565b611ba4565b610405600081565b6103af610794366004613cda565b611c8d565b6103636107a7366004613af7565b611caa565b6105656107ba366004613af7565b60009081526101346020526040902054600160401b90046001600160401b031690565b6107f06107eb366004613af7565b611f89565b6040516103159190613d91565b610343604051806040016040528060018152602001603160f81b81525081565b61034361082b366004613af7565b611ff9565b61056561083e366004613db6565b612033565b610405610851366004613af7565b612304565b610565610864366004613de0565b61231b565b610363610877366004613bdc565b612385565b6103636123aa565b610897610892366004613af7565b612415565b60405161031596959493929190613dfb565b6104057f4869181a7e5731ab23dde0d3dc3b910af0cdaafa9758229938033fda786278f881565b6103636108de366004613e60565b6124db565b6103096108f1366004613bbf565b6001600160a01b0316600090815261013560205260409020600190810154600160b01b900460ff161490565b60006109288261267a565b92915050565b600061093a600161269f565b90508015610952576000805461ff0019166101001790555b61095a61272c565b61099b60405180604001604052806006815260200165496e7669746560d01b815250604051806040016040528060018152602001603160f81b815250612755565b6109a6600087612786565b6109d07f62943daa8ff92d447f5dbd09be1204cdbd3c24313c218af83aece06ede8fe02787612786565b61013180546001600160a01b038086166001600160a01b031992831617909255610133805461012f80548a8616908516179055610130805489861690851617905561013280548786169416939093179092556001600160a81b031990911691881691909117600160a01b1790558015610a83576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b60008181526101346020526040812054600160801b900461ffff16610aaf81612790565b9392505050565b610abe613893565b60008281526101346020526040902060010154610928906127fe565b7f62943daa8ff92d447f5dbd09be1204cdbd3c24313c218af83aece06ede8fe027610b0481612847565b61013354600160a01b900460ff1615610b30576040516313d0ff5960e31b815260040160405180910390fd5b610b3a8383612851565b505050565b61013354600160a01b900460ff1615610b6b576040516313d0ff5960e31b815260040160405180910390fd5b3360009081526101356020526040812060018101549091600160801b90910463ffffffff1690819003610bb15760405163ef6e66dd60e01b815260040160405180910390fd5b60018201805463ffffffff60801b1916905561013054604051632142170760e11b815230600482015233602482015263ffffffff831660448201526001600160a01b03909116906342842e0e90606401600060405180830381600087803b158015610c1b57600080fd5b505af1158015610c2f573d6000803e3d6000fd5b505060405163ffffffff841681523392507f85082129d87b2fe11527cb1b3b7a520aeb5aa6913f88a3d8757fe40d1db02fdd91506020015b60405180910390a25050565b600082815260656020526040902060010154610c8e81612847565b610b3a8383612922565b6001600160a01b0381163314610d0d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610d178282612944565b5050565b61013354600160a01b900460ff1615610d47576040516313d0ff5960e31b815260040160405180910390fd5b4282604001351015610d6c5760405163a09a5b5f60e01b815260040160405180910390fd5b33600090815261013560205260409020805415610d9c576040516376ad0b6960e11b815260040160405180910390fd5b610da68383612966565b6020838101356000908152610134909152604090208054610dd190600160801b900461ffff16612790565b61ffff16816003018054905010610dfb57604051630a44ab9d60e21b815260040160405180910390fd5b602084013582556001820180546001600160401b03428116600160401b90810267ffffffffffffffff60401b19841681178555600386015461ffff16600160a01b0261ffff60a01b1990911675ffff00000000ffffffffffffffff0000000000000000199094169390931792909217928390558354928116928492600892610e87928692900416613ef1565b82546001600160401b039182166101009390930a9283029190920219909116179055506003810180546001810182556000918252602080832090910180546001600160a01b03191633908117909155604051918701359290917fb4e09949657f21548b58afe74e7b86cd2295da5ff1598ae1e5faecb1cf19ca959190a350505050565b6000610f1581612847565b50610133805460ff60a01b19169055565b60006109287f4869181a7e5731ab23dde0d3dc3b910af0cdaafa9758229938033fda786278f8610f596020850185613bbf565b604080516020818101949094526001600160a01b039092168282015291850135606082015290840135608082015260a00160405160208183030381529060405280519060200120612a5d565b61013354600160a01b900460ff1615610fd1576040516313d0ff5960e31b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e90602401602060405180830381865afa15801561101b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103f9190613f1c565b6001600160a01b031614158015611074575033600090815261013560205260409020600190810154600160b01b900460ff1614155b156110925760405163061cbdd360e51b815260040160405180910390fd5b60008181526101346020526040902080546005600160801b90910461ffff16106110cf57604051637177a3a360e11b815260040160405180910390fd5b80546000906110e890600160801b900461ffff1661231b565b82549091506001600160401b03908116908216111561113b578154611116906001600160401b031682613f39565b6040516365bc667160e11b81526001600160401b039091166004820152602401610d04565b8154819083906000906111589084906001600160401b0316613f39565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060018260000160108282829054906101000a900461ffff1661119e9190613f61565b82546101009290920a61ffff8181021990931691831602179091558354604051600160801b90910490911681528491507f964674a14f5875e45d79829f44fec1a2810393fbfcbb7372882936f6d4cecbe0906020015b60405180910390a2505050565b61120e6103e86032613f7e565b81565b600081156112e45760008281526101346020908152604091829020825160c08101845281546001600160401b038082168352600160401b82041682850152600160801b900461ffff168185015260018201546060820152600282015460808201526003820180548551818602810186019096528086526112df95899593949360a08601939192908301828280156112d157602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116112b3575b505050505081525050612aab565b610aaf565b60009392505050565b61013354600160a01b900460ff1615611319576040516313d0ff5960e31b815260040160405180910390fd5b6101315460405163079cc67960e41b8152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561136657600080fd5b505af115801561137a573d6000803e3d6000fd5b5050505060006113918266038d7ea4c68000900490565b33600090815261013560205260408120600101805492935083929091906113c29084906001600160401b0316613ef1565b82546001600160401b039182166101009390930a92830291909202199091161790555033600090815261013560205260409020541561146157336000908152610135602090815260408083205483526101349091529020805482919060089061143c908490600160401b90046001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b031602179055505b60405182815233907f89d28cf06bdb2ee1b92cd046d58450042ad113e9f4cdabfc4d43e7c5557758d790602001610c67565b60008181526101346020526040902060020154606090806114de576114b783612aef565b6040516020016114c79190613fad565b604051602081830303815290604052915050919050565b6000838152610134602090815260409182902060020154825191820152016114c7565b61013354600160a01b900460ff161561152d576040516313d0ff5960e31b815260040160405180910390fd5b336000908152610135602052604090206001810154600160801b900463ffffffff161561156d576040516338ef830960e11b815260040160405180910390fd5b60018101805473ffffffffffffffffffffffff00000000000000001916600160801b63ffffffff851690810267ffffffffffffffff60401b191691909117600160401b426001600160401b0316021790915561013054604051632142170760e11b815233600482015230602482015260448101929092526001600160a01b0316906342842e0e90606401600060405180830381600087803b15801561161157600080fd5b505af1158015611625573d6000803e3d6000fd5b505060405163ffffffff851681523392507febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a9150602001610c67565b61013354600160a01b900460ff161561168d576040516313d0ff5960e31b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810184905233916001600160a01b031690636352211e90602401602060405180830381865afa1580156116d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116fb9190613f1c565b6001600160a01b031614158015611730575033600090815261013560205260409020600190810154600160b01b900460ff1614155b1561174e5760405163061cbdd360e51b815260040160405180910390fd5b600082815261013460205260409020600181015482600581111561177457611774613fdc565b825461ffff918216600160801b90910490911610156117a8578260405163787b1aa360e11b8152600401610d049190614014565b60006117bd6117b78386612bef565b85612033565b83549091506001600160401b0390811690821611156117eb578254611116906001600160401b031682613f39565b8254819084906000906118089084906001600160401b0316613f39565b92506101000a8154816001600160401b0302191690836001600160401b031602179055506118368285612c10565b600184018190559150847f9814ff6c1019cc523465f0da9ec95d19d61fab8d6bae3f3d0043487788152ea88561186c8582612bef565b60405161187a929190614022565b60405180910390a25050505050565b600061189481612847565b50610133805460ff60a01b1916600160a01b179055565b61013354600160a01b900460ff16156118d7576040516313d0ff5960e31b815260040160405180910390fd5b3360009081526101356020526040812060018101549091600160801b90910463ffffffff16900361191b5760405163ef6e66dd60e01b815260040160405180910390fd5b600181015462093a809061193f90600160401b90046001600160401b031642614041565b101561198057600181015461196490600160401b90046001600160401b031642614041565b6040516305d7bfbd60e41b8152600401610d0491815260200190565b600181015460009062093a80906119a790600160401b90046001600160401b031642613f39565b6119b1919061406e565b905062093a806119c18142614094565b6119cb91906140a8565b6001830180546001600160401b0392909216600160401b0267ffffffffffffffff60401b19909216919091179055610d1733611a0a6103e86032613f7e565b611a149084613f7e565b612851565b6000828152609760205260408120610aaf9083612c63565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61013354600160a01b900460ff1615611a88576040516313d0ff5960e31b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810185905233916001600160a01b031690636352211e90602401602060405180830381865afa158015611ad2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af69190613f1c565b6001600160a01b031614611b1d57604051631648b6a960e11b815260040160405180910390fd5b6001600160a01b038216600090815261013560205260409020548314611b565760405163bf27d90360e01b815260040160405180910390fd5b80611b62576000611b65565b60015b6001600160a01b03909216600090815261013560205260409020600101805460ff93909316600160b01b0260ff60b01b19909316929092179091555050565b61013354600160a01b900460ff1615611bd0576040516313d0ff5960e31b815260040160405180910390fd5b6001600160a01b03808216600090815261013560205260409081902061012f54815492516331a9108f60e11b815291933393911691636352211e91611c1b9160040190815260200190565b602060405180830381865afa158015611c38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5c9190613f1c565b6001600160a01b031614611c8357604051631648b6a960e11b815260040160405180910390fd5b610d178282612c6f565b60008281526101346020526040812060010154610aaf9083612bef565b61013354600160a01b900460ff1615611cd6576040516313d0ff5960e31b815260040160405180910390fd5b336000908152610135602052604081208054909103611d085760405163bf27d90360e01b815260040160405180910390fd5b8054600090815261013460205260409081902061013154915163079cc67960e41b81523360048201526024810185905290916001600160a01b0316906379cc679090604401600060405180830381600087803b158015611d6757600080fd5b505af1158015611d7b573d6000803e3d6000fd5b50506040805160c08101825284546001600160401b038082168352600160401b820416602080840191909152600160801b90910461ffff1682840152600186015460608301526002860154608083015260038601805484518184028101840190955280855260009650611e3a95508994889360a08601939192908301828280156112d1576020028201919060005260206000209081546001600160a01b031681526001909101906020018083116112b357505050505081525050612aab565b825490915081908390600090611e5a9084906001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060006002611e938666038d7ea4c68000900490565b611e9d919061406e565b6001850180549192508291600090611ebf9084906001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b03160217905550808360000160088282829054906101000a90046001600160401b0316611f099190613ef1565b92506101000a8154816001600160401b0302191690836001600160401b031602179055508360000154336001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1584604051611f7a91906001600160401b0391909116815260200190565b60405180910390a35050505050565b60008181526101346020908152604091829020600301805483518184028101840190945280845260609392830182828015611fed57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611fcf575b50505050509050919050565b6060612003612f6d565b61200c83612aef565b60405160200161201d9291906140c7565b6040516020818303038152906040529050919050565b6000808083600581111561204957612049613fdc565b036120ac578361ffff1660000361206357506113886122f0565b8361ffff1660010361207857506127106122f0565b8361ffff1660020361208d5750614e206122f0565b8361ffff166003036120a2575061c3506122f0565b50620186a06122f0565b60018360058111156120c0576120c0613fdc565b03612124578361ffff166000036120da57506127106122f0565b8361ffff166001036120ef5750614e206122f0565b8361ffff16600203612104575061c3506122f0565b8361ffff1660030361211a5750620186a06122f0565b506203d0906122f0565b600283600581111561213857612138613fdc565b0361219d578361ffff166000036121525750614e206122f0565b8361ffff16600103612167575061c3506122f0565b8361ffff1660020361217d5750620186a06122f0565b8361ffff1660030361219357506203d0906122f0565b506207a1206122f0565b60038360058111156121b1576121b1613fdc565b03612217578361ffff166000036121cb575061c3506122f0565b8361ffff166001036121e15750620186a06122f0565b8361ffff166002036121f757506203d0906122f0565b8361ffff1660030361220d57506207a1206122f0565b50620f42406122f0565b600483600581111561222b5761222b613fdc565b03612292578361ffff166000036122465750620186a06122f0565b8361ffff1660010361225c57506203d0906122f0565b8361ffff1660020361227257506207a1206122f0565b8361ffff166003036122885750620f42406122f0565b50621e84806122f0565b8361ffff166000036122a857506203d0906122f0565b8361ffff166001036122be57506207a1206122f0565b8361ffff166002036122d45750620f42406122f0565b8361ffff166003036122ea5750621e84806122f0565b50623d09005b6122fc6103e882613f7e565b949350505050565b600081815260976020526040812061092890612f8d565b6000808261ffff166000036123335750612710612379565b8261ffff166001036123485750614e20612379565b8261ffff1660020361235d5750619c40612379565b8261ffff16600303612373575062027100612379565b50622710005b610aaf6103e882613f7e565b6000828152606560205260409020600101546123a081612847565b610b3a8383612944565b61013354600160a01b900460ff16156123d6576040516313d0ff5960e31b815260040160405180910390fd5b3360009081526101356020526040812080549091036124085760405163bf27d90360e01b815260040160405180910390fd5b6124123382612c6f565b50565b6000806000612422613893565b6000858152610134602090815260409182902080546003820180548551818602810186019096528086526001600160401b038084169a5061ffff600160801b8504169950600160401b909304909216965060609485949092908301828280156124b457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612496575b505050505092506124c488610ab6565b93506124cf88611493565b91505091939550919395565b61013354600160a01b900460ff1615612507576040516313d0ff5960e31b815260040160405180910390fd5b602081111561252957604051632d0483c560e21b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810185905233916001600160a01b031690636352211e90602401602060405180830381865afa158015612573573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125979190613f1c565b6001600160a01b0316146125be57604051631648b6a960e11b815260040160405180910390fd5b60008381526101346020526040902060020154156125ff576000838152610134602090815260408083206002015483526101369091529020805460ff191690555b600061260b82846140ed565b9050801561265f576000818152610136602052604090205460ff1615612644576040516302d154b760e11b815260040160405180910390fd5b600081815261013660205260409020805460ff191660011790555b60009384526101346020526040909320600201929092555050565b60006001600160e01b03198216635a05180f60e01b1480610928575061092882612f97565b60008054610100900460ff16156126e6578160ff1660011480156126c25750303b155b6126de5760405162461bcd60e51b8152600401610d049061410b565b506000919050565b60005460ff80841691161061270d5760405162461bcd60e51b8152600401610d049061410b565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff166127535760405162461bcd60e51b8152600401610d0490614159565b565b600054610100900460ff1661277c5760405162461bcd60e51b8152600401610d0490614159565b610d178282612fcc565b610d178282612922565b60008161ffff166000036127a65750600a919050565b8161ffff166001036127ba5750600f919050565b8161ffff166002036127ce57506019919050565b8161ffff166003036127e257506023919050565b8161ffff166004036127f657506032919050565b506064919050565b612806613893565b61280e613893565b8281528260101c60208201528260201c60408201528260301c60608201528260401c60808201528260501c60a082015280915050919050565b612412813361300d565b6001600160a01b038216600090815261013560205260408120805490910361288c5760405163bf27d90360e01b815260040160405180910390fd5b805460009081526101346020526040812080548492906128b69084906001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b03160217905550826001600160a01b03167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040516111f491906001600160401b0391909116815260200190565b61292c8282613071565b6000828152609760205260409020610b3a90826130f7565b61294e828261310c565b6000828152609760205260409020610b3a9082613173565b336129746020840184613bbf565b6001600160a01b03161461299b5760405163586d335760e01b815260040160405180910390fd5b60006129a683610f26565b905060006129b48284613188565b61012f546040516331a9108f60e11b8152602087013560048201529192506001600160a01b031690636352211e90602401602060405180830381865afa158015612a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a269190613f1c565b6001600160a01b0316816001600160a01b031614612a5757604051631648b6a960e11b815260040160405180910390fd5b50505050565b6000610928612a6a6131ac565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000610aaf63b2d05e00612ad084602001516001600160401b031663b2d05e0061322c565b850281612adf57612adf614058565b04840166038d7ea4c68000900490565b606081600003612b165750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612b405780612b2a816141a4565b9150612b399050600a83614094565b9150612b1a565b6000816001600160401b03811115612b5a57612b5a6139ea565b6040519080825280601f01601f191660200182016040528015612b84576020820181803683370190505b5090505b84156122fc57612b99600183614041565b9150612ba6600a866141bd565b612bb19060306141d1565b60f81b818381518110612bc657612bc66141e9565b60200101906001600160f81b031916908160001a905350612be8600a86614094565b9450612b88565b6000816005811115612c0357612c03613fdc565b6010029290921c92915050565b60006005612c1e8484612bef565b61ffff1610612c4057604051637177a3a360e11b815260040160405180910390fd5b816005811115612c5257612c52613fdc565b6010026001901b8301905092915050565b6000610aaf8383613242565b8054600081815261013460205260409020600183015481546001600160401b03918216918391600891612cac918591600160401b90910416613f39565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060018160030180549050612ce49190614041565b6001840154600160a01b900461ffff1614612e8357600381018054612d0b90600190614041565b81548110612d1b57612d1b6141e9565b60009182526020909120015460018401546003830180546001600160a01b03909316929091600160a01b900461ffff16908110612d5a57612d5a6141e9565b60009182526020909120015460018501546003840180546001600160a01b03909316929091600160a01b900461ffff16908110612d9957612d996141e9565b9060005260206000200160008460030160018660030180549050612dbd9190614041565b81548110612dcd57612dcd6141e9565b6000918252602082200180546001600160a01b0319166001600160a01b0395861617905582546101009290920a808502199092169490931602929092179091556001840154600383018054600160a01b90920461ffff16926101359290919084908110612e3c57612e3c6141e9565b60009182526020808320909101546001600160a01b031683528201929092526040019020600101805461ffff92909216600160a01b0261ffff60a01b199092169190911790555b80600301805480612e9657612e966141ff565b600082815260208120600019908301810180546001600160a01b031916905590910190915560018401805491855562ffffff60a01b1990911690556101325460405163bbead49d60e01b81526001600160a01b0386811660048301529091169063bbead49d90602401600060405180830381600087803b158015612f1957600080fd5b505af1158015612f2d573d6000803e3d6000fd5b50506040518492506001600160a01b03871691507f61a26f7c17d8780c095ccfa67e689a13ee4e06ddce3da18956369f4a396100e890600090a350505050565b60606040518060600160405280602681526020016142a260269139905090565b6000610928825490565b60006001600160e01b03198216637965db0b60e01b148061092857506301ffc9a760e01b6001600160e01b0319831614610928565b600054610100900460ff16612ff35760405162461bcd60e51b8152600401610d0490614159565b81516020928301208151919092012060c99190915560ca55565b6130178282611a31565b610d175761302f816001600160a01b0316601461326c565b61303a83602061326c565b60405160200161304b929190614215565b60408051601f198184030181529082905262461bcd60e51b8252610d0491600401613951565b61307b8282611a31565b610d175760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556130b33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610aaf836001600160a01b038416613407565b6131168282611a31565b15610d175760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610aaf836001600160a01b038416613456565b60008060006131978585613549565b915091506131a4816135b7565b509392505050565b60006132277f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6131db60c95490565b60ca546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b600081831061323b5781610aaf565b5090919050565b6000826000018281548110613259576132596141e9565b9060005260206000200154905092915050565b6060600061327b8360026140a8565b6132869060026141d1565b6001600160401b0381111561329d5761329d6139ea565b6040519080825280601f01601f1916602001820160405280156132c7576020820181803683370190505b509050600360fc1b816000815181106132e2576132e26141e9565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613311576133116141e9565b60200101906001600160f81b031916908160001a90535060006133358460026140a8565b6133409060016141d1565b90505b60018111156133b8576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613374576133746141e9565b1a60f81b82828151811061338a5761338a6141e9565b60200101906001600160f81b031916908160001a90535060049490941c936133b18161428a565b9050613343565b508315610aaf5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610d04565b600081815260018301602052604081205461344e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610928565b506000610928565b6000818152600183016020526040812054801561353f57600061347a600183614041565b855490915060009061348e90600190614041565b90508181146134f35760008660000182815481106134ae576134ae6141e9565b90600052602060002001549050808760000184815481106134d1576134d16141e9565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613504576135046141ff565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610928565b6000915050610928565b600080825160410361357f5760208301516040840151606085015160001a6135738782858561376d565b945094505050506135b0565b82516040036135a8576020830151604084015161359d86838361385a565b9350935050506135b0565b506000905060025b9250929050565b60008160048111156135cb576135cb613fdc565b036135d35750565b60018160048111156135e7576135e7613fdc565b036136345760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610d04565b600281600481111561364857613648613fdc565b036136955760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610d04565b60038160048111156136a9576136a9613fdc565b036137015760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610d04565b600481600481111561371557613715613fdc565b036124125760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610d04565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156137a45750600090506003613851565b8460ff16601b141580156137bc57508460ff16601c14155b156137cd5750600090506004613851565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613821573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661384a57600060019250925050613851565b9150600090505b94509492505050565b6000806001600160ff1b0383168161387760ff86901c601b6141d1565b90506138858782888561376d565b935093505050935093915050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6000602082840312156138e157600080fd5b81356001600160e01b031981168114610aaf57600080fd5b60005b838110156139145781810151838201526020016138fc565b83811115612a575750506000910152565b6000815180845261393d8160208601602086016138f9565b601f01601f19169290920160200192915050565b602081526000610aaf6020830184613925565b6001600160a01b038116811461241257600080fd5b600080600080600060a0868803121561399157600080fd5b853561399c81613964565b945060208601356139ac81613964565b935060408601356139bc81613964565b925060608601356139cc81613964565b915060808601356139dc81613964565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b600082601f830112613a1157600080fd5b81356001600160401b0380821115613a2b57613a2b6139ea565b604051601f8301601f19908116603f01168101908282118183101715613a5357613a536139ea565b81604052838152866020858801011115613a6c57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215613aa257600080fd5b8435613aad81613964565b93506020850135613abd81613964565b92506040850135915060608501356001600160401b03811115613adf57600080fd5b613aeb87828801613a00565b91505092959194509250565b600060208284031215613b0957600080fd5b5035919050565b61ffff8082511683528060208301511660208401528060408301511660408401528060608301511660608401528060808301511660808401528060a08301511660a08401525060018060a01b0360c08201511660c08301525050565b60e081016109288284613b10565b60008060408385031215613b8d57600080fd5b8235613b9881613964565b915060208301356001600160401b0381168114613bb457600080fd5b809150509250929050565b600060208284031215613bd157600080fd5b8135610aaf81613964565b60008060408385031215613bef57600080fd5b823591506020830135613bb481613964565b600060608284031215613c1357600080fd5b50919050565b60008060808385031215613c2c57600080fd5b613c368484613c01565b915060608301356001600160401b03811115613c5157600080fd5b613c5d85828601613a00565b9150509250929050565b600060608284031215613c7957600080fd5b610aaf8383613c01565b60008060408385031215613c9657600080fd5b50508035926020909101359150565b600060208284031215613cb757600080fd5b813563ffffffff81168114610aaf57600080fd5b80356006811061272757600080fd5b60008060408385031215613ced57600080fd5b82359150613cfd60208401613ccb565b90509250929050565b600080600060608486031215613d1b57600080fd5b833592506020840135613d2d81613964565b915060408401358015158114613d4257600080fd5b809150509250925092565b600081518084526020808501945080840160005b83811015613d865781516001600160a01b031687529582019590820190600101613d61565b509495945050505050565b602081526000610aaf6020830184613d4d565b803561ffff8116811461272757600080fd5b60008060408385031215613dc957600080fd5b613dd283613da4565b9150613cfd60208401613ccb565b600060208284031215613df257600080fd5b610aaf82613da4565b6001600160401b03878116825261ffff87166020830152851660408201526000610180613e2b6060840187613b10565b80610140840152613e3e81840186613d4d565b9050828103610160840152613e538185613925565b9998505050505050505050565b600080600060408486031215613e7557600080fd5b8335925060208401356001600160401b0380821115613e9357600080fd5b818601915086601f830112613ea757600080fd5b813581811115613eb657600080fd5b876020828501011115613ec857600080fd5b6020830194508093505050509250925092565b634e487b7160e01b600052601160045260246000fd5b60006001600160401b03808316818516808303821115613f1357613f13613edb565b01949350505050565b600060208284031215613f2e57600080fd5b8151610aaf81613964565b60006001600160401b0383811690831681811015613f5957613f59613edb565b039392505050565b600061ffff808316818516808303821115613f1357613f13613edb565b60006001600160401b0380831681851681830481118215151615613fa457613fa4613edb565b02949350505050565b664775696c64202360c81b815260008251613fcf8160078501602087016138f9565b9190910160070192915050565b634e487b7160e01b600052602160045260246000fd5b6006811061401057634e487b7160e01b600052602160045260246000fd5b9052565b602081016109288284613ff2565b604081016140308285613ff2565b61ffff831660208301529392505050565b60008282101561405357614053613edb565b500390565b634e487b7160e01b600052601260045260246000fd5b60006001600160401b038084168061408857614088614058565b92169190910492915050565b6000826140a3576140a3614058565b500490565b60008160001904831182151516156140c2576140c2613edb565b500290565b600083516140d98184602088016138f9565b835190830190613f138183602088016138f9565b8035602083101561092857600019602084900360031b1b1692915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000600182016141b6576141b6613edb565b5060010190565b6000826141cc576141cc614058565b500690565b600082198211156141e4576141e4613edb565b500190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161424d8160178501602088016138f9565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161427e8160288401602088016138f9565b01602801949350505050565b60008161429957614299613edb565b50600019019056fe68747470733a2f2f6170692e726169642e70617274792f6d657461646174612f6775696c642fa2646970667358221220ad7586db8a28c9e7848fb75569386adeed61904fae98089837074280a743dc1164736f6c634300080d0033

Deployed Bytecode

0x608060405234801561001057600080fd5b50600436106102f15760003560e01c80635a3638641161019d578063b9a54f6d116100e9578063d4d10cd2116100a2578063df1dd9761161007c578063df1dd97614610884578063f4ec87d3146108a9578063fe55932a146108d0578063fe9fbb80146108e357600080fd5b8063d4d10cd214610856578063d547741f14610869578063d66d9e191461087c57600080fd5b8063b9a54f6d146107ac578063c477ecab146107dd578063c741e13c146107fd578063c87b56dd1461081d578063c92d2b7814610830578063ca15c8731461084357600080fd5b80639010d07c1161015657806396c551751161013057806396c551751461076b578063a217fddf1461077e578063a5ef8aa614610786578063b6b55f251461079957600080fd5b80639010d07c1461071a57806391d148541461074557806392fea19a1461075857600080fd5b80635a363864146106c35780636b8ff574146106d15780637fcfb7c2146106e4578063838b836b146106f75780638456cb591461070a5780638d8a34261461071257600080fd5b806336568abe1161025c57806347444bc111610215578063502e9e9a116101ef578063502e9e9a146106505780635729b3941461067a57806357dd13111461068d578063580a14461461069757600080fd5b806347444bc11461060e578063479e9ded1461061657806348a887061461063d57600080fd5b806336568abe1461059057806337b9b2d0146105a35780633db68934146105cd5780633f4ba83a146105e05780633fe41235146105e857806345977d03146105fb57600080fd5b8063248a9ca3116102ae578063248a9ca3146103e25780632893c5b0146104135780632ada2596146104265780632def6620146105545780632e0f26251461055c5780632f2ff15d1461057d57600080fd5b806301ffc9a7146102f6578063022b1a861461031e5780631459457a14610350578063150b7a0214610365578063164491ae1461039c5780631c68c4b1146103c2575b600080fd5b6103096103043660046138cf565b61091d565b60405190151581526020015b60405180910390f35b61034360405180604001604052806006815260200165496e7669746560d01b81525081565b6040516103159190613951565b61036361035e366004613979565b61092e565b005b610383610373366004613a8c565b630a85bd0160e11b949350505050565b6040516001600160e01b03199091168152602001610315565b6103af6103aa366004613af7565b610a8b565b60405161ffff9091168152602001610315565b6103d56103d0366004613af7565b610ab6565b6040516103159190613b6c565b6104056103f0366004613af7565b60009081526065602052604090206001015490565b604051908152602001610315565b610363610421366004613b7a565b610ada565b6104ec610434366004613bbf565b6040805160c081018252600080825260208201819052918101829052606081018290526080810182905260a0810191909152506001600160a01b031660009081526101356020908152604091829020825160c081018452815481526001909101546001600160401b0380821693830193909352600160401b810490921692810192909252600160801b810463ffffffff166060830152600160a01b810461ffff166080830152600160b01b900460ff1660a082015290565b6040516103159190600060c0820190508251825260208301516001600160401b038082166020850152806040860151166040850152505063ffffffff606084015116606083015261ffff608084015116608083015260ff60a08401511660a083015292915050565b610363610b3f565b6105656103e881565b6040516001600160401b039091168152602001610315565b61036361058b366004613bdc565b610c73565b61036361059e366004613bdc565b610c98565b6104056105b1366004613bbf565b6001600160a01b03166000908152610135602052604090205490565b6103636105db366004613c19565b610d1b565b610363610f0a565b6104056105f6366004613c67565b610f26565b610363610609366004613af7565b610fa5565b610565611201565b6104057f62943daa8ff92d447f5dbd09be1204cdbd3c24313c218af83aece06ede8fe02781565b61056561064b366004613c83565b611211565b61056561065e366004613af7565b600090815261013460205260409020546001600160401b031690565b610363610688366004613af7565b6112ed565b61056562093a8081565b6103af6106a5366004613af7565b60009081526101346020526040902054600160801b900461ffff1690565b61056566038d7ea4c6800081565b6103436106df366004613af7565b611493565b6103636106f2366004613ca5565b611501565b610363610705366004613cda565b611661565b610363611889565b6103636118ab565b61072d610728366004613c83565b611a19565b6040516001600160a01b039091168152602001610315565b610309610753366004613bdc565b611a31565b610363610766366004613d06565b611a5c565b610363610779366004613bbf565b611ba4565b610405600081565b6103af610794366004613cda565b611c8d565b6103636107a7366004613af7565b611caa565b6105656107ba366004613af7565b60009081526101346020526040902054600160401b90046001600160401b031690565b6107f06107eb366004613af7565b611f89565b6040516103159190613d91565b610343604051806040016040528060018152602001603160f81b81525081565b61034361082b366004613af7565b611ff9565b61056561083e366004613db6565b612033565b610405610851366004613af7565b612304565b610565610864366004613de0565b61231b565b610363610877366004613bdc565b612385565b6103636123aa565b610897610892366004613af7565b612415565b60405161031596959493929190613dfb565b6104057f4869181a7e5731ab23dde0d3dc3b910af0cdaafa9758229938033fda786278f881565b6103636108de366004613e60565b6124db565b6103096108f1366004613bbf565b6001600160a01b0316600090815261013560205260409020600190810154600160b01b900460ff161490565b60006109288261267a565b92915050565b600061093a600161269f565b90508015610952576000805461ff0019166101001790555b61095a61272c565b61099b60405180604001604052806006815260200165496e7669746560d01b815250604051806040016040528060018152602001603160f81b815250612755565b6109a6600087612786565b6109d07f62943daa8ff92d447f5dbd09be1204cdbd3c24313c218af83aece06ede8fe02787612786565b61013180546001600160a01b038086166001600160a01b031992831617909255610133805461012f80548a8616908516179055610130805489861690851617905561013280548786169416939093179092556001600160a81b031990911691881691909117600160a01b1790558015610a83576000805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b505050505050565b60008181526101346020526040812054600160801b900461ffff16610aaf81612790565b9392505050565b610abe613893565b60008281526101346020526040902060010154610928906127fe565b7f62943daa8ff92d447f5dbd09be1204cdbd3c24313c218af83aece06ede8fe027610b0481612847565b61013354600160a01b900460ff1615610b30576040516313d0ff5960e31b815260040160405180910390fd5b610b3a8383612851565b505050565b61013354600160a01b900460ff1615610b6b576040516313d0ff5960e31b815260040160405180910390fd5b3360009081526101356020526040812060018101549091600160801b90910463ffffffff1690819003610bb15760405163ef6e66dd60e01b815260040160405180910390fd5b60018201805463ffffffff60801b1916905561013054604051632142170760e11b815230600482015233602482015263ffffffff831660448201526001600160a01b03909116906342842e0e90606401600060405180830381600087803b158015610c1b57600080fd5b505af1158015610c2f573d6000803e3d6000fd5b505060405163ffffffff841681523392507f85082129d87b2fe11527cb1b3b7a520aeb5aa6913f88a3d8757fe40d1db02fdd91506020015b60405180910390a25050565b600082815260656020526040902060010154610c8e81612847565b610b3a8383612922565b6001600160a01b0381163314610d0d5760405162461bcd60e51b815260206004820152602f60248201527f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560448201526e103937b632b9903337b91039b2b63360891b60648201526084015b60405180910390fd5b610d178282612944565b5050565b61013354600160a01b900460ff1615610d47576040516313d0ff5960e31b815260040160405180910390fd5b4282604001351015610d6c5760405163a09a5b5f60e01b815260040160405180910390fd5b33600090815261013560205260409020805415610d9c576040516376ad0b6960e11b815260040160405180910390fd5b610da68383612966565b6020838101356000908152610134909152604090208054610dd190600160801b900461ffff16612790565b61ffff16816003018054905010610dfb57604051630a44ab9d60e21b815260040160405180910390fd5b602084013582556001820180546001600160401b03428116600160401b90810267ffffffffffffffff60401b19841681178555600386015461ffff16600160a01b0261ffff60a01b1990911675ffff00000000ffffffffffffffff0000000000000000199094169390931792909217928390558354928116928492600892610e87928692900416613ef1565b82546001600160401b039182166101009390930a9283029190920219909116179055506003810180546001810182556000918252602080832090910180546001600160a01b03191633908117909155604051918701359290917fb4e09949657f21548b58afe74e7b86cd2295da5ff1598ae1e5faecb1cf19ca959190a350505050565b6000610f1581612847565b50610133805460ff60a01b19169055565b60006109287f4869181a7e5731ab23dde0d3dc3b910af0cdaafa9758229938033fda786278f8610f596020850185613bbf565b604080516020818101949094526001600160a01b039092168282015291850135606082015290840135608082015260a00160405160208183030381529060405280519060200120612a5d565b61013354600160a01b900460ff1615610fd1576040516313d0ff5960e31b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e90602401602060405180830381865afa15801561101b573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061103f9190613f1c565b6001600160a01b031614158015611074575033600090815261013560205260409020600190810154600160b01b900460ff1614155b156110925760405163061cbdd360e51b815260040160405180910390fd5b60008181526101346020526040902080546005600160801b90910461ffff16106110cf57604051637177a3a360e11b815260040160405180910390fd5b80546000906110e890600160801b900461ffff1661231b565b82549091506001600160401b03908116908216111561113b578154611116906001600160401b031682613f39565b6040516365bc667160e11b81526001600160401b039091166004820152602401610d04565b8154819083906000906111589084906001600160401b0316613f39565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060018260000160108282829054906101000a900461ffff1661119e9190613f61565b82546101009290920a61ffff8181021990931691831602179091558354604051600160801b90910490911681528491507f964674a14f5875e45d79829f44fec1a2810393fbfcbb7372882936f6d4cecbe0906020015b60405180910390a2505050565b61120e6103e86032613f7e565b81565b600081156112e45760008281526101346020908152604091829020825160c08101845281546001600160401b038082168352600160401b82041682850152600160801b900461ffff168185015260018201546060820152600282015460808201526003820180548551818602810186019096528086526112df95899593949360a08601939192908301828280156112d157602002820191906000526020600020905b81546001600160a01b031681526001909101906020018083116112b3575b505050505081525050612aab565b610aaf565b60009392505050565b61013354600160a01b900460ff1615611319576040516313d0ff5960e31b815260040160405180910390fd5b6101315460405163079cc67960e41b8152336004820152602481018390526001600160a01b03909116906379cc679090604401600060405180830381600087803b15801561136657600080fd5b505af115801561137a573d6000803e3d6000fd5b5050505060006113918266038d7ea4c68000900490565b33600090815261013560205260408120600101805492935083929091906113c29084906001600160401b0316613ef1565b82546001600160401b039182166101009390930a92830291909202199091161790555033600090815261013560205260409020541561146157336000908152610135602090815260408083205483526101349091529020805482919060089061143c908490600160401b90046001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b031602179055505b60405182815233907f89d28cf06bdb2ee1b92cd046d58450042ad113e9f4cdabfc4d43e7c5557758d790602001610c67565b60008181526101346020526040902060020154606090806114de576114b783612aef565b6040516020016114c79190613fad565b604051602081830303815290604052915050919050565b6000838152610134602090815260409182902060020154825191820152016114c7565b61013354600160a01b900460ff161561152d576040516313d0ff5960e31b815260040160405180910390fd5b336000908152610135602052604090206001810154600160801b900463ffffffff161561156d576040516338ef830960e11b815260040160405180910390fd5b60018101805473ffffffffffffffffffffffff00000000000000001916600160801b63ffffffff851690810267ffffffffffffffff60401b191691909117600160401b426001600160401b0316021790915561013054604051632142170760e11b815233600482015230602482015260448101929092526001600160a01b0316906342842e0e90606401600060405180830381600087803b15801561161157600080fd5b505af1158015611625573d6000803e3d6000fd5b505060405163ffffffff851681523392507febedb8b3c678666e7f36970bc8f57abf6d8fa2e828c0da91ea5b75bf68ed101a9150602001610c67565b61013354600160a01b900460ff161561168d576040516313d0ff5960e31b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810184905233916001600160a01b031690636352211e90602401602060405180830381865afa1580156116d7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116fb9190613f1c565b6001600160a01b031614158015611730575033600090815261013560205260409020600190810154600160b01b900460ff1614155b1561174e5760405163061cbdd360e51b815260040160405180910390fd5b600082815261013460205260409020600181015482600581111561177457611774613fdc565b825461ffff918216600160801b90910490911610156117a8578260405163787b1aa360e11b8152600401610d049190614014565b60006117bd6117b78386612bef565b85612033565b83549091506001600160401b0390811690821611156117eb578254611116906001600160401b031682613f39565b8254819084906000906118089084906001600160401b0316613f39565b92506101000a8154816001600160401b0302191690836001600160401b031602179055506118368285612c10565b600184018190559150847f9814ff6c1019cc523465f0da9ec95d19d61fab8d6bae3f3d0043487788152ea88561186c8582612bef565b60405161187a929190614022565b60405180910390a25050505050565b600061189481612847565b50610133805460ff60a01b1916600160a01b179055565b61013354600160a01b900460ff16156118d7576040516313d0ff5960e31b815260040160405180910390fd5b3360009081526101356020526040812060018101549091600160801b90910463ffffffff16900361191b5760405163ef6e66dd60e01b815260040160405180910390fd5b600181015462093a809061193f90600160401b90046001600160401b031642614041565b101561198057600181015461196490600160401b90046001600160401b031642614041565b6040516305d7bfbd60e41b8152600401610d0491815260200190565b600181015460009062093a80906119a790600160401b90046001600160401b031642613f39565b6119b1919061406e565b905062093a806119c18142614094565b6119cb91906140a8565b6001830180546001600160401b0392909216600160401b0267ffffffffffffffff60401b19909216919091179055610d1733611a0a6103e86032613f7e565b611a149084613f7e565b612851565b6000828152609760205260408120610aaf9083612c63565b60009182526065602090815260408084206001600160a01b0393909316845291905290205460ff1690565b61013354600160a01b900460ff1615611a88576040516313d0ff5960e31b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810185905233916001600160a01b031690636352211e90602401602060405180830381865afa158015611ad2573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611af69190613f1c565b6001600160a01b031614611b1d57604051631648b6a960e11b815260040160405180910390fd5b6001600160a01b038216600090815261013560205260409020548314611b565760405163bf27d90360e01b815260040160405180910390fd5b80611b62576000611b65565b60015b6001600160a01b03909216600090815261013560205260409020600101805460ff93909316600160b01b0260ff60b01b19909316929092179091555050565b61013354600160a01b900460ff1615611bd0576040516313d0ff5960e31b815260040160405180910390fd5b6001600160a01b03808216600090815261013560205260409081902061012f54815492516331a9108f60e11b815291933393911691636352211e91611c1b9160040190815260200190565b602060405180830381865afa158015611c38573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c5c9190613f1c565b6001600160a01b031614611c8357604051631648b6a960e11b815260040160405180910390fd5b610d178282612c6f565b60008281526101346020526040812060010154610aaf9083612bef565b61013354600160a01b900460ff1615611cd6576040516313d0ff5960e31b815260040160405180910390fd5b336000908152610135602052604081208054909103611d085760405163bf27d90360e01b815260040160405180910390fd5b8054600090815261013460205260409081902061013154915163079cc67960e41b81523360048201526024810185905290916001600160a01b0316906379cc679090604401600060405180830381600087803b158015611d6757600080fd5b505af1158015611d7b573d6000803e3d6000fd5b50506040805160c08101825284546001600160401b038082168352600160401b820416602080840191909152600160801b90910461ffff1682840152600186015460608301526002860154608083015260038601805484518184028101840190955280855260009650611e3a95508994889360a08601939192908301828280156112d1576020028201919060005260206000209081546001600160a01b031681526001909101906020018083116112b357505050505081525050612aab565b825490915081908390600090611e5a9084906001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060006002611e938666038d7ea4c68000900490565b611e9d919061406e565b6001850180549192508291600090611ebf9084906001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b03160217905550808360000160088282829054906101000a90046001600160401b0316611f099190613ef1565b92506101000a8154816001600160401b0302191690836001600160401b031602179055508360000154336001600160a01b03167f90890809c654f11d6e72a28fa60149770a0d11ec6c92319d6ceb2bb0a4ea1a1584604051611f7a91906001600160401b0391909116815260200190565b60405180910390a35050505050565b60008181526101346020908152604091829020600301805483518184028101840190945280845260609392830182828015611fed57602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311611fcf575b50505050509050919050565b6060612003612f6d565b61200c83612aef565b60405160200161201d9291906140c7565b6040516020818303038152906040529050919050565b6000808083600581111561204957612049613fdc565b036120ac578361ffff1660000361206357506113886122f0565b8361ffff1660010361207857506127106122f0565b8361ffff1660020361208d5750614e206122f0565b8361ffff166003036120a2575061c3506122f0565b50620186a06122f0565b60018360058111156120c0576120c0613fdc565b03612124578361ffff166000036120da57506127106122f0565b8361ffff166001036120ef5750614e206122f0565b8361ffff16600203612104575061c3506122f0565b8361ffff1660030361211a5750620186a06122f0565b506203d0906122f0565b600283600581111561213857612138613fdc565b0361219d578361ffff166000036121525750614e206122f0565b8361ffff16600103612167575061c3506122f0565b8361ffff1660020361217d5750620186a06122f0565b8361ffff1660030361219357506203d0906122f0565b506207a1206122f0565b60038360058111156121b1576121b1613fdc565b03612217578361ffff166000036121cb575061c3506122f0565b8361ffff166001036121e15750620186a06122f0565b8361ffff166002036121f757506203d0906122f0565b8361ffff1660030361220d57506207a1206122f0565b50620f42406122f0565b600483600581111561222b5761222b613fdc565b03612292578361ffff166000036122465750620186a06122f0565b8361ffff1660010361225c57506203d0906122f0565b8361ffff1660020361227257506207a1206122f0565b8361ffff166003036122885750620f42406122f0565b50621e84806122f0565b8361ffff166000036122a857506203d0906122f0565b8361ffff166001036122be57506207a1206122f0565b8361ffff166002036122d45750620f42406122f0565b8361ffff166003036122ea5750621e84806122f0565b50623d09005b6122fc6103e882613f7e565b949350505050565b600081815260976020526040812061092890612f8d565b6000808261ffff166000036123335750612710612379565b8261ffff166001036123485750614e20612379565b8261ffff1660020361235d5750619c40612379565b8261ffff16600303612373575062027100612379565b50622710005b610aaf6103e882613f7e565b6000828152606560205260409020600101546123a081612847565b610b3a8383612944565b61013354600160a01b900460ff16156123d6576040516313d0ff5960e31b815260040160405180910390fd5b3360009081526101356020526040812080549091036124085760405163bf27d90360e01b815260040160405180910390fd5b6124123382612c6f565b50565b6000806000612422613893565b6000858152610134602090815260409182902080546003820180548551818602810186019096528086526001600160401b038084169a5061ffff600160801b8504169950600160401b909304909216965060609485949092908301828280156124b457602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311612496575b505050505092506124c488610ab6565b93506124cf88611493565b91505091939550919395565b61013354600160a01b900460ff1615612507576040516313d0ff5960e31b815260040160405180910390fd5b602081111561252957604051632d0483c560e21b815260040160405180910390fd5b61012f546040516331a9108f60e11b81526004810185905233916001600160a01b031690636352211e90602401602060405180830381865afa158015612573573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125979190613f1c565b6001600160a01b0316146125be57604051631648b6a960e11b815260040160405180910390fd5b60008381526101346020526040902060020154156125ff576000838152610134602090815260408083206002015483526101369091529020805460ff191690555b600061260b82846140ed565b9050801561265f576000818152610136602052604090205460ff1615612644576040516302d154b760e11b815260040160405180910390fd5b600081815261013660205260409020805460ff191660011790555b60009384526101346020526040909320600201929092555050565b60006001600160e01b03198216635a05180f60e01b1480610928575061092882612f97565b60008054610100900460ff16156126e6578160ff1660011480156126c25750303b155b6126de5760405162461bcd60e51b8152600401610d049061410b565b506000919050565b60005460ff80841691161061270d5760405162461bcd60e51b8152600401610d049061410b565b506000805460ff191660ff92909216919091179055600190565b919050565b600054610100900460ff166127535760405162461bcd60e51b8152600401610d0490614159565b565b600054610100900460ff1661277c5760405162461bcd60e51b8152600401610d0490614159565b610d178282612fcc565b610d178282612922565b60008161ffff166000036127a65750600a919050565b8161ffff166001036127ba5750600f919050565b8161ffff166002036127ce57506019919050565b8161ffff166003036127e257506023919050565b8161ffff166004036127f657506032919050565b506064919050565b612806613893565b61280e613893565b8281528260101c60208201528260201c60408201528260301c60608201528260401c60808201528260501c60a082015280915050919050565b612412813361300d565b6001600160a01b038216600090815261013560205260408120805490910361288c5760405163bf27d90360e01b815260040160405180910390fd5b805460009081526101346020526040812080548492906128b69084906001600160401b0316613ef1565b92506101000a8154816001600160401b0302191690836001600160401b03160217905550826001600160a01b03167f0f6798a560793a54c3bcfe86a93cde1e73087d944c0ea20544137d4121396885836040516111f491906001600160401b0391909116815260200190565b61292c8282613071565b6000828152609760205260409020610b3a90826130f7565b61294e828261310c565b6000828152609760205260409020610b3a9082613173565b336129746020840184613bbf565b6001600160a01b03161461299b5760405163586d335760e01b815260040160405180910390fd5b60006129a683610f26565b905060006129b48284613188565b61012f546040516331a9108f60e11b8152602087013560048201529192506001600160a01b031690636352211e90602401602060405180830381865afa158015612a02573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190612a269190613f1c565b6001600160a01b0316816001600160a01b031614612a5757604051631648b6a960e11b815260040160405180910390fd5b50505050565b6000610928612a6a6131ac565b8360405161190160f01b6020820152602281018390526042810182905260009060620160405160208183030381529060405280519060200120905092915050565b6000610aaf63b2d05e00612ad084602001516001600160401b031663b2d05e0061322c565b850281612adf57612adf614058565b04840166038d7ea4c68000900490565b606081600003612b165750506040805180820190915260018152600360fc1b602082015290565b8160005b8115612b405780612b2a816141a4565b9150612b399050600a83614094565b9150612b1a565b6000816001600160401b03811115612b5a57612b5a6139ea565b6040519080825280601f01601f191660200182016040528015612b84576020820181803683370190505b5090505b84156122fc57612b99600183614041565b9150612ba6600a866141bd565b612bb19060306141d1565b60f81b818381518110612bc657612bc66141e9565b60200101906001600160f81b031916908160001a905350612be8600a86614094565b9450612b88565b6000816005811115612c0357612c03613fdc565b6010029290921c92915050565b60006005612c1e8484612bef565b61ffff1610612c4057604051637177a3a360e11b815260040160405180910390fd5b816005811115612c5257612c52613fdc565b6010026001901b8301905092915050565b6000610aaf8383613242565b8054600081815261013460205260409020600183015481546001600160401b03918216918391600891612cac918591600160401b90910416613f39565b92506101000a8154816001600160401b0302191690836001600160401b0316021790555060018160030180549050612ce49190614041565b6001840154600160a01b900461ffff1614612e8357600381018054612d0b90600190614041565b81548110612d1b57612d1b6141e9565b60009182526020909120015460018401546003830180546001600160a01b03909316929091600160a01b900461ffff16908110612d5a57612d5a6141e9565b60009182526020909120015460018501546003840180546001600160a01b03909316929091600160a01b900461ffff16908110612d9957612d996141e9565b9060005260206000200160008460030160018660030180549050612dbd9190614041565b81548110612dcd57612dcd6141e9565b6000918252602082200180546001600160a01b0319166001600160a01b0395861617905582546101009290920a808502199092169490931602929092179091556001840154600383018054600160a01b90920461ffff16926101359290919084908110612e3c57612e3c6141e9565b60009182526020808320909101546001600160a01b031683528201929092526040019020600101805461ffff92909216600160a01b0261ffff60a01b199092169190911790555b80600301805480612e9657612e966141ff565b600082815260208120600019908301810180546001600160a01b031916905590910190915560018401805491855562ffffff60a01b1990911690556101325460405163bbead49d60e01b81526001600160a01b0386811660048301529091169063bbead49d90602401600060405180830381600087803b158015612f1957600080fd5b505af1158015612f2d573d6000803e3d6000fd5b50506040518492506001600160a01b03871691507f61a26f7c17d8780c095ccfa67e689a13ee4e06ddce3da18956369f4a396100e890600090a350505050565b60606040518060600160405280602681526020016142a260269139905090565b6000610928825490565b60006001600160e01b03198216637965db0b60e01b148061092857506301ffc9a760e01b6001600160e01b0319831614610928565b600054610100900460ff16612ff35760405162461bcd60e51b8152600401610d0490614159565b81516020928301208151919092012060c99190915560ca55565b6130178282611a31565b610d175761302f816001600160a01b0316601461326c565b61303a83602061326c565b60405160200161304b929190614215565b60408051601f198184030181529082905262461bcd60e51b8252610d0491600401613951565b61307b8282611a31565b610d175760008281526065602090815260408083206001600160a01b03851684529091529020805460ff191660011790556130b33390565b6001600160a01b0316816001600160a01b0316837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b6000610aaf836001600160a01b038416613407565b6131168282611a31565b15610d175760008281526065602090815260408083206001600160a01b0385168085529252808320805460ff1916905551339285917ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b9190a45050565b6000610aaf836001600160a01b038416613456565b60008060006131978585613549565b915091506131a4816135b7565b509392505050565b60006132277f8b73c3c69bb8fe3d512ecc4cf759cc79239f7b179b0ffacaa9a75d522b39400f6131db60c95490565b60ca546040805160208101859052908101839052606081018290524660808201523060a082015260009060c0016040516020818303038152906040528051906020012090509392505050565b905090565b600081831061323b5781610aaf565b5090919050565b6000826000018281548110613259576132596141e9565b9060005260206000200154905092915050565b6060600061327b8360026140a8565b6132869060026141d1565b6001600160401b0381111561329d5761329d6139ea565b6040519080825280601f01601f1916602001820160405280156132c7576020820181803683370190505b509050600360fc1b816000815181106132e2576132e26141e9565b60200101906001600160f81b031916908160001a905350600f60fb1b81600181518110613311576133116141e9565b60200101906001600160f81b031916908160001a90535060006133358460026140a8565b6133409060016141d1565b90505b60018111156133b8576f181899199a1a9b1b9c1cb0b131b232b360811b85600f1660108110613374576133746141e9565b1a60f81b82828151811061338a5761338a6141e9565b60200101906001600160f81b031916908160001a90535060049490941c936133b18161428a565b9050613343565b508315610aaf5760405162461bcd60e51b815260206004820181905260248201527f537472696e67733a20686578206c656e67746820696e73756666696369656e746044820152606401610d04565b600081815260018301602052604081205461344e57508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610928565b506000610928565b6000818152600183016020526040812054801561353f57600061347a600183614041565b855490915060009061348e90600190614041565b90508181146134f35760008660000182815481106134ae576134ae6141e9565b90600052602060002001549050808760000184815481106134d1576134d16141e9565b6000918252602080832090910192909255918252600188019052604090208390555b8554869080613504576135046141ff565b600190038181906000526020600020016000905590558560010160008681526020019081526020016000206000905560019350505050610928565b6000915050610928565b600080825160410361357f5760208301516040840151606085015160001a6135738782858561376d565b945094505050506135b0565b82516040036135a8576020830151604084015161359d86838361385a565b9350935050506135b0565b506000905060025b9250929050565b60008160048111156135cb576135cb613fdc565b036135d35750565b60018160048111156135e7576135e7613fdc565b036136345760405162461bcd60e51b815260206004820152601860248201527f45434453413a20696e76616c6964207369676e617475726500000000000000006044820152606401610d04565b600281600481111561364857613648613fdc565b036136955760405162461bcd60e51b815260206004820152601f60248201527f45434453413a20696e76616c6964207369676e6174757265206c656e677468006044820152606401610d04565b60038160048111156136a9576136a9613fdc565b036137015760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202773272076616c604482015261756560f01b6064820152608401610d04565b600481600481111561371557613715613fdc565b036124125760405162461bcd60e51b815260206004820152602260248201527f45434453413a20696e76616c6964207369676e6174757265202776272076616c604482015261756560f01b6064820152608401610d04565b6000807f7fffffffffffffffffffffffffffffff5d576e7357a4501ddfe92f46681b20a08311156137a45750600090506003613851565b8460ff16601b141580156137bc57508460ff16601c14155b156137cd5750600090506004613851565b6040805160008082526020820180845289905260ff881692820192909252606081018690526080810185905260019060a0016020604051602081039080840390855afa158015613821573d6000803e3d6000fd5b5050604051601f1901519150506001600160a01b03811661384a57600060019250925050613851565b9150600090505b94509492505050565b6000806001600160ff1b0383168161387760ff86901c601b6141d1565b90506138858782888561376d565b935093505050935093915050565b6040805160e081018252600080825260208201819052918101829052606081018290526080810182905260a0810182905260c081019190915290565b6000602082840312156138e157600080fd5b81356001600160e01b031981168114610aaf57600080fd5b60005b838110156139145781810151838201526020016138fc565b83811115612a575750506000910152565b6000815180845261393d8160208601602086016138f9565b601f01601f19169290920160200192915050565b602081526000610aaf6020830184613925565b6001600160a01b038116811461241257600080fd5b600080600080600060a0868803121561399157600080fd5b853561399c81613964565b945060208601356139ac81613964565b935060408601356139bc81613964565b925060608601356139cc81613964565b915060808601356139dc81613964565b809150509295509295909350565b634e487b7160e01b600052604160045260246000fd5b600082601f830112613a1157600080fd5b81356001600160401b0380821115613a2b57613a2b6139ea565b604051601f8301601f19908116603f01168101908282118183101715613a5357613a536139ea565b81604052838152866020858801011115613a6c57600080fd5b836020870160208301376000602085830101528094505050505092915050565b60008060008060808587031215613aa257600080fd5b8435613aad81613964565b93506020850135613abd81613964565b92506040850135915060608501356001600160401b03811115613adf57600080fd5b613aeb87828801613a00565b91505092959194509250565b600060208284031215613b0957600080fd5b5035919050565b61ffff8082511683528060208301511660208401528060408301511660408401528060608301511660608401528060808301511660808401528060a08301511660a08401525060018060a01b0360c08201511660c08301525050565b60e081016109288284613b10565b60008060408385031215613b8d57600080fd5b8235613b9881613964565b915060208301356001600160401b0381168114613bb457600080fd5b809150509250929050565b600060208284031215613bd157600080fd5b8135610aaf81613964565b60008060408385031215613bef57600080fd5b823591506020830135613bb481613964565b600060608284031215613c1357600080fd5b50919050565b60008060808385031215613c2c57600080fd5b613c368484613c01565b915060608301356001600160401b03811115613c5157600080fd5b613c5d85828601613a00565b9150509250929050565b600060608284031215613c7957600080fd5b610aaf8383613c01565b60008060408385031215613c9657600080fd5b50508035926020909101359150565b600060208284031215613cb757600080fd5b813563ffffffff81168114610aaf57600080fd5b80356006811061272757600080fd5b60008060408385031215613ced57600080fd5b82359150613cfd60208401613ccb565b90509250929050565b600080600060608486031215613d1b57600080fd5b833592506020840135613d2d81613964565b915060408401358015158114613d4257600080fd5b809150509250925092565b600081518084526020808501945080840160005b83811015613d865781516001600160a01b031687529582019590820190600101613d61565b509495945050505050565b602081526000610aaf6020830184613d4d565b803561ffff8116811461272757600080fd5b60008060408385031215613dc957600080fd5b613dd283613da4565b9150613cfd60208401613ccb565b600060208284031215613df257600080fd5b610aaf82613da4565b6001600160401b03878116825261ffff87166020830152851660408201526000610180613e2b6060840187613b10565b80610140840152613e3e81840186613d4d565b9050828103610160840152613e538185613925565b9998505050505050505050565b600080600060408486031215613e7557600080fd5b8335925060208401356001600160401b0380821115613e9357600080fd5b818601915086601f830112613ea757600080fd5b813581811115613eb657600080fd5b876020828501011115613ec857600080fd5b6020830194508093505050509250925092565b634e487b7160e01b600052601160045260246000fd5b60006001600160401b03808316818516808303821115613f1357613f13613edb565b01949350505050565b600060208284031215613f2e57600080fd5b8151610aaf81613964565b60006001600160401b0383811690831681811015613f5957613f59613edb565b039392505050565b600061ffff808316818516808303821115613f1357613f13613edb565b60006001600160401b0380831681851681830481118215151615613fa457613fa4613edb565b02949350505050565b664775696c64202360c81b815260008251613fcf8160078501602087016138f9565b9190910160070192915050565b634e487b7160e01b600052602160045260246000fd5b6006811061401057634e487b7160e01b600052602160045260246000fd5b9052565b602081016109288284613ff2565b604081016140308285613ff2565b61ffff831660208301529392505050565b60008282101561405357614053613edb565b500390565b634e487b7160e01b600052601260045260246000fd5b60006001600160401b038084168061408857614088614058565b92169190910492915050565b6000826140a3576140a3614058565b500490565b60008160001904831182151516156140c2576140c2613edb565b500290565b600083516140d98184602088016138f9565b835190830190613f138183602088016138f9565b8035602083101561092857600019602084900360031b1b1692915050565b6020808252602e908201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160408201526d191e481a5b9a5d1a585b1a5e995960921b606082015260800190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b6000600182016141b6576141b6613edb565b5060010190565b6000826141cc576141cc614058565b500690565b600082198211156141e4576141e4613edb565b500190565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052603160045260246000fd5b7f416363657373436f6e74726f6c3a206163636f756e742000000000000000000081526000835161424d8160178501602088016138f9565b7001034b99036b4b9b9b4b733903937b6329607d1b601791840191820152835161427e8160288401602088016138f9565b01602801949350505050565b60008161429957614299613edb565b50600019019056fe68747470733a2f2f6170692e726169642e70617274792f6d657461646174612f6775696c642fa2646970667358221220ad7586db8a28c9e7848fb75569386adeed61904fae98089837074280a743dc1164736f6c634300080d0033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

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

Validator Index Block Amount
View All Withdrawals

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

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